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
1a17c015
Commit
1a17c015
authored
Mar 09, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix news search 2024-03-9
parent
af97846d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+7
-12
No files found.
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
1a17c015
...
@@ -108,21 +108,17 @@ async def load_news_pages(params):
...
@@ -108,21 +108,17 @@ async def load_news_pages(params):
news_type
,
se_title
=
params
[
"news_type"
],
params
[
"se_title"
]
news_type
,
se_title
=
params
[
"news_type"
],
params
[
"se_title"
]
s_dts
,
e_dts
=
params
[
"s_dts"
],
params
[
"e_dts"
]
s_dts
,
e_dts
=
params
[
"s_dts"
],
params
[
"e_dts"
]
offsets
=
0
if
page_num
==
0
else
(
page_num
-
1
)
*
page_size
offsets
=
0
if
page_num
==
0
else
(
page_num
-
1
)
*
page_size
conds
,
param_lst
=
[],
[]
conds
=
[]
if
news_type
:
if
news_type
:
param_lst
.
append
(
news_type
)
conds
.
append
(
f
"news_type={news_type}"
)
conds
.
append
(
f
"news_type=
%
s"
)
if
s_dts
:
if
s_dts
:
s_dt
=
pendulum
.
parse
(
s_dts
,
tz
=
"Asia/Shanghai"
)
s_dt
=
pendulum
.
parse
(
s_dts
,
tz
=
"Asia/Shanghai"
)
param_lst
.
append
(
str
(
s_dt
))
conds
.
append
(
f
"pub_time>='{str(s_dt)}'"
)
conds
.
append
(
f
"pub_time>=
%
s"
)
if
e_dts
:
if
e_dts
:
e_dt
=
pendulum
.
parse
(
e_dts
,
tz
=
"Asia/Shanghai"
)
e_dt
=
pendulum
.
parse
(
e_dts
,
tz
=
"Asia/Shanghai"
)
param_lst
.
append
(
str
(
e_dt
))
conds
.
append
(
f
"pub_time<'{str(e_dt)}'"
)
conds
.
append
(
f
"pub_time<
%
s"
)
if
se_title
:
if
se_title
:
param_lst
.
append
(
se_title
)
conds
.
append
(
f
"title LIKE '
%%
{se_title}
%%
'"
)
conds
.
append
(
f
"title LIKE '
%
{se_title}
%
'"
)
if
len
(
conds
)
>
1
:
if
len
(
conds
)
>
1
:
conds_str
=
"WHERE "
+
" AND "
.
join
(
conds
)
conds_str
=
"WHERE "
+
" AND "
.
join
(
conds
)
...
@@ -131,7 +127,6 @@ async def load_news_pages(params):
...
@@ -131,7 +127,6 @@ async def load_news_pages(params):
else
:
else
:
conds_str
=
""
conds_str
=
""
param_lst
+=
[
page_size
,
offsets
]
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
if
news_type
:
if
news_type
:
sql
=
"SELECT count(*) FROM official_web.news_info "
\
sql
=
"SELECT count(*) FROM official_web.news_info "
\
...
@@ -144,9 +139,9 @@ async def load_news_pages(params):
...
@@ -144,9 +139,9 @@ async def load_news_pages(params):
sql
=
f
"SELECT id, title, author, news_type, pub_time, top "
\
sql
=
f
"SELECT id, title, author, news_type, pub_time, top "
\
f
"FROM official_web.news_info "
\
f
"FROM official_web.news_info "
\
f
"{conds_str} "
\
f
"{conds_str} "
\
f
"ORDER BY pub_time DESC, id LIMIT
%
s OFFSET
%
s
;"
f
"ORDER BY pub_time DESC, id LIMIT
{page_size} OFFSET {offsets}
;"
articles
=
await
conn
.
fetchall
(
sql
,
(
tuple
(
param_lst
))
)
articles
=
await
conn
.
fetchall
(
sql
)
return
total
,
articles
return
total
,
articles
...
...
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