fix(comment): fix comment query param when select

pull/35/head
doper 2 years ago committed by 1379Monitor
parent e4fe69ac91
commit 2a82f7a328

@ -6,9 +6,9 @@ type CommentQuery struct {
Page Page
*Sort *Sort
ContentID *int32 ContentID *int32
Keyword *string `json:"keyword"` Keyword *string `json:"keyword" form:"keyword"`
CommentStatus *consts.CommentStatus `json:"status"` CommentStatus *consts.CommentStatus `json:"status" form:"status"`
ParentID *int32 `json:"parentID"` ParentID *int32 `json:"parentID" form:"parentID"`
} }
type Comment struct { type Comment struct {

@ -43,8 +43,8 @@ func (b baseCommentServiceImpl) Page(ctx context.Context, commentQuery param.Com
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
} }
if commentQuery.Keyword != nil { if commentQuery.Keyword != nil && *commentQuery.Keyword != "" {
commentDO.Where(commentDAL.Content.Like(*commentQuery.Keyword)) commentDO.Where(commentDAL.Content.Like("%" + *commentQuery.Keyword + "%"))
} }
if commentQuery.CommentStatus != nil { if commentQuery.CommentStatus != nil {
commentDO.Where(commentDAL.Status.Eq(*commentQuery.CommentStatus)) commentDO.Where(commentDAL.Status.Eq(*commentQuery.CommentStatus))

Loading…
Cancel
Save