From 9d42e312d7a87d270cca3799106f42ffd835ecbc Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Jul 2022 16:05:59 +0800 Subject: [PATCH] fix-2370 --- routers/repo/cloudbrain.go | 14 ++++++++++++++ routers/routes/routes.go | 1 + 2 files changed, 15 insertions(+) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 7af36641d..628e1f776 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -865,6 +865,20 @@ func CloudBrainCommitImageShow(ctx *context.Context) { ctx.HTML(200, tplCloudBrainImageSubmit) } +func GetImage(ctx *context.Context) { + + var ID = ctx.Params(":id") + id, _ := strconv.ParseInt(ID, 10, 64) + + image, err := models.GetImageByID(id) + if err != nil { + log.Error("GetImageByID failed:%v", err.Error()) + ctx.JSON(http.StatusNotFound, nil) + } + ctx.JSON(http.StatusOK, image) + +} + func CloudBrainImageEdit(ctx *context.Context) { ctx.Data["PageIsImageEdit"] = true ctx.Data["PageFrom"] = ctx.Params(":from") diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 35a26f585..f917aebf1 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1016,6 +1016,7 @@ func RegisterRoutes(m *macaron.Macaron) { }, context.RepoAssignment(), context.RepoMustNotBeArchived(), reqRepoAdmin) m.Group("/image/:id", func() { + m.Get("", repo.GetImage) m.Get("/:from", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageEdit) m.Post("", cloudbrain.AdminOrImageCreaterRight, bindIgnErr(auth.EditImageCloudBrainForm{}), repo.CloudBrainImageEditPost) m.Delete("", cloudbrain.AdminOrImageCreaterRight, repo.CloudBrainImageDelete)