...
|
...
|
@@ -327,21 +327,8 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con |
|
|
}
|
|
|
|
|
|
func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
|
|
|
articleTitle string, contentLike string, fromUserName string, show int) (int, []*domain.ArticleCommentShow, error) {
|
|
|
sqlStr := `select
|
|
|
article.title as article_title ,
|
|
|
article_comment.id ,
|
|
|
article_comment.from_user_id ,
|
|
|
article_comment.from_user,
|
|
|
article_comment."content" ,
|
|
|
article_comment.created_at ,
|
|
|
article_comment.count_reply ,
|
|
|
article_comment.count_user_love ,
|
|
|
article_comment.count_admin_love ,
|
|
|
article_comment."show"
|
|
|
from article_comment
|
|
|
join article on article.id = article_comment.article_id
|
|
|
where 1=1 `
|
|
|
topId int64, articleTitle string, contentLike string, fromUserName string, show int) (int, []*domain.ArticleCommentShow, error) {
|
|
|
|
|
|
if size <= 0 {
|
|
|
size = 20
|
|
|
}
|
...
|
...
|
@@ -349,8 +336,8 @@ where 1=1 ` |
|
|
page = 1
|
|
|
}
|
|
|
|
|
|
where := ""
|
|
|
condition := []interface{}{}
|
|
|
where := " and article_comment.company_id=? "
|
|
|
condition := []interface{}{companyId}
|
|
|
|
|
|
if len(articleTitle) > 0 {
|
|
|
where += ` and article.title like ? `
|
...
|
...
|
@@ -370,7 +357,15 @@ where 1=1 ` |
|
|
condition = append(condition, show)
|
|
|
}
|
|
|
|
|
|
countSql := sqlStr + where
|
|
|
if topId >= 0 {
|
|
|
where += ` and article_comment."top_id"= ? `
|
|
|
condition = append(condition, topId)
|
|
|
}
|
|
|
countSql := `select
|
|
|
count(*)
|
|
|
from article_comment
|
|
|
join article on article.id = article_comment.article_id
|
|
|
where 1=1 ` + where
|
|
|
|
|
|
var cnt int
|
|
|
db := conn.DB()
|
...
|
...
|
@@ -379,7 +374,23 @@ where 1=1 ` |
|
|
return 0, nil, result.Error
|
|
|
}
|
|
|
|
|
|
dataSql := sqlStr + where + ` order by article_comment.id desc limit ? offset ? `
|
|
|
dataSql := `select
|
|
|
article.title as article_title ,
|
|
|
article_comment.id ,
|
|
|
article_comment.pid,
|
|
|
article_comment.top_id,
|
|
|
article_comment.from_user_id ,
|
|
|
article_comment.from_user,
|
|
|
article_comment."content" ,
|
|
|
article_comment.created_at ,
|
|
|
article_comment.count_reply ,
|
|
|
article_comment.count_user_love ,
|
|
|
article_comment.count_admin_love ,
|
|
|
article_comment."show"
|
|
|
from article_comment
|
|
|
join article on article.id = article_comment.article_id
|
|
|
where 1=1` + where + ` order by article_comment.id desc limit ? offset ? `
|
|
|
|
|
|
condition = append(condition, size, (page-1)*size)
|
|
|
|
|
|
ms := []models.ArticleCommentShow{}
|
...
|
...
|
@@ -387,7 +398,6 @@ where 1=1 ` |
|
|
if result.Error != nil {
|
|
|
return 0, nil, result.Error
|
|
|
}
|
|
|
|
|
|
d := []*domain.ArticleCommentShow{}
|
|
|
for _, val := range ms {
|
|
|
d = append(d, &domain.ArticleCommentShow{
|
...
|
...
|
|