Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tour_business
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
0
Merge Requests
0
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
魏强
tour_business
Commits
1896b8aa
Commit
1896b8aa
authored
Feb 19, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spot_info接口重写
parent
a839326f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
3 deletions
+56
-3
Controller/SpotController.py
+56
-3
No files found.
Controller/SpotController.py
View file @
1896b8aa
# -*- coding: utf-8 -*-
import
datetime
from
flask
import
Blueprint
,
jsonify
,
g
,
request
from
Libs.ErrorTips
import
BASE_RESPONSE
from
Model.Base
import
db
from
Service.SpotService
import
SpotService
route_spot
=
Blueprint
(
'spot'
,
__name__
)
# @route_spot.route('/spot_info')
# def all_spot_info():
# info = SpotService.get_spot_info()
# return jsonify(BASE_RESPONSE(data=info).to_dict())
@route_spot.route
(
'/spot_info'
)
def
all_spot_info
():
info
=
SpotService
.
get_spot_info
()
return
jsonify
(
BASE_RESPONSE
(
data
=
info
)
.
to_dict
())
def
all_spot_info_new
():
sql
=
"""
SELECT
s.id AS spot_id,
s.spotname,
aa.id AS agent_id,
aa.user_name,
aa.phone,
aa.level
FROM
spot s
LEFT JOIN
agent_spot ass ON s.id = ass.spot_no and ass.status=1
LEFT JOIN
agent_account aa ON ass.agent_no = aa.id
"""
infos
=
db
.
session
.
execute
(
sql
)
.
fetchall
()
spot_info
=
{}
agent_info
=
{}
for
info
in
infos
:
cur_info
=
{}
if
agent_info
.
get
(
info
.
phone
,
None
)
is
None
:
agent_info
[
info
.
phone
]
=
[{
"spot_id"
:
info
.
spot_id
,
"spot_name"
:
info
.
spotname
}]
else
:
agent_info
[
info
.
phone
]
.
append
({
"spot_id"
:
info
.
spot_id
,
"spot_name"
:
info
.
spotname
})
if
spot_info
.
get
(
info
.
spotname
,
None
)
is
None
:
cur_info
[
'id'
]
=
info
.
spot_id
cur_info
[
'letter'
]
=
SpotService
.
get_pinyin
(
info
.
spotname
)
cur_info
[
'spotname'
]
=
info
.
spotname
cur_info
[
'agent_info'
]
=
[{
"agent_name"
:
info
.
user_name
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"spot_info"
:
agent_info
[
info
.
phone
]
}]
spot_info
[
info
.
spotname
]
=
cur_info
else
:
tmp_data
=
{
"agent_name"
:
info
.
user_name
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"spot_info"
:
agent_info
[
info
.
phone
]
}
spot_info
[
info
.
spotname
][
'agent_info'
]
.
append
(
tmp_data
)
data
=
list
(
spot_info
.
values
())
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
@route_spot.route
(
'/spot_machine_list'
,
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