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