Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
unify_api2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chaonan
unify_api2
Commits
46d95b91
Commit
46d95b91
authored
Mar 07, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add top delete news 2024-03-6
parent
87f3a1e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
news_info_cps.py
unify_api/modules/qkadmin/components/news_info_cps.py
+4
-3
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+17
-0
new_mgr.py
unify_api/modules/qkadmin/views/new_mgr.py
+22
-2
No files found.
unify_api/modules/qkadmin/components/news_info_cps.py
View file @
46d95b91
...
...
@@ -22,10 +22,10 @@ class NewsInfoRsp(Model):
@
dataclass
class
PubNewsReq
(
Model
):
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
title
:
str
=
Opt
(
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
)
author
:
str
=
Opt
(
Str
(
"文章作者"
)
.
eg
(
"清科优能"
))
news_type
:
int
=
Opt
(
Int
(
"文章类型(1:公司新闻, 2:行业新闻)"
)
.
eg
(
1
))
pub_time
:
str
=
Str
(
"发布时间"
)
.
eg
(
"2023-12-29 18:06"
)
pub_time
:
str
=
Opt
(
Str
(
"发布时间"
)
.
eg
(
"2023-12-29 18:06"
)
)
keywords
:
str
=
Opt
(
Str
(
"文章关键词"
)
.
eg
(
"清科优能"
))
contents
:
str
=
Opt
(
Str
(
"文章描述"
)
.
eg
(
"清科优能"
))
...
...
@@ -33,7 +33,8 @@ class PubNewsReq(Model):
@
dataclass
class
ReviseNewsReq
(
Model
):
news_id
:
str
=
Str
(
"文章id"
)
.
eg
(
"12"
)
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
title
:
str
=
Opt
(
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
))
top
:
int
=
Opt
(
Int
(
"置顶/取消置顶"
)
.
eg
(
0
))
@
dataclass
...
...
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
46d95b91
...
...
@@ -78,6 +78,23 @@ async def update_news_seo(news_id, keywords, contents):
return
await
conn
.
execute
(
sql
,
(
news_id
,
keywords
,
contents
,))
async
def
delete_news
(
news_id
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
sql
=
"DELETE FROM official_web.news_info WHERE id=
%
s;"
await
conn
.
execute
(
sql
,
(
news_id
,))
sql
=
"SELECT 1 FROM official_web.news_info WHERE id=
%
s LIMIT 1;"
rlt
=
await
conn
.
execute
(
sql
,
(
news_id
,))
return
False
if
rlt
else
True
async
def
top_news
(
news_id
,
top
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
sql
=
"UPDATE official_web.news_info SET top=
%
s WHERE id=
%
s;"
await
conn
.
execute
(
sql
,
(
top
,
news_id
,))
sql
=
"SELECT 1 FROM official_web.news_info WHERE id=
%
s AND top=
%
s;"
return
await
conn
.
execute
(
sql
,
(
news_id
,
top
,))
async
def
load_news_pages
(
params
):
page_num
,
page_size
=
params
[
"page_num"
],
params
[
"page_size"
]
news_type
,
se_title
=
params
[
"news_type"
],
params
[
"se_title"
]
...
...
unify_api/modules/qkadmin/views/new_mgr.py
View file @
46d95b91
...
...
@@ -11,7 +11,7 @@ from unify_api.modules.qkadmin.components.news_info_cps import (
)
from
unify_api.modules.qkadmin.service.news_mgr_srv
import
(
upload_news_qs
,
save_news_info
,
load_news_pages
,
update_news_info
,
update_news_seo
update_news_seo
,
delete_news
,
top_news
)
...
...
@@ -28,7 +28,7 @@ async def post_publish_news(request, body: PubNewsReq) -> SuccessRsp:
return
SuccessRsp
(
success
=
0
,
message
=
"发布文章失败"
)
@
summary
(
"
修改文章
"
)
@
summary
(
"
重新编辑文章(标题/内容/封面)
"
)
async
def
post_revise_news
(
request
,
body
:
ReviseNewsReq
)
->
SuccessRsp
:
news_id
,
title
=
body
.
news_id
,
body
.
title
is_success
,
url_article
,
url_cover
=
await
upload_news_qs
(
request
)
...
...
@@ -46,6 +46,26 @@ async def post_revise_news_seo(request, body: ReviseNewsSeoReq) -> SuccessRsp:
return
SuccessRsp
(
success
=
1
,
message
=
"修改文章SEO优化成功"
)
@
summary
(
"删除文章"
)
async
def
post_delete_news
(
request
,
body
:
ReviseNewsReq
)
->
SuccessRsp
:
news_id
=
body
.
news_id
is_success
=
await
delete_news
(
news_id
)
if
is_success
:
return
SuccessRsp
(
success
=
1
,
message
=
"删除文章成功"
)
return
SuccessRsp
(
success
=
0
,
message
=
"删除文章失败"
)
@
summary
(
"置顶/取消置顶文章"
)
async
def
post_top_news
(
request
,
body
:
ReviseNewsReq
)
->
SuccessRsp
:
news_id
,
top
=
body
.
news_id
,
body
.
top
is_success
=
await
top_news
(
news_id
,
top
)
if
is_success
:
return
SuccessRsp
(
success
=
1
,
message
=
"修改文章置顶成功"
)
return
SuccessRsp
(
success
=
0
,
message
=
"修改文章置顶失败"
)
@
summary
(
"后台文章列表"
)
async
def
post_news_pages
(
request
,
body
:
NewsPagesReq
)
->
NewsPagesRsp
:
page_num
=
int
(
body
.
page_num
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment