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
87f3a1e5
Commit
87f3a1e5
authored
Mar 07, 2024
by
ZZH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add contact 2024-03-6
parent
371ea1de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
0 deletions
+74
-0
contact_us_cps.py
unify_api/modules/qkadmin/components/contact_us_cps.py
+31
-0
contact_us_srv.py
unify_api/modules/qkadmin/service/contact_us_srv.py
+19
-0
contact_us.py
unify_api/modules/qkadmin/views/contact_us.py
+24
-0
No files found.
unify_api/modules/qkadmin/components/contact_us_cps.py
0 → 100644
View file @
87f3a1e5
# -*- coding:utf-8 -*-
"""
DATE:2024/3/7 11:00
"""
from
dataclasses
import
dataclass
from
pot_libs.sanic_api
import
Model
from
pot_libs.sanic_api.column
import
Opt
,
Int
,
Str
,
List
@
dataclass
class
ContactsReq
(
Model
):
page_num
:
int
=
Int
(
"页码"
)
.
eg
(
1
)
page_size
:
int
=
Opt
(
Int
(
"条数"
)
.
eg
(
10
))
@
dataclass
class
ContactInfo
(
Model
):
id
:
int
=
Opt
(
Int
(
"ID"
)
.
eg
(
1
))
user_name
:
str
=
Opt
(
Str
(
"姓名"
)
.
eg
(
"ZZH"
))
tele
:
str
=
Opt
(
Str
(
"电话号码"
)
.
eg
(
"10000"
))
email
:
str
=
Opt
(
Str
(
"电子邮箱"
)
.
eg
(
"hu.jiayi@qkupower.com"
))
company
:
str
=
Opt
(
Str
(
"公司名称"
)
.
eg
(
"清科优能"
))
msg
:
int
=
Opt
(
Str
(
"留言"
)
.
eg
(
"来!一个电话、一个扫码,一个全新的合作机会!"
))
create_time
:
str
=
Str
(
"时间"
)
.
eg
(
"2024-12-29 18:06"
)
@
dataclass
class
ContactsRsp
(
Model
):
total
:
int
=
Int
(
"联系总数"
)
.
eg
(
99
)
contacts
:
list
=
List
(
"联系列表"
)
.
items
(
ContactInfo
)
unify_api/modules/qkadmin/service/contact_us_srv.py
0 → 100644
View file @
87f3a1e5
# -*- coding:utf-8 -*-
"""
DATE:2024/3/7 11:08
"""
from
pot_libs.mysql_util.mysql_util
import
MysqlUtil
async
def
load_contact_records
(
page_num
,
page_size
):
offsets
=
0
if
page_num
==
0
else
(
page_num
-
1
)
*
page_size
async
with
MysqlUtil
(
db
=
"official_web"
)
as
conn
:
sql
=
"SELECT count(*) FROM official_web.contact_record;"
total
=
await
conn
.
fetch_value
(
sql
)
sql
=
f
"SELECT * FROM official_web.contact_record "
\
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/views/contact_us.py
0 → 100644
View file @
87f3a1e5
# -*- coding:utf-8 -*-
"""
DATE:2024/3/7 10:55
"""
from
pot_libs.sanic_api
import
summary
from
unify_api.modules.qkadmin.components.contact_us_cps
import
(
ContactsReq
,
ContactsRsp
,
ContactInfo
)
from
unify_api.modules.qkadmin.service.contact_us_srv
import
(
load_contact_records
)
@
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
)
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"
]),
email
=
r
[
"email"
])
for
r
in
records
]
return
ContactsRsp
(
total
=
total
,
contacts
=
contacts
)
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