cooperation_mode_controller.go 7.0 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.GetInt64(":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) BatchRemoveCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	batchRemoveCooperationModeCommand := &command.BatchRemoveCooperationModeCommand{}
	_ = controller.Unmarshal(batchRemoveCooperationModeCommand)
	// 解析头部信息
	header := controller.GetRequestHeader(controller.Ctx)
	batchRemoveCooperationModeCommand.CompanyId = header.CompanyId
	batchRemoveCooperationModeCommand.OrgId = header.OrgId
	batchRemoveCooperationModeCommand.UserId = header.UserId
	batchRemoveCooperationModeCommand.UserBaseId = header.UserBaseId
	data, err := cooperationModeService.BatchRemoveCooperationMode(batchRemoveCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) SearchCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	searchCooperationModeQuery := &query.SearchCooperationModeQuery{}
	_ = controller.Unmarshal(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.GetInt64("pageSize")
	listCooperationModeQuery.PageSize = pageSize
	pageNumber, _ := controller.GetInt64("pageNumber")
	listCooperationModeQuery.PageNumber = pageNumber
	data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
	controller.Response(data, err)
}

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

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