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
d45046ef
Commit
d45046ef
authored
Apr 14, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增个人模块列表接口,mongodb相关代码提交
parent
29732f3e
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
3 deletions
+95
-3
Config/base_config.py
+4
-0
Config/common_config.py
+5
-1
Controller/AccountController.py
+19
-2
Libs/ErrorTips.py
+14
-0
MongoCollection/Modules/ModulesCollection.py
+22
-0
MongoCollection/__init__.py
+24
-0
app.py
+7
-0
No files found.
Config/base_config.py
View file @
d45046ef
...
@@ -4,8 +4,12 @@ import os
...
@@ -4,8 +4,12 @@ import os
is_prod
=
os
.
getenv
(
"RUN_ENV"
,
"test"
)
==
'prod'
is_prod
=
os
.
getenv
(
"RUN_ENV"
,
"test"
)
==
'prod'
if
is_prod
:
if
is_prod
:
SQLALCHEMY_DATABASE_URI
=
'mysql+pymysql://root:Boosal2014!!@sh-cdb-kzmpyjqw.sql.tencentcdb.com:63037/suishenwan'
SQLALCHEMY_DATABASE_URI
=
'mysql+pymysql://root:Boosal2014!!@sh-cdb-kzmpyjqw.sql.tencentcdb.com:63037/suishenwan'
MONGO_DATABASE_URI
=
"mongodb://suishenwan:Bk9w8Xu4@49.235.36.102:27017/suishenwan?authSource=admin&authMechanism=SCRAM-SHA-256"
MONGO_DATABASE_NAME
=
"suishenwan"
else
:
else
:
SQLALCHEMY_DATABASE_URI
=
'mysql+pymysql://root:N58uTiMT#tt*@sh-cdb-9yr5zhu0.sql.tencentcdb.com:61088/suishenwan'
SQLALCHEMY_DATABASE_URI
=
'mysql+pymysql://root:N58uTiMT#tt*@sh-cdb-9yr5zhu0.sql.tencentcdb.com:61088/suishenwan'
MONGO_DATABASE_URI
=
"mongodb://dev:aA5nD7fM@49.235.36.102:27017/dev?authSource=admin&authMechanism=SCRAM-SHA-256"
MONGO_DATABASE_NAME
=
"dev"
SECRET_KEY
=
"MgwuKKEcAk2UIaGxHAwnf38YvjvXMCqb"
SECRET_KEY
=
"MgwuKKEcAk2UIaGxHAwnf38YvjvXMCqb"
...
...
Config/common_config.py
View file @
d45046ef
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
import
os
import
os
is_prod
=
os
.
getenv
(
"RUN_ENV"
,
"test"
)
==
'prod'
is_prod
=
os
.
getenv
(
"RUN_ENV"
,
"test"
)
==
'prod'
# is_prod = True
ONENET_CONFIG
=
{
ONENET_CONFIG
=
{
"encoding_AES_key"
:
"XzHtYS3PbRiCDErEaztV286Cf4QmmL21T77tEY4Yb2m"
,
"encoding_AES_key"
:
"XzHtYS3PbRiCDErEaztV286Cf4QmmL21T77tEY4Yb2m"
,
"he_cloud_token"
:
"suishenwanonenettesttokenhecloud"
,
"he_cloud_token"
:
"suishenwanonenettesttokenhecloud"
,
...
@@ -96,3 +95,8 @@ TAKEOUT_TOOL_TIPS_PHONE = [
...
@@ -96,3 +95,8 @@ TAKEOUT_TOOL_TIPS_PHONE = [
# 挪出订单的景区对应编号
# 挪出订单的景区对应编号
move_spot_ids
=
{
16
:
50
,
42
:
51
,
48
:
49
}
move_spot_ids
=
{
16
:
50
,
42
:
51
,
48
:
49
}
PLATFORM
=
{
"xiaotu"
:
1
,
"xiaodaoyou"
:
2
}
Controller/AccountController.py
View file @
d45046ef
...
@@ -3,12 +3,14 @@ import base64
...
@@ -3,12 +3,14 @@ import base64
import
datetime
import
datetime
from
flask
import
Blueprint
,
jsonify
,
request
,
g
from
flask
import
Blueprint
,
jsonify
,
request
,
g
from
pymongo
import
MongoClient
from
Config.base_config
import
MONGO_DATABASE_URI
from
Config.common_config
import
LOGIN_TYPE
,
ACCOUNT_STATUS
from
Config.common_config
import
LOGIN_TYPE
,
ACCOUNT_STATUS
from
Libs.ErrorTips
import
TOKEN_NOT_VALID_ERROR
,
TOKEN_EXPIRE_ERROR
,
PHONE_NOT_NULL_ERROR
,
PHONE_NOT_VALID_ERROR
,
\
from
Libs.ErrorTips
import
TOKEN_NOT_VALID_ERROR
,
TOKEN_EXPIRE_ERROR
,
PHONE_NOT_NULL_ERROR
,
PHONE_NOT_VALID_ERROR
,
\
PHONE_NOT_PERMISSION
,
USER_NOT_EXIST
,
LOGIN_ERROR
,
VERIFICATION_CODE_INVALID_ERROR
,
VERIFICATION_CODE_ERROR
,
\
PHONE_NOT_PERMISSION
,
USER_NOT_EXIST
,
LOGIN_ERROR
,
VERIFICATION_CODE_INVALID_ERROR
,
VERIFICATION_CODE_ERROR
,
\
BASE_RESPONSE
,
ACCOUNT_ALREADY_EXISTS_ERROR
,
ACCOUNT_NOT_EXISTS_ERROR
,
ACCOUNT_AGENT_SPOT_NULL_ERROR
,
\
BASE_RESPONSE
,
ACCOUNT_ALREADY_EXISTS_ERROR
,
ACCOUNT_NOT_EXISTS_ERROR
,
ACCOUNT_AGENT_SPOT_NULL_ERROR
,
\
ACCOUNT_ALREADY_DELETE_ERROR
ACCOUNT_ALREADY_DELETE_ERROR
,
BASE_SUCCESS_RESPONSE
,
AGNET_MODULES_ERROR
from
Libs.Helper
import
Helper
from
Libs.Helper
import
Helper
from
Libs.Logger
import
logger
from
Libs.Logger
import
logger
from
Model.Agent.AgentAccountModel
import
AgentAccount
from
Model.Agent.AgentAccountModel
import
AgentAccount
...
@@ -197,7 +199,8 @@ def send_code():
...
@@ -197,7 +199,8 @@ def send_code():
return
jsonify
(
PHONE_NOT_VALID_ERROR
)
return
jsonify
(
PHONE_NOT_VALID_ERROR
)
sms
=
SMSService
()
sms
=
SMSService
()
sms
.
phoneSendCode
(
phone
,
92065
,
'灰兔智能'
)
result
=
sms
.
phoneSendCode
(
phone
,
92065
,
'灰兔智能'
)
logger
.
info
(
result
)
agent_log
=
AgentLogRecord
()
agent_log
=
AgentLogRecord
()
agent_log
.
phone
=
phone
agent_log
.
phone
=
phone
...
@@ -456,3 +459,17 @@ def login():
...
@@ -456,3 +459,17 @@ def login():
data
[
'spot_info'
]
=
AgentService
.
get_spot_info
(
agent_info
)
data
[
'spot_info'
]
=
AgentService
.
get_spot_info
(
agent_info
)
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
return
jsonify
(
BASE_RESPONSE
(
data
=
data
)
.
to_dict
())
@route_account.route
(
'/agent_module_list'
,
methods
=
[
'GET'
,
'POST'
])
def
get_agent_module_list
():
agent_id
=
g
.
user
.
id
platform
=
g
.
platform
mongodatabase
=
MongoClient
(
MONGO_DATABASE_URI
)
.
get_database
(
"suishenwan"
)
agent_modules
=
mongodatabase
.
get_collection
(
"agent_modules"
)
result
=
agent_modules
.
find_one
({
"agent_id"
:
agent_id
,
"platform"
:
platform
})
return_data
=
{
"agent_id"
:
agent_id
,
"module_list"
:
result
[
"module_list"
]}
if
result
:
return
BASE_SUCCESS_RESPONSE
(
data
=
return_data
)
else
:
return
BASE_SUCCESS_RESPONSE
(
**
AGNET_MODULES_ERROR
)
Libs/ErrorTips.py
View file @
d45046ef
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
flask
import
Response
from
flask.json
import
dumps
class
BASE_RESPONSE
(
object
):
class
BASE_RESPONSE
(
object
):
def
__init__
(
self
,
error_code
=
200
,
error_message
=
'Success'
,
data
=
None
):
def
__init__
(
self
,
error_code
=
200
,
error_message
=
'Success'
,
data
=
None
):
...
@@ -10,6 +13,12 @@ class BASE_RESPONSE(object):
...
@@ -10,6 +13,12 @@ class BASE_RESPONSE(object):
return
{
'error_code'
:
self
.
error_code
,
'error_message'
:
self
.
error_message
,
'data'
:
self
.
data
}
return
{
'error_code'
:
self
.
error_code
,
'error_message'
:
self
.
error_message
,
'data'
:
self
.
data
}
class
BASE_SUCCESS_RESPONSE
(
Response
):
def
__init__
(
self
,
data
=
None
,
error_code
=
0
,
error_message
=
'Success'
):
result
=
dumps
(
dict
(
data
=
data
,
error_code
=
error_code
,
error_message
=
error_message
))
Response
.
__init__
(
self
,
result
,
mimetype
=
'application/json'
)
TOKEN_NOT_VALID_ERROR
=
{
TOKEN_NOT_VALID_ERROR
=
{
"error_code"
:
1001
,
"error_code"
:
1001
,
"error_message"
:
"无效的token"
"error_message"
:
"无效的token"
...
@@ -135,6 +144,11 @@ OPERATE_ERROR = {
...
@@ -135,6 +144,11 @@ OPERATE_ERROR = {
"error_message"
:
"操作有误"
"error_message"
:
"操作有误"
}
}
AGNET_MODULES_ERROR
=
{
"error_code"
:
1404
,
"error_message"
:
"用户未绑定模块"
}
ACTION_CODE_ERROR
=
{
ACTION_CODE_ERROR
=
{
"error_code"
:
1501
,
"error_code"
:
1501
,
"error_message"
:
"退款操作码错误"
"error_message"
:
"退款操作码错误"
...
...
MongoCollection/Modules/ModulesCollection.py
0 → 100644
View file @
d45046ef
from
MongoCollection
import
BaseCollection
class
ModulesCollection
(
BaseCollection
):
__collectionname__
=
"modules"
class
AgentModulesCollection
(
BaseCollection
):
__collectionname__
=
"agent_modules"
if
__name__
==
'__main__'
:
modules
=
ModulesCollection
()
print
(
modules
.
collection
)
result
=
list
(
modules
.
collection
.
insert_one
({
"id"
:
8
,
"name"
:
"manual_return"
,
"platform"
:
2
,
"desc"
:
"我的账号-手动归还"
,
"parent_id"
:
3
}))
print
(
result
)
MongoCollection/__init__.py
0 → 100644
View file @
d45046ef
from
pymongo
import
MongoClient
from
Config.base_config
import
MONGO_DATABASE_URI
,
MONGO_DATABASE_NAME
client
=
MongoClient
(
MONGO_DATABASE_URI
)
db
=
client
[
MONGO_DATABASE_NAME
]
class
BaseCollection
(
object
):
__collectionname__
=
None
def
__init__
(
self
):
self
.
collection
=
db
.
get_collection
(
self
.
__collectionname__
)
# 自增函数
def
get_next_id
(
self
):
ret
=
db
[
"ids"
]
.
find_one_and_update
({
"id"
:
self
.
__collectionname__
},
{
"$inc"
:
{
"sequence"
:
1
}})
new
=
ret
[
"sequence"
]
return
new
def
insert_one
(
self
,
document
:
dict
,
bypass_document_validation
=
False
,
session
=
None
):
document
.
update
({
"id"
:
self
.
get_next_id
()})
self
.
collection
.
insert_one
(
document
,
bypass_document_validation
=
bypass_document_validation
,
session
=
session
)
app.py
View file @
d45046ef
from
flask
import
Flask
,
request
,
url_for
,
jsonify
,
g
from
flask
import
Flask
,
request
,
url_for
,
jsonify
,
g
from
flask_cors
import
CORS
from
flask_cors
import
CORS
from
Config.common_config
import
PLATFORM
from
Libs.ErrorTips
import
TOKEN_NOT_PROVIDER_ERROR
,
TOKEN_NOT_VALID_ERROR
,
TOKEN_EXPIRE_ERROR
from
Libs.ErrorTips
import
TOKEN_NOT_PROVIDER_ERROR
,
TOKEN_NOT_VALID_ERROR
,
TOKEN_EXPIRE_ERROR
from
Libs.Logger
import
logger
from
Libs.Logger
import
logger
from
Model.Agent.AgentAccountModel
import
AgentAccount
from
Model.Agent.AgentAccountModel
import
AgentAccount
...
@@ -43,6 +44,12 @@ def log_enter_interface():
...
@@ -43,6 +44,12 @@ def log_enter_interface():
@app.before_request
@app.before_request
def
get_platform
():
platform
=
request
.
headers
.
get
(
'platform'
,
None
)
g
.
platform
=
PLATFORM
.
get
(
platform
,
0
)
@app.before_request
def
verify_auth_token
():
def
verify_auth_token
():
'''
'''
用户登录验证token
用户登录验证token
...
...
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