cooperation_application_controller.go 9.3 KB
package controllers

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/service"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
)

type CooperationApplicationController struct {
	BaseController
}

func (controller *CooperationApplicationController) ApplyForCooperation() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	applyForCooperationCommand := &command.ApplyForCooperationCommand{}
	_ = controller.Unmarshal(applyForCooperationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	applyForCooperationCommand.CompanyId = header.CompanyId
	applyForCooperationCommand.OrgId = header.OrgId
	applyForCooperationCommand.UserId = header.UserId
	applyForCooperationCommand.UserBaseId = header.UserBaseId
	cooperationProjectId, _ := controller.GetInt64(":cooperationProjectId")
	applyForCooperationCommand.CooperationProjectId = cooperationProjectId
	data, err := cooperationApplicationService.ApplyForCooperation(applyForCooperationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) ApprovalCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	approvalCooperationApplicationCommand := &command.ApprovalCooperationApplicationCommand{}
	_ = controller.Unmarshal(approvalCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	approvalCooperationApplicationCommand.CompanyId = header.CompanyId
	approvalCooperationApplicationCommand.OrgId = header.OrgId
	approvalCooperationApplicationCommand.UserId = header.UserId
	approvalCooperationApplicationCommand.UserBaseId = header.UserBaseId
	data, err := cooperationApplicationService.ApprovalCooperationApplication(approvalCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) CancelCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	cancelCooperationApplicationCommand := &command.CancelCooperationApplicationCommand{}
	_ = controller.Unmarshal(cancelCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	cancelCooperationApplicationCommand.CompanyId = header.CompanyId
	cancelCooperationApplicationCommand.OrgId = header.OrgId
	cancelCooperationApplicationCommand.UserId = header.UserId
	cancelCooperationApplicationCommand.UserBaseId = header.UserBaseId
	data, err := cooperationApplicationService.CancelCooperationApplication(cancelCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationContractController) BatchApprovalCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	batchApprovalCooperationApplicationCommand := &command.BatchApprovalCooperationApplicationCommand{}
	_ = controller.Unmarshal(batchApprovalCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	batchApprovalCooperationApplicationCommand.CompanyId = header.CompanyId
	batchApprovalCooperationApplicationCommand.OrgId = header.OrgId
	batchApprovalCooperationApplicationCommand.UserId = header.UserId
	batchApprovalCooperationApplicationCommand.UserBaseId = header.UserBaseId
	data, err := cooperationApplicationService.BatchApprovalCooperationApplication(batchApprovalCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) OneClickApprovalCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	oneClickApprovalCooperationApplicationCommand := &command.OneClickApprovalCooperationApplicationCommand{}
	_ = controller.Unmarshal(oneClickApprovalCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	oneClickApprovalCooperationApplicationCommand.CompanyId = header.CompanyId
	oneClickApprovalCooperationApplicationCommand.OrgId = header.OrgId
	oneClickApprovalCooperationApplicationCommand.UserId = header.UserId
	oneClickApprovalCooperationApplicationCommand.UserBaseId = header.UserBaseId
	data, err := cooperationApplicationService.OneClickApprovalCooperationApplication(oneClickApprovalCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) CreateCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	createCooperationApplicationCommand := &command.CreateCooperationApplicationCommand{}
	_ = controller.Unmarshal(createCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	createCooperationApplicationCommand.CompanyId = header.CompanyId
	createCooperationApplicationCommand.OrgId = header.OrgId
	createCooperationApplicationCommand.UserId = header.UserId
	createCooperationApplicationCommand.UserBaseId = header.UserBaseId
	data, err := cooperationApplicationService.CreateCooperationApplication(createCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) UpdateCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	updateCooperationApplicationCommand := &command.UpdateCooperationApplicationCommand{}
	_ = controller.Unmarshal(updateCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	updateCooperationApplicationCommand.CompanyId = header.CompanyId
	updateCooperationApplicationCommand.OrgId = header.OrgId
	updateCooperationApplicationCommand.UserId = header.UserId
	updateCooperationApplicationCommand.UserBaseId = header.UserBaseId
	cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
	updateCooperationApplicationCommand.CooperationApplicationId = cooperationApplicationId
	data, err := cooperationApplicationService.UpdateCooperationApplication(updateCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) GetCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	getCooperationApplicationQuery := &query.GetCooperationApplicationQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	getCooperationApplicationQuery.CompanyId = header.CompanyId
	getCooperationApplicationQuery.OrgId = header.OrgId
	getCooperationApplicationQuery.UserId = header.UserId
	getCooperationApplicationQuery.UserBaseId = header.UserBaseId
	cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
	getCooperationApplicationQuery.CooperationApplicationId = cooperationApplicationId
	data, err := cooperationApplicationService.GetCooperationApplication(getCooperationApplicationQuery)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) RemoveCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	removeCooperationApplicationCommand := &command.RemoveCooperationApplicationCommand{}
	_ = controller.Unmarshal(removeCooperationApplicationCommand)
	header := controller.GetRequestHeader(controller.Ctx)
	removeCooperationApplicationCommand.CompanyId = header.CompanyId
	removeCooperationApplicationCommand.OrgId = header.OrgId
	removeCooperationApplicationCommand.UserId = header.UserId
	removeCooperationApplicationCommand.UserBaseId = header.UserBaseId
	cooperationApplicationId, _ := controller.GetInt64(":cooperationApplicationId")
	removeCooperationApplicationCommand.CooperationApplicationId = cooperationApplicationId
	data, err := cooperationApplicationService.RemoveCooperationApplication(removeCooperationApplicationCommand)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) SearchCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	searchCooperationApplicationQuery := &query.SearchCooperationApplicationQuery{}
	err := controller.Unmarshal(searchCooperationApplicationQuery)
	if err != nil {
		log.Logger.Error("json 解析失败" + err.Error())
	}
	data, err := cooperationApplicationService.SearchCooperationApplication(searchCooperationApplicationQuery)
	controller.Response(data, err)
}

func (controller *CooperationApplicationController) ListCooperationApplication() {
	cooperationApplicationService := service.NewCooperationApplicationService(nil)
	listCooperationApplicationQuery := &query.ListCooperationApplicationQuery{}
	header := controller.GetRequestHeader(controller.Ctx)
	listCooperationApplicationQuery.CompanyId = header.CompanyId
	listCooperationApplicationQuery.OrgId = header.OrgId
	listCooperationApplicationQuery.UserId = header.UserId
	listCooperationApplicationQuery.UserBaseId = header.UserBaseId
	pageSize, _ := controller.GetInt64("pageSize")
	listCooperationApplicationQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt64("pageNumber")
	listCooperationApplicationQuery.PageNumber = pageNumber
	data, err := cooperationApplicationService.ListCooperationApplication(listCooperationApplicationQuery)
	controller.Response(data, err)
}