kboss/b/news/front_news_detail.dspy
2026-07-29 17:36:49 +08:00

40 lines
1.5 KiB
Plaintext

async def front_news_detail(ns={}):
if not ns.get('id'):
return {
'status': False,
'msg': '请传递id'
}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
update_sql = """update enterprise_news_article set read_count = ifnull(read_count, 0) + 1 where id = '%s' and status = '1' and del_flg = '0';""" % ns.get('id')
await sor.sqlExe(update_sql, {})
search_sql = """
select id, title_zh, title_en, article_type_zh, article_type_en,
summary_zh, summary_en, cover_img_zh, cover_img_en,
content_zh, content_en, publish_time_zh, publish_time_en, read_count
from enterprise_news_article
where id = '%s' and status = '1' and del_flg = '0';
""" % ns.get('id')
result = await sor.sqlExe(search_sql, {})
if not result:
return {
'status': False,
'msg': '文章不存在或未发布'
}
return {
'status': True,
'msg': 'search front news detail success',
'data': result[0]
}
except Exception as e:
await sor.rollback()
return {
'status': False,
'msg': 'search front news detail failed, %s' % str(e)
}
ret = await front_news_detail(params_kw)
return ret