添加用户组模块,修复相关问题若干
This commit is contained in:
@@ -22,7 +22,7 @@ async def broadcast(message):
|
||||
for ws in connected:
|
||||
await ws.send(message)
|
||||
|
||||
start_server = websockets.serve(handler, "localhost", 6789)
|
||||
start_server = websockets.serve(handler, "localhost", 9002)
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
asyncio.get_event_loop().run_forever()
|
||||
@@ -22,6 +22,7 @@ class CooperationMind(AbstractModel):
|
||||
mind_log_id = models.BigIntegerField(verbose_name='data对应的操作日志(cooperation_mind_log)ID', null=True, )
|
||||
data_format = models.CharField(verbose_name='数据格式化类型', max_length=32, null=False, blank=False)
|
||||
deleted = models.BooleanField(verbose_name='是否标记为软删除', default=False)
|
||||
class_id = models.IntegerField(verbose_name='脑图所属课程id', null=False, blank=False, default=1)
|
||||
|
||||
class Meta:
|
||||
db_table = 'cooperation_mind'
|
||||
|
||||
@@ -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):
|
||||
# 删除
|
||||
|
||||
@@ -17,6 +17,7 @@ class MindUser(AbstractUser):
|
||||
class_name = models.CharField(verbose_name='课程名称', max_length=64, null=True, blank=True)
|
||||
select_class = models.CharField(verbose_name='选择的课程', max_length=64, null=True, blank=True)
|
||||
select_xiaozu = models.CharField(verbose_name='选择的小组', max_length=64, null=True, blank=True)
|
||||
is_zuzhang = models.CharField(verbose_name='是否是组长', max_length=64, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'mind_user'
|
||||
|
||||
@@ -475,11 +475,8 @@
|
||||
|
||||
/**新建导图*/
|
||||
$('#new_mind_btn').click(function () {
|
||||
const mind_name = $('#mindName').val()
|
||||
if (!mind_name) {
|
||||
common_alert('请输入导图名称')
|
||||
return
|
||||
}
|
||||
const mind_name = "123"
|
||||
|
||||
|
||||
const post_data = {'mind_name': mind_name}
|
||||
$.ajax({
|
||||
@@ -663,7 +660,7 @@
|
||||
<main role="main" class="col-md-10 ml-sm-auto col-lg-10 px-md-4" id="main">
|
||||
<div style="margin-bottom: 0px;" class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h5 class="h5">全部文件</h5>
|
||||
<button id="newMindModal_btn" type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">新建导图</button>
|
||||
<button id="newMindModal_btn" type="button" class="btn btn-info" data-toggle="modal" data-target="#newMindModal">自动构建所有课程脑图结构</button>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<!--
|
||||
|
||||
@@ -641,8 +641,8 @@
|
||||
{#var uname = prompt('请输入用户名', 'user' + uuid(8, 16));#}
|
||||
var uname = document.getElementById('username').className
|
||||
console.log(uname)
|
||||
var ws = new WebSocket("ws://121.5.74.240:7101/");
|
||||
var ws = new WebSocket("ws://121.5.74.240:7101/");
|
||||
var ws = new WebSocket("ws://127.0.0.1:9001/");
|
||||
var ws = new WebSocket("ws://127.0.0.1:9001/");
|
||||
ws.onopen = function() {
|
||||
var data = "系统消息:建立连接成功";
|
||||
listMsg(data);
|
||||
|
||||
@@ -623,7 +623,7 @@
|
||||
<script src="/static/js/echarts.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
const ws = new WebSocket('ws://localhost:6789');
|
||||
const ws = new WebSocket('ws://localhost:9002');
|
||||
const editor = document.getElementById('editor');
|
||||
|
||||
ws.onopen = function(event) {
|
||||
|
||||
@@ -79,7 +79,7 @@ const modal = `
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">新建</h5>
|
||||
<h5 class="modal-title">构建协作脑图</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@@ -89,13 +89,11 @@ const modal = `
|
||||
<form>
|
||||
<div class="modal-body">
|
||||
<label for="mindName" class="sr-only"></label>
|
||||
<input type="text" id="mindName" class="form-control" placeholder="思维导图名称" autocomplete="off" required autofocus>
|
||||
|
||||
<div style="text-align:right;">
|
||||
<button type="button" class="btn btn-info" id="new_mind_btn">确认创建</button>
|
||||
<button type="button" class="btn btn-info" id="new_mind_btn">确认构建</button>
|
||||
</div>
|
||||
<div class="form-group form-check">
|
||||
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||
<label class="form-check-label" for="exampleCheck1">新建后打开</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -7,6 +7,7 @@ import json
|
||||
import websockets
|
||||
import re
|
||||
from zhipuai import ZhipuAI
|
||||
|
||||
async def gml_chat(messages):
|
||||
client = ZhipuAI(api_key="92a0e4868cda21d22fe6fd0f4c0bf6fb.oZ4IE9PPDOhsLKPp")
|
||||
|
||||
@@ -94,7 +95,7 @@ async def chat(websocket, path):
|
||||
# await asyncio.wait([user.send(message) for user in USERS.values()])
|
||||
|
||||
|
||||
start_server = websockets.serve(chat, "0.0.0.0", 4321)
|
||||
start_server = websockets.serve(chat, "0.0.0.0", 9001)
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
asyncio.get_event_loop().run_forever()
|
||||
Reference in New Issue
Block a user