dividends_order_controller.go 6.0 KB
package controllers

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/service"
)

type DividendsOrderController struct {
	BaseController
}

func (controller *DividendsOrderController) CreateDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	createDividendsOrderCommand := &command.CreateDividendsOrderCommand{}
	_ = controller.Unmarshal(createDividendsOrderCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	createDividendsOrderCommand.CompanyId = header.CompanyId
	createDividendsOrderCommand.OrgId = header.OrgId
	createDividendsOrderCommand.UserId = header.UserId
	createDividendsOrderCommand.UserBaseId = header.UserBaseId
	data, err := dividendsOrderService.CreateDividendsOrder(createDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) UpdateDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	updateDividendsOrderCommand := &command.UpdateDividendsOrderCommand{}
	_ = controller.Unmarshal(updateDividendsOrderCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	updateDividendsOrderCommand.CompanyId = header.CompanyId
	updateDividendsOrderCommand.OrgId = header.OrgId
	updateDividendsOrderCommand.UserId = header.UserId
	updateDividendsOrderCommand.UserBaseId = header.UserBaseId
	dividendsOrderId := controller.GetString(":dividendsOrderId")
	updateDividendsOrderCommand.DividendsOrderId = dividendsOrderId
	data, err := dividendsOrderService.UpdateDividendsOrder(updateDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) GetDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	getDividendsOrderQuery := &query.GetDividendsOrderQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	getDividendsOrderQuery.CompanyId = header.CompanyId
	getDividendsOrderQuery.OrgId = header.OrgId
	getDividendsOrderQuery.UserId = header.UserId
	getDividendsOrderQuery.UserBaseId = header.UserBaseId
	dividendsOrderId, _ := controller.GetInt64(":dividendsOrderId")
	getDividendsOrderQuery.DividendsOrderId = dividendsOrderId
	data, err := dividendsOrderService.GetDividendsOrder(getDividendsOrderQuery)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) RemoveDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	removeDividendsOrderCommand := &command.RemoveDividendsOrderCommand{}
	_ = controller.Unmarshal(removeDividendsOrderCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	removeDividendsOrderCommand.CompanyId = header.CompanyId
	removeDividendsOrderCommand.OrgId = header.OrgId
	removeDividendsOrderCommand.UserId = header.UserId
	removeDividendsOrderCommand.UserBaseId = header.UserBaseId
	dividendsOrderId := controller.GetString(":dividendsOrderId")
	removeDividendsOrderCommand.DividendsOrderId = dividendsOrderId
	data, err := dividendsOrderService.RemoveDividendsOrder(removeDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) BatchRemoveDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	batchRemoveDividendsOrderCommand := &command.BatchRemoveDividendsOrderCommand{}
	_ = controller.Unmarshal(batchRemoveDividendsOrderCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	batchRemoveDividendsOrderCommand.CompanyId = header.CompanyId
	batchRemoveDividendsOrderCommand.OrgId = header.OrgId
	batchRemoveDividendsOrderCommand.UserId = header.UserId
	batchRemoveDividendsOrderCommand.UserBaseId = header.UserBaseId
	data, err := dividendsOrderService.BatchRemoveDividendsOrder(batchRemoveDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) SearchDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	searchDividendsOrderQuery := &query.SearchDividendsOrderQuery{}
	_ = controller.Unmarshal(searchDividendsOrderQuery)
	header := controller.GetRequestHeader(controller.Ctx)
	searchDividendsOrderQuery.CompanyId = header.CompanyId
	searchDividendsOrderQuery.OrgId = header.OrgId
	searchDividendsOrderQuery.UserId = header.UserId
	searchDividendsOrderQuery.UserBaseId = header.UserBaseId
	data, err := dividendsOrderService.SearchDividendsOrder(searchDividendsOrderQuery)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) SearchDividendsOrderNumber() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	searchDividendsOrderNumberQuery := &query.SearchDividendsOrderNumberQuery{}
	_ = controller.Unmarshal(searchDividendsOrderNumberQuery)
	header := controller.GetRequestHeader(controller.Ctx)
	searchDividendsOrderNumberQuery.CompanyId = header.CompanyId
	searchDividendsOrderNumberQuery.OrgId = header.OrgId
	searchDividendsOrderNumberQuery.UserId = header.UserId
	searchDividendsOrderNumberQuery.UserBaseId = header.UserBaseId
	data, err := dividendsOrderService.SearchDividendsOrderNumber(searchDividendsOrderNumberQuery)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) ListDividendsOrders() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	listDividendsOrdersQuery := &query.ListDividendsOrdersQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	listDividendsOrdersQuery.CompanyId = header.CompanyId
	listDividendsOrdersQuery.OrgId = header.OrgId
	listDividendsOrdersQuery.UserId = header.UserId
	listDividendsOrdersQuery.UserBaseId = header.UserBaseId
	pageSize, _ := controller.GetInt64("pageSize")
	listDividendsOrdersQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt64("pageNumber")
	listDividendsOrdersQuery.PageNumber = pageNumber
	data, err := dividendsOrderService.ListDividendsOrders(listDividendsOrdersQuery)
	controller.Response(data, err)
}