This commit is contained in:
2024-04-23 10:10:27 +08:00
parent 35966f9914
commit a2091b7180
8 changed files with 103 additions and 25 deletions
+68 -19
View File
@@ -30,6 +30,9 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
查询思维导图
"""
pk = request.GET.get('id')
print("-----------------------------")
print(pk)
print("-----------------------------")
# 页面源
page_tag = request.GET.get('s_p')
user = request.user
@@ -39,29 +42,69 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
select_id = json.loads(user.select_xiaozu)['xiaozu']
print(select_id[0])
print('list current user: %s' % user)
if pk is not None:
# 查询导图详细 查看用户是否有权限
sql = """
select * from cooperation_mind mind where id=%s and mind.class_id =%s
""" % (pk, select_id[0])
# sql = """
# select * from cooperation_mind mind where id=%s and mind.class_id=%s
# union all select m1.* from cooperation_mind m1 join cooperation_mind_share sh on sh.coop_mind_id = m1.id where m1.id=%s and sh.operator_user_id =%s
# union all select m1.* from cooperation_mind m1 join cooperation_mind_star st on st.coop_mind_id = m1.id where m1.id=%s and st.operator_user_id =%s
# """ % (pk, select_id, pk, select_id, pk, select_id)
mind = CooperationMind.objects.raw(sql)
if len(mind) is None:
return build_response(code=CODE_FAILED, msg="无权限")
# 序列化
serializer = CooperationMindSerializer(mind[0])
return build_response(data=serializer.data)
# if pk is not None:
# # 查询导图详细 查看用户是否有权限
# sql = """
# select * from cooperation_mind mind where id=%s and mind.class_id =%s
#
# """ % (pk, select_id[0])
# # sql = """
# # select * from cooperation_mind mind where id=%s and mind.class_id=%s
# # union all select m1.* from cooperation_mind m1 join cooperation_mind_share sh on sh.coop_mind_id = m1.id where m1.id=%s and sh.operator_user_id =%s
# # union all select m1.* from cooperation_mind m1 join cooperation_mind_star st on st.coop_mind_id = m1.id where m1.id=%s and st.operator_user_id =%s
# # """ % (pk, select_id, pk, select_id, pk, select_id)
# mind = CooperationMind.objects.raw(sql)
# if len(mind) is None:
# return build_response(code=CODE_FAILED, msg="无权限")
# # 序列化
# serializer = CooperationMindSerializer(mind[0])
# print("--------------------------")
# print("--------------------------")
# print("--------------------------")
# print("--------------------------")
# print(serializer)
# print("--------------------------")
# print("--------------------------")
# print("--------------------------")
# print("--------------------------")
# return build_response(data=serializer.data)
# 查询列表
if 'b9b101e' == page_tag:
# belong_to = []
old_class = json.loads(user.select_class)['class']
old_xiaozu = json.loads(user.select_xiaozu)['xiaozu']
# for select_class,select_xiaozu in (old_class,old_xiaozu):
# belong_to = ["class1","class2"]
# ["class1"]
# new_belong = json.dumps({'belong': belong_to})
# 我的文件
self.queryset = CooperationMind.objects.filter(class_id=select_id[0], deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
aa = []
zipped_lists = zip(old_class, old_xiaozu)
for select_class,select_xiaozu in zipped_lists:
belong_to = []
belong_to.append(str(select_class + str(select_xiaozu)))
new_belong = json.dumps({'belong': belong_to})
print(new_belong)
aa.append(CooperationMind.objects.filter(belong_to=new_belong, deleted=0).values('id', 'coop_mind_name',
"client_uuid",
"data_format"))
# queryset.save()
# for i in range(len(aa) - 1):
# if i == 0:
# bb = str(aa[i])
# bb = bb + "|" + str(aa[i + 1])
if len(aa) -1 == 0:
self.queryset = aa[0]
else:
for i in range(len(aa) -1):
if i == 0:
self.queryset = aa[i]
self.queryset = self.queryset | aa[i + 1]
print("=============================")
print(self.queryset)
print("=============================")
elif 'share' == page_tag:
# 我的分享
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'), operator_user_id=user.id)
@@ -102,12 +145,18 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
data_format = 'node_tree'
test_id = 0
for item1, item2 in zipped_lists:
if (CooperationMind.objects.filter(coop_mind_name=str(item1 + "第" + str(item2) + "小组")).exists()):
print("==========================================================")
continue
print("--------------------------------------------------")
print(item1, item2)
test = []
test.append(item1+str(item2))
# new_belong = json.dumps({'belong': belong_to})
mind = CooperationMind(coop_mind_name=str(item1 + "第" + str(item2) + "小组"), client_uuid='',
mind_log_id=-1,
creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA,
data_format=data_format)
data_format=data_format,belong_to=json.dumps({'belong':test}))
mind.save()
test_id = mind.id
return build_response(data=test_id)