|
|
|
@@ -319,12 +319,13 @@ func CurrentRepoDataset(ctx *context.Context) { |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
Keyword: keyword, |
|
|
|
DatasetIDs: datasetIDs, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
Keyword: keyword, |
|
|
|
NeedDatasetIDs: true, |
|
|
|
DatasetIDs: datasetIDs, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
@@ -359,11 +360,12 @@ func MyDatasets(ctx *context.Context) { |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
Keyword: keyword, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
Keyword: keyword, |
|
|
|
NeedDatasetIDs: false, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
@@ -397,11 +399,12 @@ func PublicDataset(ctx *context.Context) { |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
Keyword: keyword, |
|
|
|
NeedIsPrivate: true, |
|
|
|
IsPrivate: false, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedRepoInfo: true, |
|
|
|
Keyword: keyword, |
|
|
|
NeedDatasetIDs: false, |
|
|
|
NeedIsPrivate: true, |
|
|
|
IsPrivate: false, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
@@ -431,45 +434,55 @@ func MyFavoriteDataset(ctx *context.Context) { |
|
|
|
keyword := strings.Trim(ctx.Query("q"), " ") |
|
|
|
|
|
|
|
var datasetIDs []int64 |
|
|
|
|
|
|
|
datasetStars, err := models.GetDatasetStarByUser(ctx.User) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetByRepo failed", err))) |
|
|
|
} |
|
|
|
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, |
|
|
|
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()) |
|
|
|
if !ctx.IsSigned { |
|
|
|
log.Error("user not login!") |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": err.Error(), |
|
|
|
"error_msg": "user not login!", |
|
|
|
"data": "", |
|
|
|
}) |
|
|
|
return |
|
|
|
} else { |
|
|
|
datasetStars, err := models.GetDatasetStarByUser(ctx.User) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err))) |
|
|
|
} |
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "0", |
|
|
|
"data": string(data), |
|
|
|
"count": strconv.FormatInt(count, 10), |
|
|
|
}) |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "0", |
|
|
|
"data": string(data), |
|
|
|
"count": strconv.FormatInt(count, 10), |
|
|
|
}) |
|
|
|
} |