kboss/b/news/front_news_detail.dspy
2026-07-14 15:22:23 +08:00

38 lines
1.3 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, article_type, summary, cover_img, content, publish_time, 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