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
5fbd8156
Commit
5fbd8156
authored
Mar 14, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contact add time condition 2024-03-14
parent
82a5137f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
24 deletions
+20
-24
contact_us_cps.py
unify_api/modules/qkadmin/components/contact_us_cps.py
+2
-0
contact_us_srv.py
unify_api/modules/qkadmin/service/contact_us_srv.py
+10
-4
news_mgr_srv.py
unify_api/modules/qkadmin/service/news_mgr_srv.py
+4
-17
contact_us.py
unify_api/modules/qkadmin/views/contact_us.py
+4
-3
No files found.
unify_api/modules/qkadmin/components/contact_us_cps.py
View file @
5fbd8156
...
...
@@ -12,6 +12,8 @@ from pot_libs.sanic_api.column import Opt, Int, Str, List
class
ContactsReq
(
Model
):
page_num
:
int
=
Int
(
"页码"
)
.
eg
(
1
)
page_size
:
int
=
Opt
(
Int
(
"条数"
)
.
eg
(
10
))
start_time
:
str
=
Opt
(
Str
(
"起始时间"
)
.
eg
(
"2024-03-07 00:00:00"
))
end_time
:
str
=
Opt
(
Str
(
"截止时间"
)
.
eg
(
"2023-12-29 18:06"
))
@
dataclass
...
...
unify_api/modules/qkadmin/service/contact_us_srv.py
View file @
5fbd8156
...
...
@@ -6,14 +6,20 @@ DATE:2024/3/7 11:08
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
async
def
load_contact_records
(
page_num
,
page_size
):
async
def
load_contact_records
(
page_num
,
page_size
,
s_dts
,
e_dts
):
offsets
=
0
if
page_num
==
0
else
(
page_num
-
1
)
*
page_size
ts_conds
=
[]
if
s_dts
:
ts_conds
.
append
(
f
"pub_time>='{str(s_dts)}'"
)
if
e_dts
:
ts_conds
.
append
(
f
"pub_time<'{str(e_dts)}'"
)
conds_str
=
" WHERE "
+
" AND "
.
join
(
ts_conds
)
if
ts_conds
else
""
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
sql
=
"SELECT count(*) FROM official_web.contact_record
;"
sql
=
f
"SELECT count(*) FROM official_web.contact_record {conds_str}
;"
total
=
await
conn
.
fetch_value
(
sql
)
sql
=
f
"SELECT * FROM official_web.contact_record "
\
sql
=
f
"SELECT * FROM official_web.contact_record
{conds_str}
"
\
f
"ORDER BY create_time DESC, id LIMIT
%
s OFFSET
%
s;"
records
=
await
conn
.
fetchall
(
sql
,
(
page_size
,
offsets
))
return
total
,
records
unify_api/modules/qkadmin/service/news_mgr_srv.py
View file @
5fbd8156
...
...
@@ -125,27 +125,14 @@ async def load_news_pages(params):
if
se_title
:
conds
.
append
(
f
"title LIKE '
%%
{se_title}
%%
'"
)
if
len
(
conds
)
>
1
:
conds_str
=
"WHERE "
+
" AND "
.
join
(
conds
)
elif
len
(
conds
)
==
1
:
conds_str
=
f
"WHERE {conds[0]} "
else
:
conds_str
=
""
conds_str
=
" WHERE "
+
" AND "
.
join
(
conds
)
if
conds
else
""
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
if
news_type
:
sql
=
"SELECT count(*) FROM official_web.news_info "
\
"WHERE news_type=
%
s;"
total
=
await
conn
.
fetch_value
(
sql
,
(
news_type
,))
else
:
sql
=
"SELECT count(*) FROM official_web.news_info;"
sql
=
f
"SELECT count(*) FROM official_web.news_info {conds_str};"
total
=
await
conn
.
fetch_value
(
sql
)
sql
=
f
"SELECT id, title, author, news_type, pub_time, top "
\
f
"FROM official_web.news_info "
\
f
"{conds_str} "
\
f
"FROM official_web.news_info {conds_str} "
\
f
"ORDER BY pub_time DESC, id LIMIT {page_size} OFFSET {offsets};"
articles
=
await
conn
.
fetchall
(
sql
)
return
total
,
articles
...
...
unify_api/modules/qkadmin/views/contact_us.py
View file @
5fbd8156
...
...
@@ -14,9 +14,10 @@ from unify_api.modules.qkadmin.service.contact_us_srv import (
@
summary
(
"联系我们记录"
)
async
def
post_contact_records
(
request
,
body
:
ContactsReq
)
->
ContactsRsp
:
page_num
=
int
(
body
.
page_num
)
page_size
=
int
(
body
.
page_size
)
total
,
records
=
await
load_contact_records
(
page_num
,
page_size
)
pg_num
=
int
(
body
.
page_num
)
pg_size
=
int
(
body
.
page_size
)
s_dts
,
e_dts
=
body
.
start_time
,
body
.
end_time
total
,
records
=
await
load_contact_records
(
pg_num
,
pg_size
,
s_dts
,
e_dts
)
contacts
=
[
ContactInfo
(
id
=
r
[
"id"
],
user_name
=
r
[
"user_name"
],
tele
=
r
[
"tele"
],
company
=
r
[
"company"
],
msg
=
r
[
"msg"
],
create_time
=
str
(
r
[
"create_time"
]),
...
...
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