modify the ticket agent list api
parent
0aa5db7547
commit
b9b0264837
|
@ -113,7 +113,7 @@ api.add_route('/ticket/apply/{id_}',
|
|||
ticket.TicketApplicationCollection())
|
||||
|
||||
# Get Ticket List: My Agent
|
||||
api.add_route('/ticket/agent/list',
|
||||
api.add_route('/ticket/list/agent',
|
||||
ticket.TicketAgentListCollection())
|
||||
########################################################################################################################
|
||||
# Routes for System Core
|
||||
|
|
|
@ -304,7 +304,37 @@ class TicketAgentListCollection:
|
|||
resp.status = falcon.HTTP_200
|
||||
|
||||
@staticmethod
|
||||
def on_get(req, resp):
|
||||
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']
|
||||
|
||||
cnx = mysql.connector.connect(**config.loonflow)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
|
@ -332,8 +362,9 @@ class TicketAgentListCollection:
|
|||
|
||||
query = (" SELECT id, title, workflow_id, sn, state_id, creator, gmt_created, gmt_modified "
|
||||
" FROM ticket_ticketrecord "
|
||||
" ORDER BY id DESC")
|
||||
cursor.execute(query)
|
||||
" WHERE participant = %s "
|
||||
" ORDER BY id DESC ")
|
||||
cursor.execute(query, (user_name, ))
|
||||
rows = cursor.fetchall()
|
||||
cursor.close()
|
||||
cnx.close()
|
||||
|
|
Loading…
Reference in New Issue