作者 陈志颖

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

... ... @@ -386,6 +386,12 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
}
}
if utils.IsContain(undertakerUserTypes, int32(1)) && utils.IsContain(undertakerUserTypes, int32(2)) {
undertakerUserTypes = append(undertakerUserTypes, int32(3))
}
newUndertakerTypesUncheckedAvailable := utils.Intersect32(undertakerTypesUncheckedAvailable, undertakerUserTypes)
log.Logger.Info("承接人类型", map[string]interface{}{
"undertakerUserTypes": undertakerUserTypes,
})
... ... @@ -417,7 +423,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
}
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil {
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, newUndertakerTypesUncheckedAvailable, applicants); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -681,6 +687,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
}
}
}
var undertakerTypes []int32
var k1, k2 int32
if len(applicantTypes) > 0 {
... ... @@ -696,6 +703,7 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
if k1 != 0 && k2 != 0 {
undertakerTypes = append(undertakerTypes, 3)
}
// 校验可以修改的承接人(申请人)类型
for _, t := range undertakerTypes {
if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
... ...
... ... @@ -30,6 +30,26 @@ func Intersect(nums1 []int64, nums2 []int64) []int64 {
return intersection
}
// Intersect32 返回两个数组的交集
func Intersect32(nums1 []int32, nums2 []int32) []int32 {
if len(nums1) > len(nums2) {
return Intersect32(nums2, nums1)
}
m := map[int32]int32{}
for _, num := range nums1 {
m[num]++
}
var intersection []int32
for _, num := range nums2 {
if m[num] > 0 {
intersection = append(intersection, num)
m[num]--
}
}
return intersection
}
// Difference 求差集 slice1-并集
func Difference(slice1, slice2 []int64) []int64 {
m := make(map[int64]int)
... ...