cooperation_contract_controller.go 3.8 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/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)
	cooperationContractId := controller.GetString(":cooperationContractId")
	updateCooperationContractCommand.CooperationContractId = cooperationContractId
	data, err := cooperationContractService.UpdateCooperationContract(updateCooperationContractCommand)
	controller.Response(data, err)
}

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

func (controller *CooperationContractController) RemoveCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	removeCooperationContractCommand := &command.RemoveCooperationContractCommand{}
	controller.Unmarshal(removeCooperationContractCommand)
	cooperationContractId, _ := controller.GetInt64(":cooperationContractId")
	removeCooperationContractCommand.CooperationContractId = cooperationContractId
	data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) SearchCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	searchCooperationContractQuery := &query.SearchCooperationContractQuery{}
	data, err := cooperationContractService.SearchCooperationContract(searchCooperationContractQuery)
	controller.Response(data, err)
}

func (controller *CooperationContractController) SearchCooperationContractByUndertaker() {
	cooperationContractService := service.NewCooperationContractService(nil)
	searchCooperationContractByUndertakerQuery := &query.SearchCooperationContractByUndertakerQuery{}
	data, err := cooperationContractService.SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery)
	controller.Response(data, err)
}

func (controller *CooperationContractController) ListCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	listCooperationContractQuery := &query.ListCooperationContractQuery{}
	offset, _ := controller.GetInt("offset")
	listCooperationContractQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listCooperationContractQuery.Limit = limit
	data, err := cooperationContractService.ListCooperationContract(listCooperationContractQuery)
	controller.Response(data, err)
}