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