update tag show

This commit is contained in:
aichy126 2022-11-25 11:40:54 +08:00
parent 8c1c1a664c
commit 436829c2d1
2 changed files with 10 additions and 7 deletions

View File

@ -65,13 +65,16 @@ func (tr *tagCommonRepo) GetTagListByName(ctx context.Context, name string, limi
cond.Recommend = true
}
session.Where(builder.Eq{"status": entity.TagStatusAvailable})
// if limit == 0 {
// session.Asc("slug_name")
// }
session.Limit(limit).Asc("slug_name")
if !hasReserved {
cond.Reserved = false
session.UseBool("recommend", "reserved")
} else {
session.UseBool("recommend")
}
// if !hasReserved {
// cond.Reserved = false
// session.UseBool("recommend", "reserved")
// } else {
session.UseBool("recommend")
// }
err = session.OrderBy("recommend desc,reserved desc,id desc").Find(&tagList, cond)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()

View File

@ -64,7 +64,7 @@ func NewTagCommonService(tagCommonRepo TagCommonRepo, tagRelRepo TagRelRepo,
// SearchTagLike get tag list all
func (ts *TagCommonService) SearchTagLike(ctx context.Context, req *schema.SearchTagLikeReq) (resp []schema.SearchTagLikeResp, err error) {
tags, err := ts.tagCommonRepo.GetTagListByName(ctx, req.Tag, 5, req.IsAdmin)
tags, err := ts.tagCommonRepo.GetTagListByName(ctx, req.Tag, 0, req.IsAdmin)
if err != nil {
return
}