20
20
from backend .common .security .permission import RequestPermission
21
21
from backend .common .security .rbac import DependsRBAC
22
22
from backend .database .db import CurrentSession
23
- from backend .utils .serializers import select_as_dict , select_list_serialize
24
23
25
24
router = APIRouter ()
26
25
27
26
28
27
@router .get ('/all' , summary = '获取所有角色' , dependencies = [DependsJwtAuth ])
29
28
async def get_all_roles () -> ResponseSchemaModel [list [GetRoleDetail ]]:
30
- roles = await role_service .get_all ()
31
- data = select_list_serialize (roles )
29
+ data = await role_service .get_all ()
32
30
return response_base .success (data = data )
33
31
34
32
35
33
@router .get ('/{pk}/all' , summary = '获取用户所有角色' , dependencies = [DependsJwtAuth ])
36
34
async def get_user_all_roles (pk : Annotated [int , Path (...)]) -> ResponseSchemaModel [list [GetRoleDetail ]]:
37
- roles = await role_service .get_by_user (pk = pk )
38
- data = select_list_serialize (roles )
35
+ data = await role_service .get_by_user (pk = pk )
39
36
return response_base .success (data = data )
40
37
41
38
@@ -53,8 +50,7 @@ async def get_role_all_rules(pk: Annotated[int, Path(...)]) -> ResponseSchemaMod
53
50
54
51
@router .get ('/{pk}' , summary = '获取角色详情' , dependencies = [DependsJwtAuth ])
55
52
async def get_role (pk : Annotated [int , Path (...)]) -> ResponseSchemaModel [GetRoleDetail ]:
56
- role = await role_service .get (pk = pk )
57
- data = GetRoleDetail (** select_as_dict (role ))
53
+ data = await role_service .get (pk = pk )
58
54
return response_base .success (data = data )
59
55
60
56
0 commit comments