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
243843b3
Commit
243843b3
authored
Mar 08, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix news edit 2024-03-8
parent
c607b9ea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
11 deletions
+19
-11
news_info_cps.py
unify_api/modules/qkadmin/components/news_info_cps.py
+4
-1
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+10
-7
new_mgr.py
unify_api/modules/qkadmin/views/new_mgr.py
+5
-3
No files found.
unify_api/modules/qkadmin/components/news_info_cps.py
View file @
243843b3
...
@@ -34,9 +34,12 @@ class PubNewsReq(Model):
...
@@ -34,9 +34,12 @@ class PubNewsReq(Model):
class
ReviseNewsReq
(
Model
):
class
ReviseNewsReq
(
Model
):
news_id
:
str
=
Str
(
"文章id"
)
.
eg
(
"12"
)
news_id
:
str
=
Str
(
"文章id"
)
.
eg
(
"12"
)
title
:
str
=
Opt
(
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
))
title
:
str
=
Opt
(
Str
(
"文章标题"
)
.
eg
(
"喜报丨热烈庆祝清科优能被评定为深圳市“专精特新”企业!"
))
news_type
:
int
=
Opt
(
Int
(
"文章类型(1:公司新闻, 2:行业新闻)"
)
.
eg
(
1
))
keywords
:
str
=
Opt
(
Str
(
"文章关键词"
)
.
eg
(
"清科优能"
))
contents
:
str
=
Opt
(
Str
(
"文章描述"
)
.
eg
(
"清科优能"
))
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"
)
...
...
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
243843b3
...
@@ -63,17 +63,20 @@ async def save_news_info(news_info, news_url, cover_url):
...
@@ -63,17 +63,20 @@ async def save_news_info(news_info, news_url, cover_url):
str
(
news_info
[
"pub_time"
]),))
str
(
news_info
[
"pub_time"
]),))
async
def
update_news_info
(
news_i
d
,
title
,
news_url
,
cover_url
):
async
def
update_news_info
(
news_i
nfo
,
news_url
,
cover_url
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
if
cover_url
:
if
cover_url
:
sql
=
"UPDATE official_web.news_info "
\
sql
=
"UPDATE official_web.news_info SET cover_url=
%
s WHERE id=
%
s;"
"SET title=
%
s, news_url=
%
s, cover_url=
%
s WHERE id=
%
s;"
await
conn
.
execute
(
sql
,
(
cover_url
,
news_info
[
"news_id"
],))
return
await
conn
.
execute
(
sql
,
(
news_id
,
title
,
news_url
,
cover_url
))
sql
=
"UPDATE official_web.news_info "
\
sql
=
"UPDATE official_web.news_info "
\
"SET title=
%
s, news_url=
%
s WHERE id=
%
s;"
"SET title=
%
s, news_type=
%
s, news_url=
%
s, keywords=
%
s, "
\
return
await
conn
.
execute
(
sql
,
(
news_id
,
title
,
news_url
,))
"contents=
%
s, pub_time=
%
s WHERE id=
%
s;"
await
conn
.
execute
(
sql
,
(
news_info
[
"title"
],
news_info
[
"news_type"
],
news_url
,
news_info
[
"keywords"
],
news_info
[
"contents"
],
str
(
news_info
[
"pub_time"
]),
news_info
[
"news_id"
]))
async
def
update_news_seo
(
news_id
,
keywords
,
contents
):
async
def
update_news_seo
(
news_id
,
keywords
,
contents
):
...
...
unify_api/modules/qkadmin/views/new_mgr.py
View file @
243843b3
...
@@ -34,12 +34,14 @@ async def post_publish_news(request, *args, **kwargs) -> SuccessRsp:
...
@@ -34,12 +34,14 @@ async def post_publish_news(request, *args, **kwargs) -> SuccessRsp:
return
SuccessRsp
(
success
=
0
,
message
=
"发布文章失败"
)
return
SuccessRsp
(
success
=
0
,
message
=
"发布文章失败"
)
@
summary
(
"重新编辑文章(标题
/内容/封面
)"
)
@
summary
(
"重新编辑文章(标题
|内容|封面|文章分类|发布时间|关键词|描述
)"
)
async
def
post_revise_news
(
request
,
body
:
ReviseNewsReq
)
->
SuccessRsp
:
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
)
is_success
,
url_article
,
url_cover
=
await
upload_news_qs
(
request
)
if
is_success
:
if
is_success
:
await
update_news_info
(
news_id
,
title
,
url_article
,
url_cover
)
d_news_info
=
dict
(
title
=
body
.
title
,
pub_time
=
body
.
pub_time
,
keywords
=
body
.
keywords
,
contents
=
body
.
contents
,
news_type
=
int
(
body
.
news_type
))
await
update_news_info
(
d_news_info
,
url_article
,
url_cover
)
return
SuccessRsp
(
success
=
1
,
message
=
"修改文章成功"
)
return
SuccessRsp
(
success
=
1
,
message
=
"修改文章成功"
)
return
SuccessRsp
(
success
=
0
,
message
=
"修改文章失败"
)
return
SuccessRsp
(
success
=
0
,
message
=
"修改文章失败"
)
...
...
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