更新model
This commit is contained in:
+2
-2
@@ -79,7 +79,7 @@ class CooperationMindStar(AbstractModel):
|
||||
"""
|
||||
收藏记录表
|
||||
"""
|
||||
user_id = models.BigIntegerField(verbose_name='收藏人', null=False)
|
||||
operator_user_id = models.BigIntegerField(verbose_name='收藏人', null=False)
|
||||
coop_mind = models.ForeignKey(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)
|
||||
|
||||
@@ -88,6 +88,6 @@ class CooperationMindStar(AbstractModel):
|
||||
class Meta:
|
||||
db_table = 'cooperation_mind_star'
|
||||
indexes = [
|
||||
models.Index(fields=['user_id'], ),
|
||||
models.Index(fields=['operator_user_id'], ),
|
||||
]
|
||||
verbose_name = "协作分享表"
|
||||
|
||||
@@ -49,10 +49,10 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
if 'b9b101e' == src_page:
|
||||
self.queryset = CooperationMind.objects.filter(creator_user_id=user.id, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
elif 'share' == src_page:
|
||||
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'))
|
||||
share = CooperationMindShare.objects.filter(coop_mind_id=OuterRef('id'), operator_user_id=user.id)
|
||||
self.queryset = CooperationMind.objects.annotate(share_col=Exists(share), ).filter(share_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
elif 'star' == src_page:
|
||||
star = CooperationMindStar.objects.filter(coop_mind_id=OuterRef('id'))
|
||||
star = CooperationMindStar.objects.filter(coop_mind_id=OuterRef('id'), operator_user_id=user.id)
|
||||
self.queryset = CooperationMind.objects.annotate(star_col=Exists(star), ).filter(star_col=1, deleted=0).values('id', 'coop_mind_name', "client_uuid", "data_format")
|
||||
else:
|
||||
# 不返回数据
|
||||
@@ -75,6 +75,7 @@ class JsMindView(LoginRequiredJSONMixin, ListAPIView):
|
||||
pk = request.POST.get('id')
|
||||
source = request.POST.get('source')
|
||||
user = request.user
|
||||
res = None
|
||||
if source == 'dashboard':
|
||||
res = CooperationMind.objects.filter(id=pk, creator_user_id=user.id).update(deleted=True)
|
||||
elif source == 'recycle':
|
||||
@@ -221,8 +222,8 @@ class JsMindStarView(LoginRequiredJSONMixin, ListAPIView):
|
||||
if mind is None:
|
||||
return build_response(CODE_FAILED, msg="导图不存在")
|
||||
|
||||
star = CooperationMindStar.objects.filter(user_id=user.id, coop_mind_id=coop_mind_id).first()
|
||||
star = CooperationMindStar.objects.filter(operator_user_id=user.id, coop_mind_id=coop_mind_id).first()
|
||||
if star is None:
|
||||
star = CooperationMindStar(user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||
star = CooperationMindStar(operator_user_id=user.id, coop_mind_id=coop_mind_id, coop_mind_name=mind.coop_mind_name)
|
||||
star.save()
|
||||
return build_response()
|
||||
|
||||
Reference in New Issue
Block a user