|
|
@@ -29,7 +29,7 @@ const ( |
|
|
|
DecompressFailed = "1" |
|
|
|
) |
|
|
|
|
|
|
|
type PublicDataset struct { |
|
|
|
type CloudBrainDataset struct { |
|
|
|
UUID string `json:"id"` |
|
|
|
Name string `json:"name"` |
|
|
|
Path string `json:"place"` |
|
|
@@ -635,25 +635,44 @@ func QueryAllPublicDataset(ctx *context.Context){ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var publicDatasets []PublicDataset |
|
|
|
queryDatasets(ctx, "admin", attachs) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryPrivateDataset(ctx *context.Context){ |
|
|
|
username := ctx.Params(":username") |
|
|
|
attachs, err := models.GetPrivateAttachments(username) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": err.Error(), |
|
|
|
"data": "", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
queryDatasets(ctx, username, attachs) |
|
|
|
} |
|
|
|
|
|
|
|
func queryDatasets(ctx *context.Context, username string, attachs []*models.Attachment) { |
|
|
|
var datasets []CloudBrainDataset |
|
|
|
for _, attch := range attachs { |
|
|
|
has,err := storage.Attachments.HasObject(models.AttachmentRelativePath(attch.UUID)) |
|
|
|
if err != nil || !has { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
publicDatasets = append(publicDatasets, PublicDataset{attch.UUID, |
|
|
|
datasets = append(datasets, CloudBrainDataset{attch.UUID, |
|
|
|
attch.Name, |
|
|
|
setting.Attachment.Minio.RealPath + |
|
|
|
setting.Attachment.Minio.Bucket + "/" + |
|
|
|
setting.Attachment.Minio.BasePath + |
|
|
|
models.AttachmentRelativePath(attch.UUID) + |
|
|
|
attch.UUID, |
|
|
|
"admin", |
|
|
|
attch.CreatedUnix.Format("2006-01-02 03:04:05")}) |
|
|
|
setting.Attachment.Minio.Bucket + "/" + |
|
|
|
setting.Attachment.Minio.BasePath + |
|
|
|
models.AttachmentRelativePath(attch.UUID) + |
|
|
|
attch.UUID, |
|
|
|
username, |
|
|
|
attch.CreatedUnix.Format("2006-01-02 03:04:05")}) |
|
|
|
} |
|
|
|
|
|
|
|
data,err := json.Marshal(publicDatasets) |
|
|
|
data,err := json.Marshal(datasets) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Marshal failed:", err.Error()) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
@@ -669,4 +688,5 @@ func QueryAllPublicDataset(ctx *context.Context){ |
|
|
|
"error_msg": "", |
|
|
|
"data": string(data), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |