cooperation_mode_controller.go 4.8 KB
package controllers

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

type CooperationModeController struct {
	BaseController
}

func (controller *CooperationModeController) CreateCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	createCooperationModeCommand := &command.CreateCooperationModeCommand{}
	_ = controller.Unmarshal(createCooperationModeCommand)
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	createCooperationModeCommand.CompanyId = header.CompanyId
	createCooperationModeCommand.OrgId = header.OrgId
	createCooperationModeCommand.UserId = header.UserId
	createCooperationModeCommand.UserBaseId = header.UserBaseId
	data, err := cooperationModeService.CreateCooperationMode(createCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) UpdateCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	updateCooperationModeCommand := &command.UpdateCooperationModeCommand{}
	_ = controller.Unmarshal(updateCooperationModeCommand)
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	updateCooperationModeCommand.CompanyId = header.CompanyId
	updateCooperationModeCommand.OrgId = header.OrgId
	updateCooperationModeCommand.UserId = header.UserId
	updateCooperationModeCommand.UserBaseId = header.UserBaseId
	cooperationModeId := controller.GetString(":cooperationModeId")
	updateCooperationModeCommand.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.UpdateCooperationMode(updateCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) GetCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	getCooperationModeQuery := &query.GetCooperationModeQuery{}
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	getCooperationModeQuery.CompanyId = header.CompanyId
	getCooperationModeQuery.OrgId = header.OrgId
	getCooperationModeQuery.UserId = header.UserId
	getCooperationModeQuery.UserBaseId = header.UserBaseId
	cooperationModeId, _ := controller.GetInt64(":cooperationModeId")
	getCooperationModeQuery.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.GetCooperationMode(getCooperationModeQuery)
	controller.Response(data, err)
}

func (controller *CooperationModeController) RemoveCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	removeCooperationModeCommand := &command.RemoveCooperationModeCommand{}
	_ = controller.Unmarshal(removeCooperationModeCommand)
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	removeCooperationModeCommand.CompanyId = header.CompanyId
	removeCooperationModeCommand.OrgId = header.OrgId
	removeCooperationModeCommand.UserId = header.UserId
	removeCooperationModeCommand.UserBaseId = header.UserBaseId
	cooperationModeId, _ := controller.GetInt64(":cooperationModeId")
	removeCooperationModeCommand.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.RemoveCooperationMode(removeCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) SearchCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	searchCooperationModeQuery := &query.SearchCooperationModeQuery{}
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	searchCooperationModeQuery.CompanyId = header.CompanyId
	searchCooperationModeQuery.OrgId = header.OrgId
	searchCooperationModeQuery.UserId = header.UserId
	searchCooperationModeQuery.UserBaseId = header.UserBaseId
	data, err := cooperationModeService.SearchCooperationMode(searchCooperationModeQuery)
	controller.Response(data, err)
}

func (controller *CooperationModeController) ListCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	listCooperationModeQuery := &query.ListCooperationModeQuery{}
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	listCooperationModeQuery.CompanyId = header.CompanyId
	listCooperationModeQuery.OrgId = header.OrgId
	listCooperationModeQuery.UserId = header.UserId
	listCooperationModeQuery.UserBaseId = header.UserBaseId
	pageSize, _ := controller.GetInt32("pageSize")
	listCooperationModeQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt32("pageNumber")
	listCooperationModeQuery.PageNumber = pageNumber
	data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
	controller.Response(data, err)
}