add the list api

pull/141/MERGE^2
hyh123a 2022-04-17 14:39:08 +08:00
parent 6a1a313897
commit ac26381747
2 changed files with 57 additions and 9 deletions

View File

@ -101,9 +101,12 @@ cors = CORS(allow_all_origins=True,
api = falcon.App(middleware=[cors.middleware, MultipartMiddleware()])
# Get Ticket Type
api.add_route('/ticket/types',
ticket.TicketTypeCollection())
# Get Ticket List
api.add_route('/ticket/list',
ticket.TicketListCollection())
########################################################################################################################
# Routes for System Core
########################################################################################################################

View File

@ -22,10 +22,9 @@ class TicketTypeCollection:
cnx = mysql.connector.connect(**config.loonflow)
cursor = cnx.cursor()
query = (" SELECT id, name, uuid, "
" email, phone, description "
" FROM tbl_contacts "
" ORDER BY name ")
query = (" SELECT id, name, description, display_form_str "
" FROM workflow_workflow "
" ORDER BY id ")
cursor.execute(query)
rows = cursor.fetchall()
cursor.close()
@ -36,15 +35,61 @@ class TicketTypeCollection:
for row in rows:
meta_result = {"id": row[0],
"name": row[1],
"uuid": row[2],
"email": row[3],
"phone": row[4],
"description": row[5]}
"description": row[2],
"display_form_str": row[3]}
result.append(meta_result)
resp.text = json.dumps(result)
class TicketListCollection:
@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, title, workflow_id, sn, state_id, creator, gmt_created, gmt_modified "
" FROM ticketed_ticketrecord "
" ORDER BY id ")
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],
"workflow_name": workflow_result.get(row[2]),
"sn": row[3],
"state_id": row[4],
"creator": row[5],
"gmt_created": row[6],
"gmt_modified": row[7]
}
result.append(meta_result)
resp.text = json.dumps(result)
class ContactItem:
@staticmethod