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
d1986959
Commit
d1986959
authored
Mar 11, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix revise news 2024-03-11
parent
b68392cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+17
-15
new_mgr.py
unify_api/modules/qkadmin/views/new_mgr.py
+0
-3
No files found.
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
d1986959
...
...
@@ -36,21 +36,27 @@ async def upload_news_qs(request):
url_article
,
url_cover
=
""
,
""
news_file
=
request
.
files
.
getlist
(
"file1"
)[
0
]
cover_file
=
request
.
files
.
getlist
(
"file2"
)[
0
]
if
news_file
.
name
==
cover_file
.
name
:
if
not
news_file
:
return
False
,
url_article
,
url_cover
if
cover_file
and
news_file
.
name
==
cover_file
.
name
:
return
False
,
url_article
,
url_cover
news_upload
,
url_article
=
await
upload_file_helper
(
news_file
)
if
news_upload
and
url_article
:
log
.
info
(
f
"上传文章成功, url {url_article}"
)
if
not
news_upload
or
not
url_article
:
log
.
info
(
f
"上传文章失败, url {url_article}"
)
return
False
,
url_article
,
url_cover
cover_upload
,
url_cover
=
await
upload_file_helper
(
cover_file
)
if
cover_upload
and
url_cover
:
log
.
info
(
f
"上传文章封面, url {url_cover}"
)
if
not
cover_file
:
log
.
info
(
f
"没有上传文章封面|删除文章封面成功"
)
return
True
,
url_article
,
url_cover
if
all
([
news_file
,
url_article
,
cover_upload
,
url_cover
]):
cover_upload
,
url_cover
=
await
upload_file_helper
(
cover_file
)
if
all
([
news_upload
,
url_article
,
cover_upload
,
url_cover
]):
log
.
info
(
f
"上传文章和封面成功 {url_article} {url_cover}"
)
return
True
,
url_article
,
url_cover
log
.
info
(
f
"上传文章或封面失败 {url_article} {url_cover}"
)
return
False
,
url_article
,
url_cover
...
...
@@ -66,16 +72,12 @@ async def save_news_info(news_info, news_url, cover_url):
async
def
update_news_info
(
news_info
,
news_url
,
cover_url
):
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
if
cover_url
:
sql
=
"UPDATE official_web.news_info SET cover_url=
%
s WHERE id=
%
s;"
await
conn
.
execute
(
sql
,
(
cover_url
,
news_info
[
"news_id"
],))
sql
=
"UPDATE official_web.news_info "
\
"SET title=
%
s, news_type=
%
s, news_url=
%
s, keywords=
%
s, "
\
"contents=
%
s, pub_time=
%
s WHERE id=
%
s;"
"SET title=
%
s, news_type=
%
s, news_url=
%
s, cover_url=
%
s, "
\
"keywords=
%
s, contents=
%
s, pub_time=
%
s WHERE id=
%
s;"
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
await
conn
.
execute
(
sql
,
(
news_info
[
"title"
],
news_info
[
"news_type"
],
news_url
,
news_info
[
"keywords"
],
news_url
,
cover_url
,
news_info
[
"keywords"
],
news_info
[
"contents"
],
str
(
news_info
[
"pub_time"
]),
news_info
[
"news_id"
]))
...
...
unify_api/modules/qkadmin/views/new_mgr.py
View file @
d1986959
...
...
@@ -18,9 +18,6 @@ from unify_api.modules.qkadmin.service.news_mgr_srv import (
@
summary
(
"发布文章"
)
async
def
post_publish_news
(
request
,
*
args
,
**
kwargs
)
->
SuccessRsp
:
log
.
info
(
f
"post_publish_news:{request.form}"
)
log
.
info
(
f
"post_publish_news:{len(request.files.getlist('file1'))}"
)
log
.
info
(
f
"post_publish_news:{len(request.files.getlist('file2'))}"
)
is_success
,
news_url
,
cover_url
=
await
upload_news_qs
(
request
)
if
is_success
:
form
=
request
.
form
...
...
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