fix location

This commit is contained in:
root 2019-07-10 10:49:57 +08:00
parent ac8aa11068
commit 2b28947bea
3 changed files with 4 additions and 1 deletions

Binary file not shown.

View File

@ -24,7 +24,7 @@ class Location(Resource):
self.args = parser.parse_args() self.args = parser.parse_args()
def get(self): def get(self):
sql = f"select id,gameid,area,type from localtion where in_used=1" sql = f"select id,gameid,area,type from location where in_used=1;"
try: try:
data = mydb.query(sql) data = mydb.query(sql)
except Exception: except Exception:
@ -39,6 +39,7 @@ class Location(Resource):
localtion['id'], localtion['gameid'], localtion['area'], localtion['type'] = line localtion['id'], localtion['gameid'], localtion['area'], localtion['type'] = line
all_data.append(localtion) all_data.append(localtion)
del localtion del localtion
return jsonify({'code': 200,'message': all_data})
else: else:
log.error(f"{data} not found in mysql !") log.error(f"{data} not found in mysql !")
return jsonify({'code': 404}) return jsonify({'code': 404})
@ -91,6 +92,8 @@ class Location(Resource):
def delete(self): def delete(self):
id = self.args['id'] id = self.args['id']
if not id:
return jsonify({'code':500,'message':'id not found'})
try: try:
del_sql = f'delete from location where id={id};' del_sql = f'delete from location where id={id};'
mydb.query(del_sql) mydb.query(del_sql)