dividends_order_controller.go 3.3 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"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 {
	beego.BaseController
}

func (controller *DividendsOrderController) CreateDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	createDividendsOrderCommand := &command.CreateDividendsOrderCommand{}
	controller.Unmarshal(createDividendsOrderCommand)
	data, err := dividendsOrderService.CreateDividendsOrder(createDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) UpdateDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	updateDividendsOrderCommand := &command.UpdateDividendsOrderCommand{}
	controller.Unmarshal(updateDividendsOrderCommand)
	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{}
	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)
	dividendsOrderId := controller.GetString(":dividendsOrderId")
	removeDividendsOrderCommand.DividendsOrderId = dividendsOrderId
	data, err := dividendsOrderService.RemoveDividendsOrder(removeDividendsOrderCommand)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) SearchDividendsOrder() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	searchDividendsOrderQuery := &query.SearchDividendsOrderQuery{}
	data, err := dividendsOrderService.SearchDividendsOrder(searchDividendsOrderQuery)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) SearchDividendsOrderNumber() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	searchDividendsOrderNumberQuery := &query.SearchDividendsOrderNumberQuery{}
	data, err := dividendsOrderService.SearchDividendsOrderNumber(searchDividendsOrderNumberQuery)
	controller.Response(data, err)
}

func (controller *DividendsOrderController) ListDividendsOrders() {
	dividendsOrderService := service.NewDividendsOrderService(nil)
	listDividendsOrdersQuery := &query.ListDividendsOrdersQuery{}
	offset, _ := controller.GetInt("offset")
	listDividendsOrdersQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listDividendsOrdersQuery.Limit = limit
	data, err := dividendsOrderService.ListDividendsOrders(listDividendsOrdersQuery)
	controller.Response(data, err)
}