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
6a1796b0
Commit
6a1796b0
authored
Mar 06, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update news info 2024-03-6
parent
0269e24c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
10 deletions
+41
-10
news_info_cps.py
unify_api/modules/qkadmin/components/news_info_cps.py
+10
-0
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+15
-5
new_mgr.py
unify_api/modules/qkadmin/views/new_mgr.py
+16
-5
No files found.
unify_api/modules/qkadmin/components/news_info_cps.py
View file @
6a1796b0
...
@@ -24,7 +24,10 @@ class NewsInfoRsp(Model):
...
@@ -24,7 +24,10 @@ class NewsInfoRsp(Model):
class
PubNewsReq
(
Model
):
class
PubNewsReq
(
Model
):
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
author
:
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
=
Str
(
"发布时间"
)
.
eg
(
"2023-12-29 18:06"
)
keywords
:
str
=
Opt
(
Str
(
"文章关键词"
)
.
eg
(
"清科优能"
))
contents
:
str
=
Opt
(
Str
(
"文章描述"
)
.
eg
(
"清科优能"
))
@
dataclass
@
dataclass
...
@@ -33,6 +36,13 @@ class ReviseNewsReq(Model):
...
@@ -33,6 +36,13 @@ class ReviseNewsReq(Model):
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
title
:
str
=
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
)
@
dataclass
class
ReviseNewsSeoReq
(
Model
):
news_id
:
str
=
Str
(
"文章id"
)
.
eg
(
"12"
)
keywords
:
str
=
Opt
(
Str
(
"文章关键词"
)
.
eg
(
"清科优能"
))
contents
:
str
=
Opt
(
Str
(
"文章描述"
)
.
eg
(
"清科优能"
))
@
dataclass
@
dataclass
class
NewsPagesReq
(
Model
):
class
NewsPagesReq
(
Model
):
news_type
:
int
=
Opt
(
Int
(
"文章类型(1:公司新闻, 2:行业新闻) 不传则返回所有类型文章"
)
.
eg
(
1
))
news_type
:
int
=
Opt
(
Int
(
"文章类型(1:公司新闻, 2:行业新闻) 不传则返回所有类型文章"
)
.
eg
(
1
))
...
...
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
6a1796b0
...
@@ -47,12 +47,15 @@ async def upload_news_qs(request):
...
@@ -47,12 +47,15 @@ async def upload_news_qs(request):
return
True
,
url_article
,
url_cover
return
True
,
url_article
,
url_cover
async
def
save_news_info
(
title
,
pub_time
,
news_url
,
cover_url
):
async
def
save_news_info
(
news_info
,
news_url
,
cover_url
):
sql
=
"INSERT INTO official_web.news_info ("
\
sql
=
"INSERT INTO official_web.news_info (
title, news_type, news_url,
"
\
"
title, pub_time, news_url, cover_url
) "
\
"
cover_url, keywords, contents, pub_time
) "
\
"VALUES (
%
s,
%
s,
%
s,
%
s);"
"VALUES (
%
s,
%
s,
%
s,
%
s
,
%
s,
%
s,
%
s
);"
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
await
conn
.
execute
(
sql
,
(
title
,
str
(
pub_time
),
news_url
,
cover_url
))
await
conn
.
execute
(
sql
,
(
news_info
[
"title"
],
news_info
[
"news_type"
],
news_url
,
cover_url
,
news_info
[
"keywords"
],
news_info
[
"contents"
],
str
(
news_info
[
"pub_time"
]),))
async
def
update_news_info
(
news_id
,
title
,
news_url
,
cover_url
):
async
def
update_news_info
(
news_id
,
title
,
news_url
,
cover_url
):
...
@@ -68,6 +71,13 @@ async def update_news_info(news_id, title, news_url, cover_url):
...
@@ -68,6 +71,13 @@ async def update_news_info(news_id, title, news_url, cover_url):
return
await
conn
.
execute
(
sql
,
(
news_id
,
title
,
news_url
,))
return
await
conn
.
execute
(
sql
,
(
news_id
,
title
,
news_url
,))
async
def
update_news_seo
(
news_id
,
keywords
,
contents
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
sql
=
"UPDATE official_web.news_info "
\
"SET keywords=
%
s, contents=
%
s WHERE id=
%
s;"
return
await
conn
.
execute
(
sql
,
(
news_id
,
keywords
,
contents
,))
async
def
load_news_pages
(
news_type
,
page_num
,
page_size
):
async
def
load_news_pages
(
news_type
,
page_num
,
page_size
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
if
news_type
:
if
news_type
:
...
...
unify_api/modules/qkadmin/views/new_mgr.py
View file @
6a1796b0
...
@@ -6,19 +6,23 @@ DATE:2024/3/5 16:19
...
@@ -6,19 +6,23 @@ DATE:2024/3/5 16:19
from
pot_libs.sanic_api
import
summary
from
pot_libs.sanic_api
import
summary
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
(
PubNewsReq
,
NewsPagesReq
,
NewsPagesRsp
,
NewsInfo
,
ReviseNewsReq
PubNewsReq
,
NewsPagesReq
,
NewsPagesRsp
,
NewsInfo
,
ReviseNewsReq
,
ReviseNewsSeoReq
)
)
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
)
)
@
summary
(
"发布文章"
)
@
summary
(
"发布文章"
)
async
def
post_publish_news
(
request
,
body
:
PubNewsReq
)
->
SuccessRsp
:
async
def
post_publish_news
(
request
,
body
:
PubNewsReq
)
->
SuccessRsp
:
title
,
pub_time
,
author
=
body
.
title
,
body
.
pub_time
,
body
.
author
is_success
,
news_url
,
cover_url
=
await
upload_news_qs
(
request
)
is_success
,
url_article
,
url_cover
=
await
upload_news_qs
(
request
)
if
is_success
:
if
is_success
:
await
save_news_info
(
title
,
pub_time
,
url_article
,
url_cover
)
d_news_info
=
dict
(
title
=
body
.
title
,
author
=
body
.
author
,
pub_time
=
body
.
pub_time
,
news_type
=
int
(
body
.
news_type
))
await
save_news_info
(
d_news_info
,
news_url
,
cover_url
)
return
SuccessRsp
(
success
=
1
,
message
=
"发布文章成功"
)
return
SuccessRsp
(
success
=
1
,
message
=
"发布文章成功"
)
return
SuccessRsp
(
success
=
0
,
message
=
"发布文章失败"
)
return
SuccessRsp
(
success
=
0
,
message
=
"发布文章失败"
)
...
@@ -35,6 +39,13 @@ async def post_revise_news(request, body: ReviseNewsReq) -> SuccessRsp:
...
@@ -35,6 +39,13 @@ async def post_revise_news(request, body: ReviseNewsReq) -> SuccessRsp:
return
SuccessRsp
(
success
=
0
,
message
=
"修改文章失败"
)
return
SuccessRsp
(
success
=
0
,
message
=
"修改文章失败"
)
@
summary
(
"修改文章SEO优化"
)
async
def
post_revise_news_seo
(
request
,
body
:
ReviseNewsSeoReq
)
->
SuccessRsp
:
news_id
,
keywords
,
contents
=
body
.
news_id
,
body
.
keywords
,
body
.
contents
await
update_news_seo
(
news_id
,
keywords
,
contents
)
return
SuccessRsp
(
success
=
1
,
message
=
"修改文章SEO优化成功"
)
@
summary
(
"后台文章列表"
)
@
summary
(
"后台文章列表"
)
async
def
get_news_pages
(
request
,
body
:
NewsPagesReq
)
->
NewsPagesRsp
:
async
def
get_news_pages
(
request
,
body
:
NewsPagesReq
)
->
NewsPagesRsp
:
page_num
=
int
(
body
.
page_num
)
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