Browse Source

add attachment

tags/v1.22.1.3
lewis 3 years ago
parent
commit
15fd02425a
1 changed files with 29 additions and 2 deletions
  1. +29
    -2
      routers/repo/cloudbrain.go

+ 29
- 2
routers/repo/cloudbrain.go View File

@@ -1030,8 +1030,35 @@ func CloudBrainBenchmarkNew(ctx *context.Context) {
ctx.HTML(200, tplCloudBrainBenchmarkNew)
}

func getBenchmarkAttachment() error {
return nil
func getBenchmarkAttachment(benchmarkTypeID, benchmarkChildTypeID int) (string, error) {
uuid := ""
if benchmarkTypes == nil {
if err := json.Unmarshal([]byte(setting.BenchmarkTypes), &benchmarkTypes); err != nil {
log.Error("json.Unmarshal BenchmarkTypes(%s) failed:%v", setting.BenchmarkTypes, err)
return uuid, err
}
}

var isExist bool
for id, benchmarkType := range benchmarkTypes.BenchmarkType {
if id == benchmarkTypeID {
for childID, childType := range benchmarkType.Second {
if childID == benchmarkChildTypeID {
uuid = childType.Attachment
isExist = true
break
}
}
break
}
}

if !isExist {
log.Error("no such benchmark_type_id&benchmark_child_type_id")
return uuid, errors.New("no such benchmark_type_id&benchmark_child_type_id")
}

return uuid, nil
}

func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {


Loading…
Cancel
Save