...
|
...
|
@@ -278,27 +278,11 @@ func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepositor |
|
|
return &ArticleRepository{CachedRepository: cache}
|
|
|
}
|
|
|
|
|
|
// -- 首页统计数据
|
|
|
// with
|
|
|
// -- 按查看权限查询文章
|
|
|
// -- 获取有标签的文章
|
|
|
// -- 过滤出可展示的文章id
|
|
|
// t_article_and_tag_2 as (
|
|
|
// select article_and_tag.article_id , article_and_tag.tag_id
|
|
|
// from article_and_tag
|
|
|
// join article on article_and_tag.article_id = article.id
|
|
|
// where article.deleted_at=0
|
|
|
// and article.company_id =1598224576532189184
|
|
|
// and article."show" =0
|
|
|
// and (article.target_user =0 or article.who_read @>'[1]')
|
|
|
// ),
|
|
|
// -- 查询人员已查看的文章
|
|
|
// t_user_read as(
|
|
|
// select user_read_article.article_id from user_read_article where user_read_article.user_id =1
|
|
|
// )
|
|
|
// -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量
|
|
|
// select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id
|
|
|
// from t_article_and_tag_2
|
|
|
// left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id
|
|
|
// group by t_article_and_tag_2.tag_id
|
|
|
// ; |
|
|
// select *
|
|
|
// from article
|
|
|
// join article_and_tag on article.id = article_and_tag.article_id
|
|
|
// where article."show" =1
|
|
|
// and article_and_tag.tag_id =any(select article_tag.id from article_tag where category ='分组三' )
|
|
|
// and article_and_tag.tag_id =0
|
|
|
// and article.created_at >=0 and article.created_at <=9000000000
|
|
|
// and article.title like '%%' |
...
|
...
|
|