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

Commit 95703c75 by 李景熙

添加查找我的任务列表功能

parent 18ba6e9a
......@@ -41,7 +41,17 @@ def create_relation(slice_id, user_id, data_id):
return Result(1, "create success", {})
def find_slice_by_executor(user_id):
try:
slice_list = Relation.select(Relation.slice_id).where(Relation.user_id == user_id)
except:
return False
else:
return slice_list
if __name__ == '__main__':
Relation.drop_table()
Relation.create_table()
# Relation.drop_table()
# Relation.create_table()
print(Relation.select(Relation.slice_id).where(Relation.user_id == 1)[0].slice_id)
# create_relation(3, 1, 2)
......@@ -168,6 +168,16 @@ def find_task_by_slice(slice_id):
return s.task_id
# 通过一个sliceid数组查找taskid
def find_task_by_slicelist(slice_list):
try:
task_list = Slice.select(Slice.task_id).where(Slice.slice_id << slice_list)
except:
return False
else:
return task_list
if __name__ == '__main__':
Slice.drop_table()
Slice.create_table()
from peewee import *
import datetime
import math
from Dao import User
from Dao import User, Relation, Slice
from Dao.model import mysql
......@@ -42,7 +42,7 @@ def create_task(publish_id, task_name):
return Result(1, "create success", task.task_id, 0)
# 根据任务名称查找任务
# 根据任务名称查找任务(任务大厅搜索功能)
def find_task_by_name(task_name, start, num):
try:
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(Task.task_name.contains(task_name))
......@@ -65,7 +65,7 @@ def find_task_by_name(task_name, start, num):
return Result(1, "find success", list, math.ceil(len(find)/num))
# 查找所有任务
# 查找所有任务(用于任务大厅界面)
def find_task(start, num):
try:
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time)
......@@ -88,10 +88,85 @@ def find_task(start, num):
return Result(1, "find success", list, math.ceil(len(find)/num))
# 查找与该发布者相关的任务
# 查找与该发布者相关的任务(用于我的发布界面,可对任务进行修改删除)
def find_task_by_creator(creator, start, num):
try:
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(Task.publish_id == creator)
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(
Task.publish_id == creator, Task.task_state == 0)
index = 0
list = []
while index < len(find) and index < num:
user = User.get_username(find[index + start].publish_id)
list.append(
{
'id': find[index+start].task_id,
'creator': user,
'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
}
)
index += 1
except:
return Result(0, "find failed", {}, 0)
else:
return Result(1, "find success", list, math.ceil(len(find)/num))
# 寻找发布者发布的需要审核的任务
def find_task_check(creator, start, num):
try:
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(
Task.publish_id == creator, Task.task_state == 2)
index = 0
list = []
while index < len(find) and index < num:
user = User.get_username(find[index + start].publish_id)
list.append(
{
'id': find[index+start].task_id,
'creator': user,
'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
}
)
index += 1
except:
return Result(0, "find failed", {}, 0)
else:
return Result(1, "find success", list, math.ceil(len(find)/num))
# 寻找已完成任务
def find_task_completed(executor, start, num):
try:
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(
Task.task_state == 3)
index = 0
list = []
while index < len(find) and index < num:
user = User.get_username(find[index + start].publish_id)
list.append(
{
'id': find[index+start].task_id,
'creator': user,
'name': find[index+start].task_name,
'date': find[index+start].publish_time.strftime("%Y-%m-%d %H:%M:%S")
}
)
index += 1
except:
return Result(0, "find failed", {}, 0)
else:
return Result(1, "find success", list, math.ceil(len(find)/num))
# 寻找标注者选择的任务
def find_task_my_task(executor, start, num):
try:
slice_list = Relation.find_slice_by_executor(executor)
task_list = Slice.find_task_by_slicelist(slice_list)
find = Task.select(Task.task_id, Task.task_name, Task.publish_id, Task.publish_time).where(
Task.task_id << task_list)
index = 0
list = []
while index < len(find) and index < num:
......@@ -166,6 +241,6 @@ def set_state(task_id, state):
if __name__ == '__main__':
# delete_task(10)
Task.drop_table()
Task.create_table()
find_task_my_task(1,1,1)
# Task.drop_table()
# Task.create_table()
......@@ -20,7 +20,19 @@ def get_tasks():
if keyword:
ret = Task.find_task_by_name(keyword, pagesize*(currentpage-1), pagesize)
elif creator:
ret = Task.find_task_by_creator(creator, pagesize * (currentpage - 1), pagesize)
if state:
ret = Task.find_task_check(creator, pagesize * (currentpage - 1), pagesize)
print("checking")
else:
ret = Task.find_task_by_creator(creator, pagesize * (currentpage - 1), pagesize)
print("wodefabu")
elif executor:
if state:
ret = Task.find_task_completed(executor, pagesize * (currentpage - 1), pagesize)
print("completed")
else:
ret = Task.find_task_my_task(executor, pagesize * (currentpage - 1), pagesize)
print("woderenwu")
else:
ret = Task.find_task(pagesize*(currentpage-1), pagesize)
res = {
......
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