作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !12
... ... @@ -122,9 +122,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 4) { // 非公开类型校验
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验
for _, userType := range cooperationProject.CooperationProjectUndertakerTypes {
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
}
... ...
... ... @@ -160,12 +160,10 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
// 校验承接人是否属于承接对象,1员工,2共创用户,4公开
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) {
var userType int32
if undertakerDomain.UserType > 1024 {
userType = undertakerDomain.UserType - 1024
}
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
for _, userType := range createCooperationContractCommand.CooperationContractUndertakerTypes {
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
}
... ... @@ -1027,12 +1025,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验
var userType int32
if undertakerDomain.UserType > 1024 {
userType = undertakerDomain.UserType - 1024
}
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
for _, userType := range cooperationContract.CooperationContractUndertakerTypes {
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
}
... ...
... ... @@ -7,6 +7,8 @@ type CooperationProjectsDto struct {
//CooperationMode *CooperationMode `json:"cooperationMode"`
// 可以去除勾选的共创项目承接对象列表
UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"`
// 承接人
Applicants []*domain.User `json:"applicants"`
}
type CooperationMode struct {
... ... @@ -18,7 +20,7 @@ type CooperationMode struct {
CooperationModeName string `json:"cooperationModeName"`
}
func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32) error {
func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32, applicants []*domain.User) error {
dto.CooperationProject = project
dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable
//dto.CooperationMode = &CooperationMode{
... ... @@ -26,5 +28,6 @@ func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, m
// CooperationModeName: mode.CooperationModeName,
// CooperationModeNumber: mode.CooperationModeNumber,
//}
dto.Applicants = applicants
return nil
}
... ...
... ... @@ -12,6 +12,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"strconv"
"time"
)
... ... @@ -169,6 +170,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
if err2 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
}
// 校验共创项目编号是否唯一
numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
"companyId": createCooperationProjectCommand.CompanyId,
... ... @@ -244,6 +246,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -252,6 +256,18 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
} else {
cooperationProjectRepository = value
}
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -276,6 +292,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"user": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -288,6 +306,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"partner": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -301,10 +321,32 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
}
// TODO 返回所有员工类型的申请通过人
// 返回所有员工类型的申请通过人
applicants := make([]*domain.User, 0)
// 获取当前项目的所有申请
if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
"cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countApplication > 0 {
for _, cooperationApplication := range cooperationApplications {
log.Logger.Info("申请人", map[string]interface{}{
"applicant": cooperationApplication.CooperationApplicationApplicant,
})
userType := cooperationApplication.CooperationApplicationApplicant.UserType & 1
fmt.Printf("用户类型值: %d\n", userType)
if userType == 1 && cooperationApplication.CooperationApplicationStatus == 2 { // 申请人中的员工类型,审核中通过的
applicants = append(applicants, cooperationApplication.CooperationApplicationApplicant)
}
}
}
}
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -118,6 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId)
}
query.Where("cooperation_project.status = ?", 1)
ok, err := query.Exists()
return !ok, err
}
... ...
... ... @@ -231,6 +231,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
}
if cooperationProjectNumberExact, ok := queryOptions["cooperationProjectNumberExact"]; ok && cooperationProjectNumberExact != "" {
query.Where("cooperation_project_number = ? ", cooperationProjectNumberExact)
}
if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
query.Join("LEFT JOIN cooperation_projects AS a").
JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
... ...