Browse Source

更新代码

tags/v1.22.4.1^2
ychao_1983 3 years ago
parent
commit
67c69c1ae2
2 changed files with 9 additions and 1 deletions
  1. +5
    -1
      models/cloudbrain_image.go
  2. +4
    -0
      routers/repo/cloudbrain.go

+ 5
- 1
models/cloudbrain_image.go View File

@@ -30,7 +30,7 @@ type Image struct {
IsStar bool `xorm:"-" json:"isStar"` IsStar bool `xorm:"-" json:"isStar"`
UserName string `xorm:"-" json:"userName"` UserName string `xorm:"-" json:"userName"`
RelAvatarLink string `xorm:"-" json:"relAvatarLink"` RelAvatarLink string `xorm:"-" json:"relAvatarLink"`
Status int `xorm:"NOT NULL DEFAULT 0" json:"status"` //0代表正在提交,1提交完成,2提交失败
Status int `xorm:"INDEX NOT NULL DEFAULT 0" json:"status"` //0代表正在提交,1提交完成,2提交失败
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created" json:"createdUnix"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX created" json:"createdUnix"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated" json:"updatedUnix"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated" json:"updatedUnix"`
} }
@@ -60,6 +60,7 @@ type ImageTopicRelation struct {
type SearchImageOptions struct { type SearchImageOptions struct {
Keyword string Keyword string
UID int64 UID int64
Status int
IncludePublicOnly bool IncludePublicOnly bool
IncludeOfficialOnly bool IncludeOfficialOnly bool
IncludePrivateOnly bool IncludePrivateOnly bool
@@ -397,6 +398,9 @@ func SearchImageCondition(opts *SearchImageOptions) builder.Cond {
if opts.IncludeOfficialOnly { if opts.IncludeOfficialOnly {
cond = cond.And(builder.Eq{"type": RECOMMOND_TYPE}) cond = cond.And(builder.Eq{"type": RECOMMOND_TYPE})
} }
if opts.Status >= 0 {
cond = cond.And(builder.Eq{"status": opts.Status})
}


if opts.IncludeStarByMe { if opts.IncludeStarByMe {




+ 4
- 0
routers/repo/cloudbrain.go View File

@@ -978,6 +978,7 @@ func GetPublicImages(ctx *context.Context) {
Topics: ctx.Query("topic"), Topics: ctx.Query("topic"),
IncludeOfficialOnly: ctx.QueryBool("recommend"), IncludeOfficialOnly: ctx.QueryBool("recommend"),
SearchOrderBy: "type desc, num_stars desc,id desc", SearchOrderBy: "type desc, num_stars desc,id desc",
Status: models.IMAGE_STATUS_SUCCESS,
} }


getImages(ctx, &opts) getImages(ctx, &opts)
@@ -991,6 +992,7 @@ func GetCustomImages(ctx *context.Context) {
IncludeOwnerOnly: true, IncludeOwnerOnly: true,
Keyword: ctx.Query("q"), Keyword: ctx.Query("q"),
Topics: ctx.Query("topic"), Topics: ctx.Query("topic"),
Status: -1,
SearchOrderBy: "id desc", SearchOrderBy: "id desc",
} }
getImages(ctx, &opts) getImages(ctx, &opts)
@@ -1004,6 +1006,7 @@ func GetStarImages(ctx *context.Context) {
IncludeStarByMe: true, IncludeStarByMe: true,
Keyword: ctx.Query("q"), Keyword: ctx.Query("q"),
Topics: ctx.Query("topic"), Topics: ctx.Query("topic"),
Status: models.IMAGE_STATUS_SUCCESS,
SearchOrderBy: "id desc", SearchOrderBy: "id desc",
} }
getImages(ctx, &opts) getImages(ctx, &opts)
@@ -1025,6 +1028,7 @@ func GetAllImages(ctx *context.Context) {
Keyword: ctx.Query("q"), Keyword: ctx.Query("q"),
Topics: ctx.Query("topic"), Topics: ctx.Query("topic"),
SearchOrderBy: "id desc", SearchOrderBy: "id desc",
Status: -1,
} }


if ctx.Query("private") != "" { if ctx.Query("private") != "" {


Loading…
Cancel
Save