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

Commit 5eb47d72 by 李景熙

限制用户多次选择同一文件

parent 2a80221f
...@@ -31,9 +31,11 @@ class Relation(Model): ...@@ -31,9 +31,11 @@ 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) r = Relation.get(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) if not r:
relation.save() Slice.add_annotation(slice_id)
relation = Relation(slice_id=slice_id, user_id=user_id, data_id=data_id)
relation.save()
except: except:
return Result(0, "create failed", {}) return Result(0, "create failed", {})
else: else:
...@@ -215,7 +217,8 @@ def get_relation_id(uid, did): ...@@ -215,7 +217,8 @@ def get_relation_id(uid, did):
if __name__ == '__main__': if __name__ == '__main__':
Relation.drop_table() # Relation.drop_table()
Relation.create_table() # Relation.create_table()
Relation.delete().where(Relation.relation_id == 67).execute()
# print(get_state(1, 5)) # print(get_state(1, 5))
# create_relation(3, 1, 2) # create_relation(3, 1, 2)
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