cooperation_mode_controller.go 6.9 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)
}

// OperateCooperationMode 启用或禁用共创模式
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)
}

// BatchOperateCooperationMode 批量启用或禁用共创模式
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)
}