cooperation_project_controller.go 4.0 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/service"
)

type CooperationProjectController struct {
	beego.BaseController
}

func (controller *CooperationProjectController) ReleaseCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	releaseCooperationProjectCommand := &command.ReleaseCooperationProjectCommand{}
	controller.Unmarshal(releaseCooperationProjectCommand)
	data, err := cooperationProjectService.ReleaseCooperationProject(releaseCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) CreateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	createCooperationProjectCommand := &command.CreateCooperationProjectCommand{}
	controller.Unmarshal(createCooperationProjectCommand)
	data, err := cooperationProjectService.CreateCooperationProject(createCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) UpdateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	updateCooperationProjectCommand := &command.UpdateCooperationProjectCommand{}
	controller.Unmarshal(updateCooperationProjectCommand)
	cooperationProjectId := controller.GetString(":cooperationProjectId")
	updateCooperationProjectCommand.CooperationProjectId = cooperationProjectId
	data, err := cooperationProjectService.UpdateCooperationProject(updateCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) GetCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	getCooperationProjectQuery := &query.GetCooperationProjectQuery{}
	cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId")
	getCooperationProjectQuery.CooperationProjectId = cooperationProjectId
	data, err := cooperationProjectService.GetCooperationProject(getCooperationProjectQuery)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) RemoveCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	removeCooperationProjectCommand := &command.RemoveCooperationProjectCommand{}
	controller.Unmarshal(removeCooperationProjectCommand)
	cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId")
	removeCooperationProjectCommand.CooperationProjectId = cooperationProjectId
	data, err := cooperationProjectService.RemoveCooperationProject(removeCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) SearchCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	searchCooperationProjectQuery := &query.SearchCooperationProjectQuery{}
	data, err := cooperationProjectService.SearchCooperationProject(searchCooperationProjectQuery)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) CheckUndertaker() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	checkUndertakerQuery := &query.CheckUndertakerQuery{}
	data, err := cooperationProjectService.CheckUndertaker(checkUndertakerQuery)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) ListCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	listCooperationProjectQuery := &query.ListCooperationProjectQuery{}
	offset, _ := controller.GetInt("offset")
	listCooperationProjectQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listCooperationProjectQuery.Limit = limit
	data, err := cooperationProjectService.ListCooperationProject(listCooperationProjectQuery)
	controller.Response(data, err)
}