cooperation_project_controller.go 6.3 KB
package controllers

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

func (controller *CooperationProjectController) ReleaseCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	releaseCooperationProjectCommand := &command.ReleaseCooperationProjectCommand{}
	_ = controller.Unmarshal(releaseCooperationProjectCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	releaseCooperationProjectCommand.CompanyId = header.CompanyId
	releaseCooperationProjectCommand.OrgId = header.OrgId
	releaseCooperationProjectCommand.UserId = header.UserId
	releaseCooperationProjectCommand.UserBaseId = header.UserBaseId
	data, err := cooperationProjectService.ReleaseCooperationProject(releaseCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) CreateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	createCooperationProjectCommand := &command.CreateCooperationProjectCommand{}
	_ = controller.Unmarshal(createCooperationProjectCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	createCooperationProjectCommand.CompanyId = header.CompanyId
	createCooperationProjectCommand.OrgId = header.OrgId
	createCooperationProjectCommand.UserId = header.UserId
	createCooperationProjectCommand.UserBaseId = header.UserBaseId
	data, err := cooperationProjectService.CreateCooperationProject(createCooperationProjectCommand)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) UpdateCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	updateCooperationProjectCommand := &command.UpdateCooperationProjectCommand{}
	_ = controller.Unmarshal(updateCooperationProjectCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	updateCooperationProjectCommand.CompanyId = header.CompanyId
	updateCooperationProjectCommand.OrgId = header.OrgId
	updateCooperationProjectCommand.UserId = header.UserId
	updateCooperationProjectCommand.UserBaseId = header.UserBaseId
	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{}
	header := controller.GetRequestHeader(controller.Ctx)
	getCooperationProjectQuery.CompanyId = header.CompanyId
	getCooperationProjectQuery.OrgId = header.OrgId
	getCooperationProjectQuery.UserId = header.UserId
	getCooperationProjectQuery.UserBaseId = header.UserBaseId
	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)
	header := controller.GetRequestHeader(controller.Ctx)
	removeCooperationProjectCommand.CompanyId = header.CompanyId
	removeCooperationProjectCommand.OrgId = header.OrgId
	removeCooperationProjectCommand.UserId = header.UserId
	removeCooperationProjectCommand.UserBaseId = header.UserBaseId
	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{}
	controller.Unmarshal(searchCooperationProjectQuery)
	header := controller.GetRequestHeader(controller.Ctx)
	searchCooperationProjectQuery.CompanyId = header.CompanyId
	searchCooperationProjectQuery.OrgId = header.OrgId
	searchCooperationProjectQuery.UserId = header.UserId
	searchCooperationProjectQuery.UserBaseId = header.UserBaseId
	data, err := cooperationProjectService.SearchCooperationProject(searchCooperationProjectQuery)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) CheckUndertaker() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	checkUndertakerQuery := &query.CheckUndertakerQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	checkUndertakerQuery.CompanyId = header.CompanyId
	checkUndertakerQuery.OrgId = header.OrgId
	checkUndertakerQuery.UserId = header.UserId
	checkUndertakerQuery.UserBaseId = header.UserBaseId
	data, err := cooperationProjectService.CheckUndertaker(checkUndertakerQuery)
	controller.Response(data, err)
}

func (controller *CooperationProjectController) ListCooperationProject() {
	cooperationProjectService := service.NewCooperationProjectService(nil)
	listCooperationProjectQuery := &query.ListCooperationProjectQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	listCooperationProjectQuery.CompanyId = header.CompanyId
	listCooperationProjectQuery.OrgId = header.OrgId
	listCooperationProjectQuery.UserId = header.UserId
	listCooperationProjectQuery.UserBaseId = header.UserBaseId
	pageSize, _ := controller.GetInt64("pageSize")
	listCooperationProjectQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt64("pageNumber")
	listCooperationProjectQuery.PageNumber = pageNumber
	data, err := cooperationProjectService.ListCooperationProject(listCooperationProjectQuery)
	controller.Response(data, err)
}