diff --git a/server/models.py b/server/models.py index 066cd40..5734fe3 100644 --- a/server/models.py +++ b/server/models.py @@ -59,7 +59,7 @@ class CooperationMindShare(AbstractModel): """ 分享记录表 """ - coop_mind = models.ForeignKey(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE) + coop_mind = models.OneToOneField(to="CooperationMind", to_field="id", verbose_name="脑图ID", on_delete=models.CASCADE) coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=128, null=False, blank=False) 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) diff --git a/server/urls.py b/server/urls.py index 8bbb9eb..5cb4d54 100644 --- a/server/urls.py +++ b/server/urls.py @@ -23,7 +23,7 @@ urlpatterns = [ path('d', JsMindView.as_view()), # 获得导图详情 path('s_d', JsMindShareView.as_view()), # 获得导图详情 path('delete', JsMindView.as_view()), # 删除思维导图 - path('share', JsMindShareView.as_view()), # 分享思维导图 + path('share', JsMindShareView.as_view()), # 分享思维导图,查询等 # --------------------------------------------------- path('register', MindUserView.as_view()), # 用户注册 diff --git a/server/views/mind_map.py b/server/views/mind_map.py index 17cda07..90b9947 100644 --- a/server/views/mind_map.py +++ b/server/views/mind_map.py @@ -127,6 +127,9 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView): """ share_uuid_hash = request.GET.get('h') share_uuid = request.GET.get('u') + coop_mind_id = request.GET.get('coop_mind_id') + user = request.user + # if share_uuid_hash is not None and share_uuid is not None: share = CooperationMindShare.objects.filter(share_uuid_hash=share_uuid_hash, share_uuid=share_uuid).first() if share is None: @@ -136,8 +139,15 @@ class JsMindShareView(LoginRequiredJSONMixin, ListAPIView): mind = CooperationMind.objects.filter(id=share.coop_mind_id).first() serializer = CooperationMindSerializer(mind) return build_response(data=serializer.data) + elif coop_mind_id is not None: + # 查询分享信息 + share = CooperationMindShare.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).first() + if share is None: + return build_response(code=CODE_FAILED, msg='分享不存在') + serializer = CooperationMindShareSerializer(share) + return build_response(data=serializer.data) else: - user = request.user + # 查询列表 self.queryset = CooperationMindShare.objects.filter(operator_user_id=user.id).all() return self.list(request, *args, **kwargs) diff --git a/static/html/dashboard.html b/static/html/dashboard.html index 423fb7e..c4ec91e 100644 --- a/static/html/dashboard.html +++ b/static/html/dashboard.html @@ -113,7 +113,7 @@ 分享` } else if (src_page === 'share') { sub_btn = `取消分享 - 查看分享链接` + 查看分享链接` } const content = `
@@ -230,6 +230,26 @@ async: false }); }, + /**获得分享信息*/ + fetch_share_info: function (mind_id) { + const me = this + $.ajax({ + type: "get", + url: "share", + headers: {"X-CSRFToken": $.cookie("csrftoken")}, + data: {'coop_mind_id': mind_id}, + dataType: "json", + success: function (resp) { + if (me.is_success_resp(resp)) { + const data = resp.data + me.show_share_url(data.share_uuid, data.share_uuid_hash) + } else { + common_alert(resp.msg) + } + }, + async: false + }); + }, is_success_resp(resp) { return resp.code === 0 },