文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit d07e169a by 李景熙

修改Task,User

parent 6450f073
from peewee import * from peewee import *
import datetime import datetime
import math import math
from Dao import User
mysql = MySQLDatabase( mysql = MySQLDatabase(
'sys', 'sys',
...@@ -57,10 +58,11 @@ def find_task_by_name(task_name, start, num): ...@@ -57,10 +58,11 @@ def find_task_by_name(task_name, start, num):
index = 0 index = 0
list = [] list = []
while index < len(find) and index < num: while index < len(find) and index < num:
user = User.get_username(find[index+start].publish_id)
list.append( list.append(
{ {
'id': find[index+start].task_id, 'id': find[index+start].task_id,
'creator': find[index+start].publish_id, 'creator': user,
'name': find[index+start].task_name, 'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S") 'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
} }
...@@ -79,10 +81,11 @@ def find_task(start, num): ...@@ -79,10 +81,11 @@ def find_task(start, num):
index = 0 index = 0
list = [] list = []
while index < len(find) and index < num: while index < len(find) and index < num:
user = User.get_username(find[index + start].publish_id)
list.append( list.append(
{ {
'id': find[index+start].task_id, 'id': find[index+start].task_id,
'creator': find[index+start].publish_id, 'creator': user,
'name': find[index+start].task_name, 'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S") 'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
} }
...@@ -101,10 +104,11 @@ def find_task_by_creator(creator, start, num): ...@@ -101,10 +104,11 @@ def find_task_by_creator(creator, start, num):
index = 0 index = 0
list = [] list = []
while index < len(find) and index < num: while index < len(find) and index < num:
user = User.get_username(find[index + start].publish_id)
list.append( list.append(
{ {
'id': find[index+start].task_id, 'id': find[index+start].task_id,
'creator': find[index+start].publish_id, 'creator': user,
'name': find[index+start].task_name, 'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S") 'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
} }
......
...@@ -166,6 +166,14 @@ def find_id(id): ...@@ -166,6 +166,14 @@ def find_id(id):
return 1 return 1
def get_username(id):
try:
tmp = User.get(User.usrId == id)
except:
return tmp
else:
return tmp.userName
if __name__ == '__main__': if __name__ == '__main__':
register('456', '456', '456') register('456', '456', '456')
set_type(4, 1) set_type(4, 1)
......
...@@ -32,3 +32,9 @@ def get_tasks(): ...@@ -32,3 +32,9 @@ def get_tasks():
} }
} }
return json.dumps(res) return json.dumps(res)
@task.route("/createTask", methods=["Post"])
def create_task():
data = request.get_json(silent=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment