Browse Source

支持仅官方推荐的过滤

tags/v1.22.4.1^2
ychao_1983 3 years ago
parent
commit
c89713bcf6
2 changed files with 18 additions and 13 deletions
  1. +12
    -8
      models/cloudbrain_image.go
  2. +6
    -5
      routers/repo/cloudbrain.go

+ 12
- 8
models/cloudbrain_image.go View File

@@ -51,14 +51,15 @@ type ImageTopicRelation struct {
}

type SearchImageOptions struct {
Keyword string
UID int64
IncludePublicOnly bool
IncludePrivateOnly bool
IncludeStarByMe bool
IncludeCustom bool
IncludeOwnerOnly bool
Topics string
Keyword string
UID int64
IncludePublicOnly bool
IncludeOfficialOnly bool
IncludePrivateOnly bool
IncludeStarByMe bool
IncludeCustom bool
IncludeOwnerOnly bool
Topics string
ListOptions
SearchOrderBy
}
@@ -319,6 +320,9 @@ func SearchImageCondition(opts *SearchImageOptions) builder.Cond {

cond = cond.And(builder.Eq{"uid": opts.UID})
}
if opts.IncludeOfficialOnly {
cond = cond.And(builder.Eq{"type": RECOMMOND_TYPE})
}

if opts.IncludeStarByMe {



+ 6
- 5
routers/repo/cloudbrain.go View File

@@ -798,11 +798,12 @@ func CloudBrainShowModels(ctx *context.Context) {
func GetPublicImages(ctx *context.Context) {

opts := models.SearchImageOptions{
IncludePrivateOnly: true,
UID: -1,
Keyword: ctx.Query("q"),
Topics: ctx.Query("topic"),
SearchOrderBy: "type desc, num_stars desc",
IncludePrivateOnly: true,
UID: -1,
Keyword: ctx.Query("q"),
Topics: ctx.Query("topic"),
IncludeOfficialOnly: ctx.QueryBool("recommend"),
SearchOrderBy: "type desc, num_stars desc",
}

getImages(ctx, &opts)


Loading…
Cancel
Save