审查视图

pkg/port/beego/controllers/web_client/cooperation_contract_controller.go 5.6 KB
tangxuhui authored
1 2 3 4 5 6
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationContract/service"
tangxuhui authored
7
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
tangxuhui authored
8 9 10
)

type CooperationContractController struct {
tangxuhui authored
11
	baseController
tangxuhui authored
12 13 14 15 16
}

func (controller *CooperationContractController) CreateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	createCooperationContractCommand := &command.CreateCooperationContractCommand{}
tangxuhui authored
17 18 19
	err := controller.Unmarshal(createCooperationContractCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
20 21
		controller.Response(nil, err)
		return
tangxuhui authored
22 23
	}
	createCooperationContractCommand.Operator = controller.GetOperator()
tangxuhui authored
24 25 26 27 28 29 30
	data, err := cooperationContractService.CreateCooperationContract(createCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) UpdateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
tangxuhui authored
31 32 33
	err := controller.Unmarshal(updateCooperationContractCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
34 35
		controller.Response(nil, err)
		return
tangxuhui authored
36
	}
tangxuhui authored
37
	contractId, _ := controller.GetInt(":contractId")
tangxuhui authored
38
	updateCooperationContractCommand.Operator = controller.GetOperator()
tangxuhui authored
39
	updateCooperationContractCommand.CooperationContract.CooperationContractId = contractId
tangxuhui authored
40 41 42 43 44 45 46 47
	data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) GetCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	getCooperationContractQuery := &query.GetCooperationContractQuery{}
	contractId, _ := controller.GetInt(":contractId")
tangxuhui authored
48
	getCooperationContractQuery.Operator = controller.GetOperator()
tangxuhui authored
49 50 51 52 53 54 55 56
	getCooperationContractQuery.CooperationContractId = contractId
	data, err := cooperationContractService.GetCooperationContract(getCooperationContractQuery)
	controller.Response(data, err)
}

func (controller *CooperationContractController) ListCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	listCooperationContractQuery := &query.ListCooperationContractQuery{}
tangxuhui authored
57 58 59
	err := controller.Unmarshal(listCooperationContractQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
60 61
		controller.Response(nil, err)
		return
tangxuhui authored
62 63 64 65
	}
	listCooperationContractQuery.Operator = controller.GetOperator()
	cnt, data, err := cooperationContractService.ListCooperationContract(listCooperationContractQuery)
	controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber)
tangxuhui authored
66 67 68 69 70
}

func (controller *CooperationContractController) EnableCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	enableCooperationContractCommand := &command.EnableCooperationContractCommand{}
tangxuhui authored
71 72 73
	err := controller.Unmarshal(enableCooperationContractCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
74 75
		controller.Response(nil, err)
		return
tangxuhui authored
76
	}
tangxuhui authored
77
	enableCooperationContractCommand.Operator = controller.GetOperator()
tangxuhui authored
78 79 80
	data, err := cooperationContractService.EnableCooperationContract(enableCooperationContractCommand)
	controller.Response(data, err)
}
tangxuhui authored
81 82 83 84 85 86 87

func (controller *CooperationContractController) SearchCooperationContractsByUndertake() {
	cooperationContractService := service.NewCooperationContractService(nil)
	listCooperationContractQuery := &query.SearchCooperationContractsByUndertake{}
	err := controller.Unmarshal(listCooperationContractQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
88 89
		controller.Response(nil, err)
		return
tangxuhui authored
90 91 92 93 94
	}
	listCooperationContractQuery.Operator = controller.GetOperator()
	cnt, data, err := cooperationContractService.SearchCooperationContractsByUndertake(listCooperationContractQuery)
	controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber)
}
tangxuhui authored
95 96 97 98 99 100 101

func (controller *CooperationContractController) RemoveCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
	err := controller.Unmarshal(removeCooperationContractCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
102 103
		controller.Response(nil, err)
		return
tangxuhui authored
104
	}
tangxuhui authored
105
	removeCooperationContractCommand.Operator = controller.GetOperator()
tangxuhui authored
106 107 108
	data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
	controller.Response(data, err)
}
109 110

//分红订单,分红退货单获取关联合约选择列表
111
func (controller *CooperationContractController) SelectorContractForDividendsOrder() {
112 113 114 115 116 117 118 119 120
	cooperationContractService := service.NewCooperationContractService(nil)
	listCooperationContractQuery := &query.ListContractSelectorQuery{}
	err := controller.Unmarshal(listCooperationContractQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
		controller.Response(nil, err)
		return
	}
	listCooperationContractQuery.Operator = controller.GetOperator()
121
	cnt, data, err := cooperationContractService.ContractSelectorForDividendsOrder(listCooperationContractQuery)
122 123
	controller.ReturnPageListData(int64(cnt), data, err, listCooperationContractQuery.PageNumber)
}