fixed the bug
parent
7988638473
commit
07e03395f3
|
@ -7,12 +7,14 @@ import re
|
||||||
from core.useractivity import user_logger, access_control
|
from core.useractivity import user_logger, access_control
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
BASE_API = 'http://172.16.203.116/'
|
||||||
|
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
url = "http://172.16.203.116/api/v1.0/login"
|
url = BASE_API + "/api/v1.0/login"
|
||||||
|
|
||||||
payload = json.dumps({
|
payload = json.dumps({
|
||||||
"username": "user",
|
"username": "admin",
|
||||||
"password": "123456",
|
"password": "123456",
|
||||||
"type": "account"
|
"type": "account"
|
||||||
})
|
})
|
||||||
|
@ -75,7 +77,37 @@ class TicketListCollection:
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
@staticmethod
|
@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)
|
cnx = mysql.connector.connect(**config.loonflow)
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
|
|
||||||
|
@ -103,8 +135,9 @@ class TicketListCollection:
|
||||||
|
|
||||||
query = (" SELECT id, title, workflow_id, sn, state_id, creator, gmt_created, gmt_modified "
|
query = (" SELECT id, title, workflow_id, sn, state_id, creator, gmt_created, gmt_modified "
|
||||||
" FROM ticket_ticketrecord "
|
" FROM ticket_ticketrecord "
|
||||||
|
" WHERE creator = %s "
|
||||||
" ORDER BY id DESC")
|
" ORDER BY id DESC")
|
||||||
cursor.execute(query)
|
cursor.execute(query, (user_name, ))
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.close()
|
cnx.close()
|
||||||
|
@ -251,6 +284,7 @@ class TicketApplicationItem:
|
||||||
"transition_id": 29,
|
"transition_id": 29,
|
||||||
"workflow_id": 4
|
"workflow_id": 4
|
||||||
}"""
|
}"""
|
||||||
|
print("id_", id_)
|
||||||
new_values = json.loads(raw_json)
|
new_values = json.loads(raw_json)
|
||||||
|
|
||||||
checked_fields = [
|
checked_fields = [
|
||||||
|
@ -277,7 +311,7 @@ class TicketApplicationItem:
|
||||||
payload = new_values
|
payload = new_values
|
||||||
|
|
||||||
session = login()
|
session = login()
|
||||||
url = 'http://172.16.203.116/api/v1.0/tickets'
|
url = BASE_API + "/api/v1.0/tickets"
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
}
|
}
|
||||||
|
@ -378,7 +412,7 @@ class TicketAgentListCollection:
|
||||||
" FROM ticket_ticketrecord "
|
" FROM ticket_ticketrecord "
|
||||||
" WHERE participant = %s "
|
" WHERE participant = %s "
|
||||||
" ORDER BY id DESC ")
|
" ORDER BY id DESC ")
|
||||||
cursor.execute(query, (user_name, ))
|
cursor.execute(query, (user_name,))
|
||||||
rows = cursor.fetchall()
|
rows = cursor.fetchall()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.close()
|
cnx.close()
|
||||||
|
|
Loading…
Reference in New Issue