浏览代码

#2701

distinct by sourceSpecId
tags/v1.22.9.1^2^2
chenyifan01 3 年前
父节点
当前提交
a37d60153f
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. +7
    -1
      services/cloudbrain/resource/resource_specification.go

+ 7
- 1
services/cloudbrain/resource/resource_specification.go 查看文件

@@ -203,15 +203,20 @@ func FindAvailableSpecs(userId int64, opts models.FindSpecsOptions) ([]*models.S

//distinct by sourceSpecId
specs = distinctSpecs(specs)
return specs, nil
return specs, err
}

func filterExclusiveSpecs(r []*models.Specification, userId int64) []*models.Specification {
specs := make([]*models.Specification, 0, len(r))
specMap := make(map[int64]string, 0)
for i := 0; i < len(r); i++ {
spec := r[i]
if _, has := specMap[spec.ID]; has {
continue
}
if !spec.IsExclusive {
specs = append(specs, spec)
specMap[spec.ID] = ""
continue
}
orgs := strings.Split(spec.ExclusiveOrg, ";")
@@ -219,6 +224,7 @@ func filterExclusiveSpecs(r []*models.Specification, userId int64) []*models.Spe
isMember, _ := models.IsOrganizationMemberByOrgName(org, userId)
if isMember {
specs = append(specs, spec)
specMap[spec.ID] = ""
}
}
}


正在加载...
取消
保存