Browse Source

删除无用代码

tags/v1.22.3.2^2
liuzx 3 years ago
parent
commit
15468ee231
1 changed files with 39 additions and 49 deletions
  1. +39
    -49
      routers/repo/dataset.go

+ 39
- 49
routers/repo/dataset.go View File

@@ -433,63 +433,53 @@ func MyFavoriteDataset(ctx *context.Context) {
cloudbrainType := ctx.QueryInt("type") cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("q"), " ") keyword := strings.Trim(ctx.Query("q"), " ")


var datasetIDs []int64
if !ctx.IsSigned {
log.Error("user not login!")
datasetStars, err := models.GetDatasetStarByUser(ctx.User)
if err != nil {
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err)))
log.Error("GetDatasetStarByUser failed:", err.Error())
ctx.JSON(200, map[string]string{ ctx.JSON(200, map[string]string{
"result_code": "-1", "result_code": "-1",
"error_msg": "user not login!",
"error_msg": err.Error(),
"data": "", "data": "",
}) })
return return
} else {
datasetStars, err := models.GetDatasetStarByUser(ctx.User)
if err != nil {
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err)))
log.Error("GetDatasetStarByUser failed:", err.Error())
ctx.JSON(200, map[string]string{
"result_code": "-1",
"error_msg": err.Error(),
"data": "",
})
return
}
for i, _ := range datasetStars {
datasetIDs = append(datasetIDs, datasetStars[i].DatasetID)
}
}
for i, _ := range datasetStars {
datasetIDs = append(datasetIDs, datasetStars[i].DatasetID)
}


datasets, count, err := models.Attachments(&models.AttachmentsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
NeedDatasetIDs: true,
DatasetIDs: datasetIDs,
NeedIsPrivate: true,
IsPrivate: false,
Type: cloudbrainType,
NeedRepoInfo: true,
})
if err != nil {
ctx.ServerError("datasets", err)
return
}
datasets, count, err := models.Attachments(&models.AttachmentsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
NeedDatasetIDs: true,
DatasetIDs: datasetIDs,
NeedIsPrivate: true,
IsPrivate: false,
Type: cloudbrainType,
NeedRepoInfo: true,
})
if err != nil {
ctx.ServerError("datasets", err)
return
}


data, err := json.Marshal(datasets)
if err != nil {
log.Error("json.Marshal failed:", err.Error())
ctx.JSON(200, map[string]string{
"result_code": "-1",
"error_msg": err.Error(),
"data": "",
})
return
}
data, err := json.Marshal(datasets)
if err != nil {
log.Error("json.Marshal failed:", err.Error())
ctx.JSON(200, map[string]string{ ctx.JSON(200, map[string]string{
"result_code": "0",
"data": string(data),
"count": strconv.FormatInt(count, 10),
"result_code": "-1",
"error_msg": err.Error(),
"data": "",
}) })
return
} }
ctx.JSON(200, map[string]string{
"result_code": "0",
"data": string(data),
"count": strconv.FormatInt(count, 10),
})

} }

Loading…
Cancel
Save