From 854ee2683b567e7fb900512d7bce0619b9e6f4e7 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Wed, 6 Apr 2022 14:40:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/cloudbrain.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 4f484c3f2..5b46c4d67 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -813,10 +813,10 @@ func CloudBrainShowModels(ctx *context.Context) { } func GetPublicImages(ctx *context.Context) { - + uid := getUID(ctx) opts := models.SearchImageOptions{ IncludePublicOnly: true, - UID: -1, + UID: uid, Keyword: ctx.Query("q"), Topics: ctx.Query("topic"), IncludeOfficialOnly: ctx.QueryBool("recommend"), @@ -828,10 +828,7 @@ func GetPublicImages(ctx *context.Context) { } func GetCustomImages(ctx *context.Context) { - var uid int64 = -1 - if ctx.IsSigned { - uid = ctx.User.ID - } + uid := getUID(ctx) opts := models.SearchImageOptions{ UID: uid, IncludeOwnerOnly: true, @@ -844,10 +841,7 @@ func GetCustomImages(ctx *context.Context) { } func GetStarImages(ctx *context.Context) { - var uid int64 = -1 - if ctx.IsSigned { - uid = ctx.User.ID - } + uid := getUID(ctx) opts := models.SearchImageOptions{ UID: uid, IncludeStarByMe: true, @@ -859,10 +853,18 @@ func GetStarImages(ctx *context.Context) { } -func GetAllImages(ctx *context.Context) { +func getUID(ctx *context.Context) int64 { + var uid int64 = -1 + if ctx.IsSigned { + uid = ctx.User.ID + } + return uid +} +func GetAllImages(ctx *context.Context) { + uid := getUID(ctx) opts := models.SearchImageOptions{ - UID: -1, + UID: uid, Keyword: ctx.Query("q"), Topics: ctx.Query("topic"), SearchOrderBy: "id desc",