modify the ticket list api

pull/141/head
hyh123a 2022-04-21 13:33:23 +08:00
parent e04b6d2634
commit 38decf7cbb
1 changed files with 2 additions and 30 deletions

View File

@ -403,37 +403,9 @@ class TicketCompletedListCollection:
resp.status = falcon.HTTP_200 resp.status = falcon.HTTP_200
@staticmethod @staticmethod
def on_post(req, resp): def on_get(req, resp):
try:
raw_json = req.stream.read().decode('utf-8')
except Exception as ex:
raise falcon.HTTPError(falcon.HTTP_400, title='API.ERROR', description=ex)
"""
{
"user_name": "admin",
}"""
new_values = json.loads(raw_json)
checked_fields = [
{
"name": "user_name",
"type": str
},
]
for field in checked_fields:
_name = field['name']
_type = field['type']
if _name not in new_values.keys() or \
not isinstance(new_values[_name], _type) or \
len(str(new_values[_name])) == 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_FIELD' + _name)
payload = new_values
user_name = payload['user_name']
user_name = req.get_param('username')
cnx = mysql.connector.connect(**config.loonflow) cnx = mysql.connector.connect(**config.loonflow)
cursor = cnx.cursor() cursor = cnx.cursor()