添加用户组模块,修复相关问题若干
This commit is contained in:
@@ -12,6 +12,7 @@ from server.util.constant_util import *
|
||||
from server.util.mix_util import build_response
|
||||
from server_auth.lib.auth import LoginRequiredJSONMixin
|
||||
from django.db.models import Exists, OuterRef
|
||||
import json
|
||||
|
||||
|
||||
class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
@@ -35,14 +36,20 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
if page_tag is None or user.id is None:
|
||||
return build_response(code=CODE_FAILED, msg="参数错误")
|
||||
|
||||
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.creator_user_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, user.id, pk, user.id, pk, user.id)
|
||||
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="无权限")
|
||||
@@ -53,7 +60,8 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
# 查询列表
|
||||
if 'b9b101e' == page_tag:
|
||||
# 我的文件
|
||||
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
self.queryset = CooperationMind.objects.filter(class_id=select_id[0], deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
print(self.queryset)
|
||||
elif 'share' == page_tag:
|
||||
# 我的分享
|
||||
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'), operator_user_id=user.id)
|
||||
@@ -75,7 +83,14 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
创建思维导图
|
||||
"""
|
||||
user = request.user
|
||||
coop_mind_name = request.data.get('mind_name')
|
||||
# print(json.loads(user.select_class)['class'][0])
|
||||
class_name = json.loads(user.select_class)['class']
|
||||
select_id = json.loads(user.select_xiaozu)['xiaozu']
|
||||
# coop_mind_name = class_name
|
||||
# coop_mind_name = request.data.get('mind_name')
|
||||
# 使用zip函数将两个列表打包
|
||||
zipped_lists = zip(class_name, select_id)
|
||||
|
||||
coop_mind_id = request.data.get('coop_mind_id')
|
||||
op_type = request.data.get('op_type')
|
||||
|
||||
@@ -85,9 +100,17 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
else:
|
||||
user = request.user
|
||||
data_format = 'node_tree'
|
||||
mind = CooperationMind(coop_mind_name=coop_mind_name, client_uuid='', mind_log_id=-1, creator_user_id=user.id, snapshot_data=SNAPSHOT_JSON_DATA, data_format=data_format)
|
||||
mind.save()
|
||||
return build_response(data=mind.id)
|
||||
test_id = 0
|
||||
for item1, item2 in zipped_lists:
|
||||
print(item1, item2)
|
||||
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)
|
||||
mind.save()
|
||||
test_id = mind.id
|
||||
return build_response(data=test_id)
|
||||
|
||||
|
||||
def delete(self, request):
|
||||
# 删除
|
||||
|
||||
Reference in New Issue
Block a user