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

Commit 5690afa1 by 李景熙

修改选择分片后端

parent 9d9dc147
......@@ -23,7 +23,7 @@ class Relation(Model):
flag = BooleanField(default=False) # 代表该标注关系是否被标注
score = IntegerField(default=0)
receive_time = DateTimeField(default=datetime.datetime.now())
complete_time = DateTimeField()
complete_time = DateTimeField(null=True)
class Meta:
database = mysql
......@@ -32,10 +32,10 @@ class Relation(Model):
# 创建标注关系
def create_relation(slice_id, user_id, data_id):
try:
Slice.add_annotation(slice_id)
Slice.add_file(slice_id)
relation = Relation(slice_id=slice_id, user_id=user_id, data_id=data_id)
relation.save()
except Exception:
except:
return Result(0, "create failed", {})
else:
return Result(1, "create success", {})
......
......@@ -23,13 +23,23 @@ def get_pieces():
@slice.route("/selectPieces", methods=["Post"])
def select_pieces():
# 接收前端传回的用户id与分片列表,将每个分片下的每一个文件创建一个relation
userId = request.args['userId']
selected = request.args['selected']
print("select_pieces")
data = request.get_json(silent=True)
userId = int(data['userId'])
selected = list(data['selected'])
for sliceItem in selected:
dataList = Data.find_data_by_slice(sliceItem)
ret = Data.find_data_by_slice(sliceItem)
if ret.code == 0:
res = {
'code': ret.code,
'message': ret.message,
'data': ret.data
}
return json.dumps(res)
dataList = ret.data
for dataItem in dataList:
ret = Relation.create_relation(sliceItem, userId, dataItem)
dataId = dataItem['id']
ret = Relation.create_relation(sliceItem, userId, dataId)
if ret.code == 0:
res = {
'code': ret.code,
......
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