Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
f4424504
Commit
f4424504
authored
Jan 12, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
913ea867
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
+34
-12
myapps/pc_management/api/place_portal.py
+34
-12
No files found.
myapps/pc_management/api/place_portal.py
View file @
f4424504
...
@@ -28,22 +28,44 @@ def run_place_list():
...
@@ -28,22 +28,44 @@ def run_place_list():
:return:
:return:
"""
"""
json_data
=
request
.
get_json
()
page
=
json_data
.
get
(
"page"
,
None
)
page_size
=
json_data
.
get
(
"pageSize"
,
None
)
keyword
=
json_data
.
get
(
"keyword"
,
None
)
admin
=
g
.
user
admin
=
g
.
user
admin_place_list
=
AdminPlace
.
query
.
filter_by
(
user_id
=
admin
.
id
,
status
=
1
)
.
all
()
select_sql
=
"select place.place_name, place.address, place.parent_id,place.status, place.id "
if
admin_place_list
:
count_sql
=
"select count(place.id) as total_count"
place_id_list
=
[
i
.
place_id
for
i
in
admin_place_list
]
from_sql
=
" from place where place.id in ( select place_id from admin_place where admin_place.user_id = {} and admin_place.status = 1) "
.
format
(
else
:
admin
.
id
)
return
BaseResponse
(
data
=
[])
where_sql
=
" "
if
keyword
:
where_sql
+=
"""
and CONCAT(place.place_name, place.address) LIKE '
%
{keyword}
%
'
place_list
=
db
.
session
.
query
(
Place
)
.
filter
(
Place
.
id
.
in_
(
place_id_list
))
.
all
()
"""
.
format
(
keyword
=
keyword
)
order_sql
=
" ORDER BY place.id ASC, place.status ASC"
limit_sql
=
" LIMIT {offset} , {page_size} "
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
if
place_list
:
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
place_data_list
=
[
{
"place_name"
:
i
.
place_name
,
"place_id"
:
i
.
id
,
"address"
:
i
.
address
,
"parent_id"
:
i
.
parent_id
}
for
i
in
if
not
count_result
:
place_list
]
return
BaseResponse
(
data
=
{
"list"
:
[],
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
0
})
return
BaseResponse
(
data
=
place_data_list
)
else
:
else
:
return
BaseResponse
(
data
=
[])
total_count
=
count_result
.
total_count
print
(
select_sql
+
from_sql
+
where_sql
+
order_sql
+
limit_sql
)
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
return_data
=
[]
for
info
in
result
:
return_data
.
append
(
{
"place_name"
:
info
.
place_name
,
"place_id"
:
info
.
id
,
"address"
:
info
.
address
,
"parent_id"
:
info
.
parent_id
,
"status"
:
info
.
status
})
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
@place_route.route
(
"add_place"
,
methods
=
[
"POST"
])
@place_route.route
(
"add_place"
,
methods
=
[
"POST"
])
...
...
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