作者 陈志颖

fix:共创项目承接人类型判断

@@ -386,6 +386,12 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -386,6 +386,12 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
386 } 386 }
387 } 387 }
388 388
  389 + if utils.IsContain(undertakerUserTypes, int32(1)) && utils.IsContain(undertakerUserTypes, int32(2)) {
  390 + undertakerUserTypes = append(undertakerUserTypes, int32(3))
  391 + }
  392 +
  393 + newUndertakerTypesUncheckedAvailable := utils.Intersect32(undertakerTypesUncheckedAvailable, undertakerUserTypes)
  394 +
389 log.Logger.Info("承接人类型", map[string]interface{}{ 395 log.Logger.Info("承接人类型", map[string]interface{}{
390 "undertakerUserTypes": undertakerUserTypes, 396 "undertakerUserTypes": undertakerUserTypes,
391 }) 397 })
@@ -417,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -417,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
417 } 423 }
418 424
419 cooperationProjectDto := &dto.CooperationProjectsDto{} 425 cooperationProjectDto := &dto.CooperationProjectsDto{}
420 - if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil { 426 + if err := cooperationProjectDto.LoadDto(cooperationProject, nil, newUndertakerTypesUncheckedAvailable, applicants); err != nil {
421 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 427 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
422 } 428 }
423 if err := transactionContext.CommitTransaction(); err != nil { 429 if err := transactionContext.CommitTransaction(); err != nil {
@@ -681,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -681,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
681 } 687 }
682 } 688 }
683 } 689 }
  690 +
684 var undertakerTypes []int32 691 var undertakerTypes []int32
685 var k1, k2 int32 692 var k1, k2 int32
686 if len(applicantTypes) > 0 { 693 if len(applicantTypes) > 0 {
@@ -696,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -696,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
696 if k1 != 0 && k2 != 0 { 703 if k1 != 0 && k2 != 0 {
697 undertakerTypes = append(undertakerTypes, 3) 704 undertakerTypes = append(undertakerTypes, 3)
698 } 705 }
  706 +
699 // 校验可以修改的承接人(申请人)类型 707 // 校验可以修改的承接人(申请人)类型
700 for _, t := range undertakerTypes { 708 for _, t := range undertakerTypes {
701 if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) { 709 if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
@@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 { @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
30 return intersection 30 return intersection
31 } 31 }
32 32
  33 +// Intersect32 返回两个数组的交集
  34 +func Intersect32(nums1 []int32, nums2 []int32) []int32 {
  35 + if len(nums1) > len(nums2) {
  36 + return Intersect32(nums2, nums1)
  37 + }
  38 + m := map[int32]int32{}
  39 + for _, num := range nums1 {
  40 + m[num]++
  41 + }
  42 +
  43 + var intersection []int32
  44 + for _, num := range nums2 {
  45 + if m[num] > 0 {
  46 + intersection = append(intersection, num)
  47 + m[num]--
  48 + }
  49 + }
  50 + return intersection
  51 +}
  52 +
33 // Difference 求差集 slice1-并集 53 // Difference 求差集 slice1-并集
34 func Difference(slice1, slice2 []int64) []int64 { 54 func Difference(slice1, slice2 []int64) []int64 {
35 m := make(map[int64]int) 55 m := make(map[int64]int)