cooperation_contract_controller.go 2.6 KB
package web_client

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

type CooperationContractController struct {
	beego.BaseController
}

func (controller *CooperationContractController) CreateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	createCooperationContractCommand := &command.CreateCooperationContractCommand{}
	controller.Unmarshal(createCooperationContractCommand)
	data, err := cooperationContractService.CreateCooperationContract(createCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) UpdateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
	controller.Unmarshal(updateCooperationContractCommand)
	contractId, _ := controller.GetInt(":contractId")
	updateCooperationContractCommand.CooperationContractId = contractId
	data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) GetCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	getCooperationContractQuery := &query.GetCooperationContractQuery{}
	contractId, _ := controller.GetInt(":contractId")
	getCooperationContractQuery.CooperationContractId = contractId
	data, err := cooperationContractService.GetCooperationContract(getCooperationContractQuery)
	controller.Response(data, err)
}

func (controller *CooperationContractController) ListCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	listCooperationContractQuery := &query.ListCooperationContractQuery{}
	data, err := cooperationContractService.ListCooperationContract(listCooperationContractQuery)
	controller.Response(data, err)
}

func (controller *CooperationContractController) EnableCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	enableCooperationContractCommand := &command.EnableCooperationContractCommand{}
	controller.Unmarshal(enableCooperationContractCommand)
	data, err := cooperationContractService.EnableCooperationContract(enableCooperationContractCommand)
	controller.Response(data, err)
}