作者 陈志颖

feat:共创项目详情增加申请人

... ... @@ -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"
)
... ... @@ -244,6 +245,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 +255,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 +291,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 +305,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 +320,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 {
... ...
... ... @@ -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").
... ...