cooperation_projects.go 3.5 KB
package service

import (
	"github.com/linmadan/egglib-go/core/application"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)

// CooperationProjectService 共创项目服务
type CooperationProjectService struct {
}

// CreateCooperationProject  TODO:创建共创项目
func (srv CooperationProjectService) CreateCooperationProject(userMenusCommand *command.CreateCooperationProjectCommand) (interface{}, error) {
	creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
		userMenusCommand.Operator)
	resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
		UserId: int(userMenusCommand.Operator.UserId),
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return map[string]interface{}{
		"accessMenus": resultMenu.Menus,
	}, nil
}

// GetCooperationProject  TODO:返回共创项目明细
func (srv CooperationProjectService) GetCooperationProject(userMenusCommand *command.GetCooperationProjectQuery) (interface{}, error) {
	creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
		userMenusCommand.Operator)
	resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
		UserId: int(userMenusCommand.Operator.UserId),
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return map[string]interface{}{
		"accessMenus": resultMenu.Menus,
	}, nil
}

// UpdateCooperationProject  TODO:企业更新共创项目
func (srv CooperationProjectService) UpdateCooperationProject(userMenusCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
	creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
		userMenusCommand.Operator)
	resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
		UserId: int(userMenusCommand.Operator.UserId),
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return map[string]interface{}{
		"accessMenus": resultMenu.Menus,
	}, nil
}

// EndCooperationProject  TODO:企业结束共创项目
func (srv CooperationProjectService) EndCooperationProject(userMenusCommand *command.EndCooperationProjectCommand) (interface{}, error) {
	creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
		userMenusCommand.Operator)
	resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
		UserId: int(userMenusCommand.Operator.UserId),
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return map[string]interface{}{
		"accessMenus": resultMenu.Menus,
	}, nil
}

// SearchCooperationProject  TODO:获取共创项目列表
func (srv CooperationProjectService) SearchCooperationProject(userMenusCommand *command.ListCooperationProjectQuery) (interface{}, error) {
	creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
		userMenusCommand.Operator)
	resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
		UserId: int(userMenusCommand.Operator.UserId),
	})
	if err != nil {
		return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
	}
	return map[string]interface{}{
		"accessMenus": resultMenu.Menus,
	}, nil
}