作者 陈志颖

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

@@ -7,6 +7,8 @@ type CooperationProjectsDto struct { @@ -7,6 +7,8 @@ type CooperationProjectsDto struct {
7 //CooperationMode *CooperationMode `json:"cooperationMode"` 7 //CooperationMode *CooperationMode `json:"cooperationMode"`
8 // 可以去除勾选的共创项目承接对象列表 8 // 可以去除勾选的共创项目承接对象列表
9 UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"` 9 UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"`
  10 + // 承接人
  11 + Applicants []*domain.User `json:"applicants"`
10 } 12 }
11 13
12 type CooperationMode struct { 14 type CooperationMode struct {
@@ -18,7 +20,7 @@ type CooperationMode struct { @@ -18,7 +20,7 @@ type CooperationMode struct {
18 CooperationModeName string `json:"cooperationModeName"` 20 CooperationModeName string `json:"cooperationModeName"`
19 } 21 }
20 22
21 -func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32) error { 23 +func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32, applicants []*domain.User) error {
22 dto.CooperationProject = project 24 dto.CooperationProject = project
23 dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable 25 dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable
24 //dto.CooperationMode = &CooperationMode{ 26 //dto.CooperationMode = &CooperationMode{
@@ -26,5 +28,6 @@ func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, m @@ -26,5 +28,6 @@ func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, m
26 // CooperationModeName: mode.CooperationModeName, 28 // CooperationModeName: mode.CooperationModeName,
27 // CooperationModeNumber: mode.CooperationModeNumber, 29 // CooperationModeNumber: mode.CooperationModeNumber,
28 //} 30 //}
  31 + dto.Applicants = applicants
29 return nil 32 return nil
30 } 33 }
@@ -12,6 +12,7 @@ import ( @@ -12,6 +12,7 @@ import (
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
  15 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
15 "strconv" 16 "strconv"
16 "time" 17 "time"
17 ) 18 )
@@ -244,6 +245,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -244,6 +245,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
244 defer func() { 245 defer func() {
245 _ = transactionContext.RollbackTransaction() 246 _ = transactionContext.RollbackTransaction()
246 }() 247 }()
  248 +
  249 + // 共创项目仓储初始化
247 var cooperationProjectRepository domain.CooperationProjectRepository 250 var cooperationProjectRepository domain.CooperationProjectRepository
248 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ 251 if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
249 "transactionContext": transactionContext, 252 "transactionContext": transactionContext,
@@ -252,6 +255,18 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -252,6 +255,18 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
252 } else { 255 } else {
253 cooperationProjectRepository = value 256 cooperationProjectRepository = value
254 } 257 }
  258 +
  259 + // 共创申请仓储初始化
  260 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  261 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  262 + "transactionContext": transactionContext,
  263 + }); err != nil {
  264 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  265 + } else {
  266 + cooperationApplicationRepository = value
  267 + }
  268 +
  269 + // 获取共创项目
255 cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery)) 270 cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery))
256 if err != nil { 271 if err != nil {
257 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 272 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -276,6 +291,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -276,6 +291,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
276 gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ 291 gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
277 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, 292 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
278 "user": true, 293 "user": true,
  294 + "companyId": getCooperationProjectQuery.CompanyId,
  295 + "orgId": getCooperationProjectQuery.OrgId,
279 }) 296 })
280 if err != nil { 297 if err != nil {
281 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 298 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -288,6 +305,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -288,6 +305,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
288 gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ 305 gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
289 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, 306 "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
290 "partner": true, 307 "partner": true,
  308 + "companyId": getCooperationProjectQuery.CompanyId,
  309 + "orgId": getCooperationProjectQuery.OrgId,
291 }) 310 })
292 if err != nil { 311 if err != nil {
293 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 312 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -301,10 +320,32 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -301,10 +320,32 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
301 undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) 320 undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
302 } 321 }
303 322
304 - // TODO 返回所有员工类型的申请通过人 323 + // 返回所有员工类型的申请通过人
  324 + applicants := make([]*domain.User, 0)
  325 + // 获取当前项目的所有申请
  326 + if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
  327 + "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
  328 + "companyId": cooperationProject.Company.CompanyId,
  329 + "orgId": cooperationProject.Org.OrgId,
  330 + }); err != nil {
  331 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  332 + } else {
  333 + if countApplication > 0 {
  334 + for _, cooperationApplication := range cooperationApplications {
  335 + log.Logger.Info("申请人", map[string]interface{}{
  336 + "applicant": cooperationApplication.CooperationApplicationApplicant,
  337 + })
  338 + userType := cooperationApplication.CooperationApplicationApplicant.UserType & 1
  339 + fmt.Printf("用户类型值: %d\n", userType)
  340 + if userType == 1 && cooperationApplication.CooperationApplicationStatus == 2 { // 申请人中的员工类型,审核中通过的
  341 + applicants = append(applicants, cooperationApplication.CooperationApplicationApplicant)
  342 + }
  343 + }
  344 + }
  345 + }
305 346
306 cooperationProjectDto := &dto.CooperationProjectsDto{} 347 cooperationProjectDto := &dto.CooperationProjectsDto{}
307 - if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil { 348 + if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil {
308 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 349 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
309 } 350 }
310 if err := transactionContext.CommitTransaction(); err != nil { 351 if err := transactionContext.CommitTransaction(); err != nil {
@@ -231,6 +231,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -231,6 +231,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
231 if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { 231 if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
232 query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber)) 232 query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber))
233 } 233 }
  234 + if cooperationProjectNumberExact, ok := queryOptions["cooperationProjectNumberExact"]; ok && cooperationProjectNumberExact != "" {
  235 + query.Where("cooperation_project_number = ? ", cooperationProjectNumberExact)
  236 + }
234 if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" { 237 if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
235 query.Join("LEFT JOIN cooperation_projects AS a"). 238 query.Join("LEFT JOIN cooperation_projects AS a").
236 JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number"). 239 JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").