Commit 3b60c56d authored by ZZH's avatar ZZH

add news detail 2024-03-8

parent 243843b3
...@@ -15,9 +15,15 @@ class NewsInfoReq(Model): ...@@ -15,9 +15,15 @@ class NewsInfoReq(Model):
@dataclass @dataclass
class NewsInfoRsp(Model): class NewsInfoRsp(Model):
title: str = Str("文章标题").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!") title: str = Opt(Str("文章标题").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"))
contents: str = Str("文章内容").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!") author: str = Opt(Str("文章作者").eg("清科优能"))
pub_time: str = Str("发布时间").eg("2023-12-29 18:06") news_type: int = Opt(Int("文章类型(1:公司新闻, 2:行业新闻)").eg(1))
top: int = Opt(Int("是否置顶").eg(0))
keywords: str = Opt(Str("文章关键词").eg("专精特新"))
contents: str = Opt(Str("文章描述").eg("清科优能被评定为深圳市“专精特新”企业!"))
news_url: str = Opt(Str("文章URL").eg("xxx90c2-bb7ef44fea51.html"))
cover_url: str = Opt(Str("封面URL").eg("xxxx68117e4c27e4.png"))
pub_time: str = Opt(Str("发布时间").eg("2023-12-29 18:06"))
@dataclass @dataclass
...@@ -40,6 +46,7 @@ class ReviseNewsReq(Model): ...@@ -40,6 +46,7 @@ class ReviseNewsReq(Model):
pub_time: str = Opt(Str("发布时间").eg("2023-12-29 18:06")) pub_time: str = Opt(Str("发布时间").eg("2023-12-29 18:06"))
top: int = Opt(Int("置顶/取消置顶").eg(0)) top: int = Opt(Int("置顶/取消置顶").eg(0))
@dataclass @dataclass
class ReviseNewsSeoReq(Model): class ReviseNewsSeoReq(Model):
news_id: str = Str("文章id").eg("12") news_id: str = Str("文章id").eg("12")
...@@ -60,13 +67,15 @@ class NewsPagesReq(Model): ...@@ -60,13 +67,15 @@ class NewsPagesReq(Model):
@dataclass @dataclass
class NewsInfo(Model): class NewsInfo(Model):
id: int = Opt(Int("文章ID").eg(1)) id: int = Opt(Int("文章ID").eg(1))
title: str = Str("文章标题").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!") title: str = Opt(Str("文章标题").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"))
author: str = Str("文章作者").eg("清科优能") author: str = Opt(Str("文章作者").eg("清科优能"))
pub_time: str = Str("发布时间").eg("2023-12-29 18:06") news_type: int = Opt(Int("文章类型(1:公司新闻, 2:行业新闻)").eg(1))
news_type: int = Int("文章类型(1:公司新闻, 2:行业新闻)").eg(1)
top: int = Opt(Int("是否置顶").eg(0)) top: int = Opt(Int("是否置顶").eg(0))
contents: str = Opt(Str("文章内容").eg("喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!")) keywords: str = Opt(Str("文章关键词").eg("专精特新"))
cover_url: str = Opt(Str("文章封面URL").eg("xxxxxxxxxx")) contents: str = Opt(Str("文章描述").eg("清科优能被评定为深圳市“专精特新”企业!"))
news_url: str = Opt(Str("文章URL").eg("xxx90c2-bb7ef44fea51.html"))
cover_url: str = Opt(Str("封面URL").eg("xxxx68117e4c27e4.png"))
pub_time: str = Opt(Str("发布时间").eg("2023-12-29 18:06"))
@dataclass @dataclass
......
...@@ -148,3 +148,9 @@ async def load_news_pages(params): ...@@ -148,3 +148,9 @@ async def load_news_pages(params):
articles = await conn.fetchall(sql, (tuple(param_lst))) articles = await conn.fetchall(sql, (tuple(param_lst)))
return total, articles return total, articles
async def load_news_info(news_id):
sql = "SELECT * FROM official_web.news_info WHERE id=%s;"
async with MysqlUtil(db="official_web") as conn:
return await conn.fetchone(sql, (news_id,))
...@@ -7,11 +7,12 @@ from pot_libs.sanic_api import summary ...@@ -7,11 +7,12 @@ from pot_libs.sanic_api import summary
from pot_libs.logger import log from pot_libs.logger import log
from unify_api.modules.common.components.common_cps import SuccessRsp from unify_api.modules.common.components.common_cps import SuccessRsp
from unify_api.modules.qkadmin.components.news_info_cps import ( from unify_api.modules.qkadmin.components.news_info_cps import (
NewsPagesReq, NewsPagesRsp, NewsInfo, ReviseNewsReq, ReviseNewsSeoReq NewsPagesReq, NewsPagesRsp, NewsInfo, ReviseNewsReq, ReviseNewsSeoReq,
NewsInfoReq, NewsInfoRsp
) )
from unify_api.modules.qkadmin.service.news_mgr_srv import ( from unify_api.modules.qkadmin.service.news_mgr_srv import (
upload_news_qs, save_news_info, load_news_pages, update_news_info, upload_news_qs, save_news_info, load_news_pages, update_news_info,
update_news_seo, delete_news, top_news update_news_seo, delete_news, top_news, load_news_info
) )
...@@ -64,6 +65,15 @@ async def post_delete_news(request, body: ReviseNewsReq) -> SuccessRsp: ...@@ -64,6 +65,15 @@ async def post_delete_news(request, body: ReviseNewsReq) -> SuccessRsp:
return SuccessRsp(success=0, message="删除文章失败") return SuccessRsp(success=0, message="删除文章失败")
@summary("文章详情")
async def post_news_detail(request, body: NewsInfoReq) -> NewsInfoRsp:
r = await load_news_info(body.news_id)
return NewsInfoRsp(title=r["title"], news_type=r["news_type"],
keywords=r["keywords"], contents=r["contents"],
news_url=r["news_url"], cover_url=r["cover_url"],
pub_time=r["pub_time"])
@summary("置顶/取消置顶文章") @summary("置顶/取消置顶文章")
async def post_top_news(request, body: ReviseNewsReq) -> SuccessRsp: async def post_top_news(request, body: ReviseNewsReq) -> SuccessRsp:
news_id, top = body.news_id, body.top news_id, top = body.news_id, body.top
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment