From 5bc32fdb24aad7e1bd031b16fcb4a3e62ec26d44 Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Tue, 14 Jul 2026 17:16:36 +0800 Subject: [PATCH] updaste --- b/news/front_news_search.dspy | 2 +- b/news/news_article_search.dspy | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/b/news/front_news_search.dspy b/b/news/front_news_search.dspy index 09544aa..67d05f4 100644 --- a/b/news/front_news_search.dspy +++ b/b/news/front_news_search.dspy @@ -16,7 +16,7 @@ async def front_news_search(ns={}): if ns.get('article_type'): conditions.append("article_type = '%s'" % ns.get('article_type')) if ns.get('title'): - conditions.append("title like '%%%s%%'" % ns.get('title')) + conditions.append("title like '%%%%%s%%%%'" % ns.get('title')) where_clause = " and ".join(conditions) db = DBPools() diff --git a/b/news/news_article_search.dspy b/b/news/news_article_search.dspy index 5d4d42f..7ae054e 100644 --- a/b/news/news_article_search.dspy +++ b/b/news/news_article_search.dspy @@ -13,6 +13,7 @@ async def news_article_search(ns={}): offset = (current_page - 1) * page_size conditions = ["domain_name = '%s'" % domain_name, "del_flg = '0'"] + summary_conditions = ["domain_name = '%s'" % domain_name, "del_flg = '0'"] if ns.get('title'): conditions.append("title like '%%%%%s%%%%'" % ns.get('title')) if ns.get('article_type'): @@ -26,6 +27,24 @@ async def news_article_search(ns={}): try: count_sql = """select count(*) as total_count from enterprise_news_article where %s;""" % where_clause total_count = (await sor.sqlExe(count_sql, {}))[0]['total_count'] + summary_sql = """ + select article_type, count(*) as article_count, ifnull(sum(read_count), 0) as read_count + from enterprise_news_article + where %s + group by article_type; + """ % " and ".join(summary_conditions) + summary_result = await sor.sqlExe(summary_sql, {}) + summary_mapping = {} + for summary_dic in summary_result: + summary_mapping[summary_dic.get('article_type')] = summary_dic + article_type_summary = [] + for article_type in ['企业动态', '产品动态', '行业洞察', '活动资讯']: + summary_dic = summary_mapping.get(article_type, {}) + article_type_summary.append({ + 'article_type': article_type, + 'article_count': summary_dic.get('article_count', 0), + 'read_count': summary_dic.get('read_count', 0) + }) search_sql = """ select id, domain_name, title, article_type, summary, cover_img, status, publish_time, read_count, update_time, create_at @@ -42,6 +61,7 @@ async def news_article_search(ns={}): 'status': True, 'msg': 'search news article success', 'data': result, + 'article_type_summary': article_type_summary, 'pagination': { 'total': total_count, 'page_size': page_size,