fix: 修复角色列表用户数量字段为0的问题

pull/9551/head
Bai 2 years ago committed by Jiangjie.Bai
parent 44d3f88225
commit ac4a321225

@ -69,8 +69,10 @@ class RoleViewSet(JMSModelViewSet):
role.users_amount = role_user_amount_mapper.get(role.id, 0)
return queryset
def page_queryset(self, queryset):
queryset = super().page_queryset(queryset)
def paginate_queryset(self, queryset):
page_queryset = super().paginate_queryset(queryset) # 返回是 list 对象
page_queryset_ids = [str(i.id) for i in page_queryset]
queryset = queryset.filter(id__in=page_queryset_ids)
queryset = self.set_users_amount(queryset)
return queryset

@ -102,7 +102,7 @@ class Role(JMSBaseModel):
@lazyproperty
def users_amount(self):
return 0
return self.users.count()
@lazyproperty
def permissions_amount(self):

Loading…
Cancel
Save