Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nfc_storage
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
冯佳佳
nfc_storage
Commits
b6e29a4d
Commit
b6e29a4d
authored
May 08, 2021
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口错误提示优化
parent
04107188
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
17 deletions
+24
-17
app.py
+1
-1
app/api/repair.py
+13
-5
blueprint/__init__.py
+0
-11
utils/return_code.py
+10
-0
No files found.
app.py
View file @
b6e29a4d
...
...
@@ -17,4 +17,4 @@ logger = logging.getLogger(__name__)
app
=
create_app
(
'production'
)
# app = create_app(os.getenv('RUN_ENV', 'development'))
app
.
run
(
'127.0.0.1'
,
8888
)
app
.
run
(
'127.0.0.1'
,
8888
,
debug
=
True
)
app/api/repair.py
View file @
b6e29a4d
...
...
@@ -14,7 +14,7 @@ from flask import Blueprint, request
from
app
import
db
from
models.Repairs
import
PowerRepairModel
from
utils.return_code
import
BASE_RESPONSE
,
PARAMS_INVALID
from
utils.return_code
import
BASE_RESPONSE
,
PARAMS_INVALID
,
DUPLICATE_RECORD
,
SQL_ERROR
logger
=
logging
.
getLogger
(
__name__
)
repair
=
Blueprint
(
'repair'
,
__name__
)
...
...
@@ -28,17 +28,25 @@ def update_repair():
repair_man
=
request
.
values
.
get
(
"repair_man"
,
None
)
index
=
request
.
values
.
get
(
"index"
,
None
)
if
not
nfc_id
or
not
power_sn
or
not
repair_content
or
not
repair_man
:
if
not
nfc_id
or
not
power_sn
or
not
repair_content
or
not
repair_man
or
int
(
index
)
>
5
:
return
BASE_RESPONSE
(
**
PARAMS_INVALID
)
logger
.
info
(
'======================='
)
result
=
PowerRepairModel
.
query
.
filter_by
(
power_sn
=
power_sn
,
index
=
index
)
.
first
()
if
result
:
return
BASE_RESPONSE
(
**
DUPLICATE_RECORD
)
model
=
PowerRepairModel
()
model
.
power_sn
=
power_sn
model
.
nfc_id
=
nfc_id
model
.
repair_content
=
repair_content
model
.
repair_man
e
=
repair_man
model
.
repair_man
=
repair_man
model
.
index
=
index
db
.
session
.
add
(
model
)
result
=
db
.
session
.
commit
()
try
:
db
.
session
.
add
(
model
)
db
.
session
.
commit
()
except
Exception
as
e
:
logger
.
info
(
e
)
return
BASE_RESPONSE
(
**
SQL_ERROR
)
return
BASE_RESPONSE
()
...
...
blueprint/__init__.py
deleted
100644 → 0
View file @
04107188
#!usr/bin/env python
#-*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@time: 2021/03/25
@file: __init__.py.py
@function:
@modify:
"""
\ No newline at end of file
utils/return_code.py
View file @
b6e29a4d
...
...
@@ -21,7 +21,17 @@ class BASE_RESPONSE(Response):
Response
.
__init__
(
self
,
result
,
mimetype
=
'application/json'
)
SQL_ERROR
=
{
"error_code"
:
9001
,
"error_message"
:
"SQL execute error"
}
PARAMS_INVALID
=
{
"error_code"
:
1001
,
"error_message"
:
"params invalid"
}
DUPLICATE_RECORD
=
{
"error_code"
:
1002
,
"error_message"
:
"duplicate record"
}
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