add the list api
parent
6a1a313897
commit
ac26381747
|
@ -101,9 +101,12 @@ cors = CORS(allow_all_origins=True,
|
||||||
api = falcon.App(middleware=[cors.middleware, MultipartMiddleware()])
|
api = falcon.App(middleware=[cors.middleware, MultipartMiddleware()])
|
||||||
|
|
||||||
|
|
||||||
|
# Get Ticket Type
|
||||||
api.add_route('/ticket/types',
|
api.add_route('/ticket/types',
|
||||||
ticket.TicketTypeCollection())
|
ticket.TicketTypeCollection())
|
||||||
|
# Get Ticket List
|
||||||
|
api.add_route('/ticket/list',
|
||||||
|
ticket.TicketListCollection())
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
# Routes for System Core
|
# Routes for System Core
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
|
@ -22,10 +22,9 @@ class TicketTypeCollection:
|
||||||
cnx = mysql.connector.connect(**config.loonflow)
|
cnx = mysql.connector.connect(**config.loonflow)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
|
|
||||||
query = (" SELECT id, name, uuid, "
|
query = (" SELECT id, name, description, display_form_str "
|
||||||
" email, phone, description "
|
" FROM workflow_workflow "
|
||||||
" FROM tbl_contacts "
|
" ORDER BY id ")
|
||||||
" ORDER BY name ")
|
|
||||||
cursor.execute(query)
|
cursor.execute(query)
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
@ -36,15 +35,61 @@ class TicketTypeCollection:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
meta_result = {"id": row[0],
|
meta_result = {"id": row[0],
|
||||||
"name": row[1],
|
"name": row[1],
|
||||||
"uuid": row[2],
|
"description": row[2],
|
||||||
"email": row[3],
|
"display_form_str": row[3]}
|
||||||
"phone": row[4],
|
|
||||||
"description": row[5]}
|
|
||||||
result.append(meta_result)
|
result.append(meta_result)
|
||||||
|
|
||||||
resp.text = json.dumps(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:
|
class ContactItem:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue