add the ticket agent list api route
parent
45a4792730
commit
2d389a3f2d
|
@ -104,7 +104,7 @@ api = falcon.App(middleware=[cors.middleware, MultipartMiddleware()])
|
|||
# Get Ticket Type
|
||||
api.add_route('/ticket/types',
|
||||
ticket.TicketTypeCollection())
|
||||
# Get Ticket List
|
||||
# Get Ticket List: all
|
||||
api.add_route('/ticket/list',
|
||||
ticket.TicketListCollection())
|
||||
|
||||
|
@ -112,6 +112,9 @@ api.add_route('/ticket/list',
|
|||
api.add_route('/ticket/apply/{id_}',
|
||||
ticket.TicketApplicationCollection())
|
||||
|
||||
# Get Ticket List: My Agent
|
||||
api.add_route('/ticket/agent/list',
|
||||
ticket.TicketAggentListCollection())
|
||||
########################################################################################################################
|
||||
# Routes for System Core
|
||||
########################################################################################################################
|
||||
|
|
|
@ -293,6 +293,68 @@ class TicketApplicationCollection:
|
|||
resp.location = '/tickets/' + str(new_ticket_id)
|
||||
|
||||
|
||||
class TicketAggentListCollection:
|
||||
@staticmethod
|
||||
def __init__():
|
||||
""""Initializes ContactCollection"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def on_options(req, resp):
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
@staticmethod
|
||||
def on_get(req, resp):
|
||||
cnx = mysql.connector.connect(**config.loonflow)
|
||||
cursor = cnx.cursor()
|
||||
|
||||
query = (" SELECT id, name "
|
||||
" FROM workflow_workflow "
|
||||
" ORDER BY id ")
|
||||
cursor.execute(query)
|
||||
workflow_rows = cursor.fetchall()
|
||||
|
||||
workflow_result = {}
|
||||
if workflow_rows is not None and len(workflow_rows) > 0:
|
||||
for row in workflow_rows:
|
||||
workflow_result[row[0]] = row[1]
|
||||
|
||||
query = (" SELECT id, name "
|
||||
" FROM workflow_state "
|
||||
" ORDER BY id ")
|
||||
cursor.execute(query)
|
||||
workflow_state_rows = cursor.fetchall()
|
||||
|
||||
workflow_state_result = {}
|
||||
if workflow_state_rows is not None and len(workflow_state_rows) > 0:
|
||||
for row in workflow_state_rows:
|
||||
workflow_state_result[row[0]] = row[1]
|
||||
|
||||
query = (" SELECT id, title, workflow_id, sn, state_id, creator, gmt_created, gmt_modified "
|
||||
" FROM ticket_ticketrecord "
|
||||
" ORDER BY id DESC")
|
||||
cursor.execute(query)
|
||||
rows = cursor.fetchall()
|
||||
cursor.close()
|
||||
cnx.close()
|
||||
|
||||
result = list()
|
||||
if rows is not None and len(rows) > 0:
|
||||
for row in rows:
|
||||
meta_result = {"id": row[0],
|
||||
"title": row[1],
|
||||
"ticket_type": workflow_result.get(row[2]),
|
||||
"sn": row[3],
|
||||
"state": workflow_state_result.get(row[4]),
|
||||
"creator": row[5],
|
||||
"gmt_created": str(row[6]),
|
||||
"gmt_modified": str(row[7])
|
||||
}
|
||||
result.append(meta_result)
|
||||
|
||||
resp.text = json.dumps(result)
|
||||
|
||||
|
||||
class ContactItem:
|
||||
@staticmethod
|
||||
def __init__():
|
||||
|
|
Loading…
Reference in New Issue