Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tamp_course_order
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
tamp_course_order
Commits
0965e2ba
Commit
0965e2ba
authored
Nov 27, 2020
by
pengxiong@wealthgrow.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复
parent
231172c7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6683 additions
and
122 deletions
+6683
-122
engine.py
app/api/engine.py
+33
-0
errors.py
app/config/errors.py
+3
-1
order.py
app/controller/order.py
+4
-3
order_service.py
app/service/order_service.py
+121
-118
tamp_course_order.log
logs/tamp_course_order.log
+6522
-0
No files found.
app/api/engine.py
View file @
0965e2ba
...
...
@@ -22,6 +22,39 @@ CFG_FILEPATH = work_dir + '/app/config/config.yaml'
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
class
TAMP_SQL
(
object
):
"""[sqlalchemy 封装]
Args:
object ([type]): [description]
Returns:
[type]: [description]
"""
def
__init__
(
self
,
db_engine
):
# db = "mysql+mysqlconnector://root:password@localhost:3306/test"
# engine = create_engine(db)
# 创建DBSession类型:
self
.
DBSession
=
scoped_session
(
sessionmaker
(
bind
=
db_engine
))
def
__enter__
(
self
):
self
.
session
=
self
.
DBSession
()
return
self
.
session
def
__exit__
(
self
,
ext_type
,
exc_val
,
exc_tb
):
print
(
ext_type
)
self
.
session
.
commit
()
self
.
session
.
close
()
def
add
(
self
,
model
):
# model = User(id='5', name='Bob')
# 添加到session:
self
.
session
.
add
(
model
)
# 提交即保存到数据库:
self
.
session
.
commit
()
tamp_user_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_user_db'
],
...
...
app/config/errors.py
View file @
0965e2ba
...
...
@@ -17,6 +17,7 @@ class Errors:
APPLE_VOCHER_USED
=
'9005'
INPUT_PARAMS_ERROR
=
'9006'
REPEAT_BUY
=
'9007'
PROD_NOPRICE
=
'9008'
MSG
=
{
TOKEN_INVALID
:
'TOKEN失效'
,
...
...
@@ -25,5 +26,6 @@ class Errors:
TANGPU_BALANCE_NOT_ENOUGH
:
'探普币余额不足'
,
APPLE_VOCHER_USED
:
'该支付凭证已使用'
,
INPUT_PARAMS_ERROR
:
'入参错误'
,
REPEAT_BUY
:
'请勿重复购买商品'
REPEAT_BUY
:
'请勿重复购买商品'
,
PROD_NOPRICE
:
'商品未定价'
}
app/controller/order.py
View file @
0965e2ba
...
...
@@ -9,12 +9,13 @@
import
json
from
flask_restful
import
Resource
,
reqparse
from
flask
import
request
,
make_response
from
sqlalchemy.exc
import
InvalidRequestError
from
app.api
import
app
from
app.controller.errorhandler
import
CustomFlaskErr
from
app.config.errors
import
Errors
from
app.service
import
order_service
from
app.api.engine
import
logging
from
app.api.engine
import
logging
,
tamp_user_session
class
TopUpOrder
(
Resource
):
...
...
@@ -207,8 +208,8 @@ class AllOrders(Resource):
args
[
'user_id'
]
=
request
.
user_id
try
:
data
=
order_service
.
getAllOrders
(
args
)
except
Exception
as
e
:
logging
.
error
(
e
)
except
InvalidRequestError
:
tamp_user_session
.
rollback
(
)
resp
=
request
.
return_success
resp
[
'attributes'
]
=
data
return
resp
...
...
app/service/order_service.py
View file @
0965e2ba
This diff is collapsed.
Click to expand it.
logs/tamp_course_order.log
View file @
0965e2ba
This diff is collapsed.
Click to expand it.
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