cooperation_contract_controller.go 7.8 KB
package controllers

import (
	"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 {
	BaseController
}

func (controller *CooperationContractController) CreateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	createCooperationContractCommand := &command.CreateCooperationContractCommand{}
	_ = controller.Unmarshal(createCooperationContractCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	createCooperationContractCommand.CompanyId = header.CompanyId
	createCooperationContractCommand.OrgId = header.OrgId
	createCooperationContractCommand.UserId = header.UserId
	createCooperationContractCommand.UserBaseId = header.UserBaseId
	data, err := cooperationContractService.CreateCooperationContract(createCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) UpdateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
	_ = controller.Unmarshal(updateCooperationContractCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	updateCooperationContractCommand.CompanyId = header.CompanyId
	updateCooperationContractCommand.OrgId = header.OrgId
	updateCooperationContractCommand.UserId = header.UserId
	updateCooperationContractCommand.UserBaseId = header.UserBaseId
	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{}
	header := controller.GetRequestHeader(controller.Ctx)
	getCooperationContractQuery.CompanyId = header.CompanyId
	getCooperationContractQuery.OrgId = header.OrgId
	getCooperationContractQuery.UserId = header.UserId
	getCooperationContractQuery.UserBaseId = header.UserBaseId
	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)
	header := controller.GetRequestHeader(controller.Ctx)
	removeCooperationContractCommand.CompanyId = header.CompanyId
	removeCooperationContractCommand.OrgId = header.OrgId
	removeCooperationContractCommand.UserId = header.UserId
	removeCooperationContractCommand.UserBaseId = header.UserBaseId
	cooperationContractId, _ := controller.GetInt64(":cooperationContractId")
	removeCooperationContractCommand.CooperationContractId = cooperationContractId
	data, err := cooperationContractService.RemoveCooperationContract(removeCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) BatchRemoveCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	batchRemoveCooperationContractCommand := &command.BatchRemoveCooperationContractCommand{}
	_ = controller.Unmarshal(batchRemoveCooperationContractCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	batchRemoveCooperationContractCommand.CompanyId = header.CompanyId
	batchRemoveCooperationContractCommand.OrgId = header.OrgId
	batchRemoveCooperationContractCommand.UserId = header.UserId
	batchRemoveCooperationContractCommand.UserBaseId = header.UserBaseId
	data, err := cooperationContractService.BatchRemoveCooperationContract(batchRemoveCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) OperateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	opreateCooperationContractCommand := &command.OperateCooperationContractCommand{}
	_ = controller.Unmarshal(opreateCooperationContractCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	opreateCooperationContractCommand.CompanyId = header.CompanyId
	opreateCooperationContractCommand.OrgId = header.OrgId
	opreateCooperationContractCommand.UserId = header.UserId
	opreateCooperationContractCommand.UserBaseId = header.UserBaseId
	data, err := cooperationContractService.OperateCooperationContract(opreateCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) BatchOperateCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	batchOperateCooperationContractCommand := &command.BatchOperateCooperationContractCommand{}
	_ = controller.Unmarshal(batchOperateCooperationContractCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	batchOperateCooperationContractCommand.CompanyId = header.CompanyId
	batchOperateCooperationContractCommand.OrgId = header.OrgId
	batchOperateCooperationContractCommand.UserId = header.UserId
	batchOperateCooperationContractCommand.UserBaseId = header.UserBaseId
	data, err := cooperationContractService.BatchOperateCooperationContract(batchOperateCooperationContractCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) SearchCooperationContract() {
	cooperationContractService := service.NewCooperationContractService(nil)
	searchCooperationContractQuery := &query.SearchCooperationContractQuery{}
	_ = controller.Unmarshal(searchCooperationContractQuery)
	header := controller.GetRequestHeader(controller.Ctx)
	searchCooperationContractQuery.CompanyId = header.CompanyId
	searchCooperationContractQuery.OrgId = header.OrgId
	searchCooperationContractQuery.UserId = header.UserId
	searchCooperationContractQuery.UserBaseId = header.UserBaseId
	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{}
	header := controller.GetRequestHeader(controller.Ctx)
	listCooperationContractQuery.CompanyId = header.CompanyId
	listCooperationContractQuery.OrgId = header.OrgId
	listCooperationContractQuery.UserId = header.UserId
	listCooperationContractQuery.UserBaseId = header.UserBaseId
	pageSize, _ := controller.GetInt64("pageSize")
	listCooperationContractQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt64("pageNumber")
	listCooperationContractQuery.PageNumber = pageNumber
	data, err := cooperationContractService.ListCooperationContract(listCooperationContractQuery)
	controller.Response(data, err)
}