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

Commit 20524ed2 by 李景熙

修改Data中函数的返回

parent 8510e7fd
......@@ -2,6 +2,17 @@ from peewee import *
from Dao.model import mysql
class Result:
code: int
message: []
data: {}
def __init__(self, code, message, data):
self.code = code
self.message = message
self.data = data
class Data(Model):
data_id = AutoField(primary_key=True, unique=True)
slice_id = IntegerField(null=False)
......@@ -17,9 +28,9 @@ def create_data(slice_id, url):
data = Data(slice_id=slice_id, url=url)
data.save()
except Exception:
print(0)
return Result(0, "create failed", {})
else:
print(1)
return Result(1, "create success", {})
# 根据数据id寻找数据url
......@@ -27,11 +38,10 @@ def find_data(id):
try:
data = Data.get(Data.data_id == id)
except Exception:
print(0)
return Result(0, "find failed", {})
else:
print(data.url)
return Result(1, "find success", data.url)
if __name__ == '__main__':
Data.drop_table()
Data.create_table()
......@@ -3,6 +3,7 @@ from Dao import Task
from peewee import *
from Dao.model import mysql
class Result:
code: int
message: []
......@@ -76,7 +77,8 @@ def delete_slice(id):
# 查找某任务下的分片
def find_slice_by_task(task_id):
try:
find = Slice.select(Slice.slice_id, Slice.document_number, Slice.type, Slice.model_id).where(Slice.task_id == task_id)
find = Slice.select(Slice.slice_id, Slice.document_number, Slice.type, Slice.model_id).where(
Slice.task_id == task_id)
index = 0
list = []
while index < len(find):
......
......@@ -4,6 +4,7 @@ import math
from Dao import User
from Dao.model import mysql
class Result:
code: int
message: []
......
......@@ -164,6 +164,7 @@ def get_username(id):
else:
return tmp.userName
if __name__ == '__main__':
User.create_table()
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