modify the ticket list api
parent
e04b6d2634
commit
38decf7cbb
|
@ -403,37 +403,9 @@ class TicketCompletedListCollection:
|
|||
resp.status = falcon.HTTP_200
|
||||
|
||||
@staticmethod
|
||||
def on_post(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']
|
||||
def on_get(req, resp):
|
||||
|
||||
user_name = req.get_param('username')
|
||||
cnx = mysql.connector.connect(**config.loonflow)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
|
|
Loading…
Reference in New Issue