cooperation_project_controller.go 3.2 KB
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/cooperationProject/service"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)

type CooperationProjectController struct {
	baseController
}

func (controller *CooperationProjectController) CreateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	createCooperationProjectCommand := &command.CreateCooperationProjectCommand{}
	err := controller.Unmarshal(createCooperationProjectCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	createCooperationProjectCommand.Operator = controller.GetOperator()
	data, err := cooperationProjectService.CreateCooperationProject(createCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) UpdateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	updateCooperationProjectCommand := &command.UpdateCooperationProjectCommand{}
	err := controller.Unmarshal(updateCooperationProjectCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	projectId := controller.GetString(":projectId")
	updateCooperationProjectCommand.CooperationProjectId = projectId
	updateCooperationProjectCommand.Operator = controller.GetOperator()
	data, err := cooperationProjectService.UpdateCooperationProject(updateCooperationProjectCommand)
	controller.Response(data, err)
}

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

func (controller *CooperationProjectController) ListCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	listCooperationProjectQuery := &query.ListCooperationProjectQuery{}
	err := controller.Unmarshal(listCooperationProjectQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	listCooperationProjectQuery.Operator = controller.GetOperator()
	cnt, data, err := cooperationProjectService.ListCooperationProject(listCooperationProjectQuery)
	controller.returnPageListData(cnt, data, err, listCooperationProjectQuery.PageNumber)
}

func (controller *CooperationProjectController) EndCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	endCooperationProjectCommand := &command.EndCooperationProjectCommand{}
	controller.Unmarshal(endCooperationProjectCommand)
	//TODO
	endCooperationProjectCommand.Operator = controller.GetOperator()
	data, err := cooperationProjectService.EndCooperationProject(endCooperationProjectCommand)
	controller.Response(data, err)
}