update
This commit is contained in:
@@ -64,11 +64,13 @@ class CooperationMindShare(AbstractModel):
|
||||
share_uuid = models.CharField(verbose_name='分享uuid', max_length=128, null=False, blank=False)
|
||||
share_uuid_hash = models.BigIntegerField(verbose_name='分享uuid_hash', null=False, blank=False)
|
||||
share_end_time = models.DateTimeField(verbose_name='分享有效期', null=True)
|
||||
operator_user_id = models.BigIntegerField(verbose_name='分享操作人', null=False)
|
||||
|
||||
class Meta:
|
||||
db_table = 'cooperation_mind_share'
|
||||
indexes = [
|
||||
models.Index(fields=['share_uuid_hash'], ),
|
||||
models.Index(fields=['operator_user_id'], ),
|
||||
]
|
||||
verbose_name = "协作分享表"
|
||||
|
||||
|
||||
+4
-1
@@ -16,8 +16,9 @@ urlpatterns = [
|
||||
|
||||
# ---------------------------------------------------
|
||||
path('create', JsMindView.as_view()), # 创建思维导图
|
||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||
path('list', JsMindView.as_view()), # 查询思维导图
|
||||
path('delete', JsMindView.as_view()), # 删除思维导图
|
||||
path('share', JsMindShareView.as_view()), # 分享思维导图
|
||||
path(r'jsmind_op', JsMindLogView.as_view()), # 更新快照,get日志
|
||||
|
||||
# ---------------------------------------------------
|
||||
@@ -25,4 +26,6 @@ urlpatterns = [
|
||||
path('login', LoginView.as_view()), # 用户登录
|
||||
path('logout', LogoutView.as_view()), # 用户登出
|
||||
|
||||
# ---------------------------------------------------
|
||||
|
||||
]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
CODE_SUCCESS = 0
|
||||
CODE_FAILED = -1
|
||||
DUPLICATE = 1
|
||||
|
||||
snapshot_json_data = """{
|
||||
"id": "root",
|
||||
|
||||
@@ -11,6 +11,7 @@ from server.util.mix_util import build_response
|
||||
from server.pagination import DefaultNumberPagination
|
||||
from server_auth.lib.auth import LoginRequiredJSONMixin
|
||||
from server.util.constant_util import *
|
||||
import uuid
|
||||
|
||||
|
||||
class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
@@ -29,7 +30,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
"""
|
||||
pk = request.GET.get('id')
|
||||
user = request.user
|
||||
print(user)
|
||||
print('list current user: %s' % user)
|
||||
if pk is not None:
|
||||
mind = CooperationMind.objects.filter(id=pk).first()
|
||||
# 序列化
|
||||
@@ -97,3 +98,30 @@ class JsMindLogView(APIView):
|
||||
data_format = post_body.get('data_format')
|
||||
CooperationMind.objects.filter(id=coop_mind_id, mind_log_id__lt=coop_mind_log_id).update(data_format=data_format, snapshot_data=data, mind_log_id=coop_mind_log_id, update_time=dt.now(), client_uuid=client_uuid)
|
||||
return build_response()
|
||||
|
||||
|
||||
class JsMindShareView(LoginRequiredJSONMixin, APIView):
|
||||
"""
|
||||
分享脑图功能,只有创建人能分享
|
||||
"""
|
||||
|
||||
def post(self, request):
|
||||
post_body = request.POST
|
||||
id = post_body.get('id')
|
||||
user = request.user
|
||||
if id is None:
|
||||
return build_response(code=CODE_FAILED, msg='参数错误')
|
||||
mind = CooperationMind.objects.filter(id=id, creator_user_id=user.id).first()
|
||||
if mind is None:
|
||||
return build_response(code=CODE_FAILED, msg='导图不存在')
|
||||
|
||||
# 校验成功
|
||||
share = CooperationMindShare.objects.filter(coop_mind_id=mind.id, operator_user_id=user.id).first()
|
||||
if share is None:
|
||||
uuid_str = str(uuid.uuid4()).replace('-', "")
|
||||
share = CooperationMindShare(coop_mind_id=mind.id, coop_mind_name=mind.coop_mind_name, share_uuid=uuid_str, share_uuid_hash=-1, operator_user_id=user.id)
|
||||
share.save()
|
||||
return build_response(data=uuid_str)
|
||||
|
||||
# 重复分享
|
||||
return build_response(code=DUPLICATE, data=share.share_uuid)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
// 未登录
|
||||
if (!uid || isNaN(uid)) {
|
||||
$('#login_register').show()
|
||||
$('#login_register').click()
|
||||
$('#logout_a').hide()
|
||||
$('#newMindModal_btn').hide()
|
||||
} else {
|
||||
@@ -100,7 +101,7 @@
|
||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="window.open('detail?id=${item.id}')">编辑</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.del_mind(${item.id},'card_${uuid}')">删除</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);">分享</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="mind.share_mind(${item.id})">分享</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -165,6 +166,21 @@
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/**分享脑图*/
|
||||
share_mind: function (mind_id) {
|
||||
const me = this
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "share",
|
||||
headers: {"X-CSRFToken": $.cookie("csrftoken")},
|
||||
data: {'id': mind_id},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
},
|
||||
async: false
|
||||
});
|
||||
},
|
||||
/** 清除注册时输入内容 */
|
||||
clear_reg_info: function () {
|
||||
$('#userName').val('');
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.3 KiB |
Reference in New Issue
Block a user