优化查询用户接口,加入返回权限

This commit is contained in:
27942
2025-12-25 11:18:48 +08:00
parent a13b5c3c9f
commit d2ce4f478a

View File

@@ -268,7 +268,7 @@ class PersonnelListView(APIView):
Q_obj &= Q(username__icontains=username)
if department:
Q_obj &= Q(department__username__icontains=department)
users = User.objects.prefetch_related('department').filter(Q_obj)
users = User.objects.prefetch_related('department', 'role').filter(Q_obj).order_by('-id')
total = len(users)
paginator = Paginator(users, per_page)
@@ -289,6 +289,7 @@ class PersonnelListView(APIView):
"IdCard": info.card, # 身份证
"mobilePhone": info.mobilePhone, # 手机号
"department": list(info.department.values('id', 'username')),
"role": list(info.role.values('id', 'RoleName', 'permissionId')), # 角色信息
"position": info.position, # 岗位
"team": info.team, # 所属团队
"Dateofjoining": info.Dateofjoining, # 入职时间