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

Commit 560f1263 by 李景熙

添加选择分片后端

parent 12fe970a
...@@ -35,10 +35,10 @@ def create_relation(slice_id, user_id, data_id): ...@@ -35,10 +35,10 @@ def create_relation(slice_id, user_id, data_id):
Slice.add_annotation(slice_id) Slice.add_annotation(slice_id)
relation = Relation(slice_id=slice_id, user_id=user_id, data_id=data_id) relation = Relation(slice_id=slice_id, user_id=user_id, data_id=data_id)
relation.save() relation.save()
except: except Exception:
return 0 return Result(0, "create failed", {})
else: else:
return 1 return Result(1, "create success", {})
# 根据用户id找寻标注关系 # 根据用户id找寻标注关系
...@@ -46,9 +46,9 @@ def find_relationbyuserid(user_id): ...@@ -46,9 +46,9 @@ def find_relationbyuserid(user_id):
try: try:
p = Relation.get(Relation.user_id == user_id) p = Relation.get(Relation.user_id == user_id)
except Exception: except Exception:
print(0) return Result(0, "find failed", {})
else: else:
print(p.email) return Result(1, "find success", p.email)
# 根据数据id找标注关系 # 根据数据id找标注关系
...@@ -58,9 +58,9 @@ def find_relationbydataid(data_id): ...@@ -58,9 +58,9 @@ def find_relationbydataid(data_id):
try: try:
p = Relation.get(Relation.data_id == data_id) p = Relation.get(Relation.data_id == data_id)
except Exception: except Exception:
print(0) return Result(0, "find failed", {})
else: else:
print(p.email) return Result(1, "find success", p.email)
if __name__ == '__main__': if __name__ == '__main__':
......
import json import json
from flask import Blueprint from flask import Blueprint
from flask import request from flask import request
from Dao import Slice, Relation from Dao import Data, Slice, Relation
slice = Blueprint("slice", __name__, url_prefix="/api/slice") slice = Blueprint("slice", __name__, url_prefix="/api/slice")
...@@ -19,7 +19,27 @@ def get_pieces(): ...@@ -19,7 +19,27 @@ def get_pieces():
return json.dumps(res) return json.dumps(res)
# # 用户选择想要标注的分片后,后端接收信息的接口 # 用户选择想要标注的分片后,后端接收信息的接口
# @slice.route("/selectPieces", methods=["Post"]) @slice.route("/selectPieces", methods=["Post"])
# def select_pieces(): def select_pieces():
# # 接收前端传回的用户id与分片列表,将每个分片下的每一个文件创建一个relation # 接收前端传回的用户id与分片列表,将每个分片下的每一个文件创建一个relation
userId = request.args['userId']
selected = request.args['selected']
print("select_pieces")
for sliceItem in selected:
dataList = Data.find_data_by_slice(sliceItem)
for dataItem in dataList:
ret = Relation.create_relation(sliceItem, userId, dataItem)
if ret.code == 0:
res = {
'code': ret.code,
'message': ret.message,
'data': ret.data
}
return json.dumps(res)
res = {
'code': 1,
'message': "ok",
}
return json.dumps(res)
\ No newline at end of file
...@@ -51,7 +51,7 @@ def create_task(): ...@@ -51,7 +51,7 @@ def create_task():
i = 0 i = 0
print(data) print(data)
while i < len(data['task']['domains']): while i < len(data['task']['domains']):
s = Slice.create_text_slice(tid, data['task']['domains'][i]['piecesOptions']) s = Slice.create_text_slice(tid, data['task']['domains'][i]['textModel'])
j = 0 j = 0
while j < len(data['task']['domains'][i]['fileList']): while j < len(data['task']['domains'][i]['fileList']):
Data.create_data(s.data, data['task']['domains'][i]['fileList'][j]['name'], Data.create_data(s.data, data['task']['domains'][i]['fileList'][j]['name'],
......
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