feat: 角色管理
This commit is contained in:
@@ -62,8 +62,8 @@ async def role_put(pk: int, data: RoleIn) -> Response:
|
||||
|
||||
async def role_query(query: RoleQuery) -> Response[ListAll[list[RoleRead]]]:
|
||||
"""post条件查询角色表"""
|
||||
limit = query.size
|
||||
skip = (query.offset - 1) * limit
|
||||
del query.offset, query.size
|
||||
users, count = await get_roles(skip, limit, query.dict())
|
||||
size = query.limit
|
||||
skip = (query.offset - 1) * size
|
||||
del query.offset, query.limit
|
||||
users, count = await get_roles(skip, size, query.dict())
|
||||
return Response(data=ListAll(total=count, items=users))
|
||||
|
@@ -38,7 +38,7 @@ async def get_roles(skip: int, limit: int, kwargs: dict = None):
|
||||
kwargs = {f"{k}__contains": v for k, v in kwargs.items()}
|
||||
else:
|
||||
kwargs = {}
|
||||
result = RoleModel.filter(status__not=9, **kwargs).all().order_by("-created")
|
||||
result = RoleModel.filter(**kwargs).all().order_by("-created")
|
||||
return await result.offset(skip).limit(limit), await result.count()
|
||||
|
||||
|
||||
|
BIN
backend/mini.db
BIN
backend/mini.db
Binary file not shown.
BIN
backend/mini.db-shm
Normal file
BIN
backend/mini.db-shm
Normal file
Binary file not shown.
BIN
backend/mini.db-wal
Normal file
BIN
backend/mini.db-wal
Normal file
Binary file not shown.
@@ -157,7 +157,9 @@ routes = [
|
||||
summary="查询角色拥有权限",
|
||||
**has_perm
|
||||
),
|
||||
Route.put("/role", endpoint=role_put, tags=["角色管理"], summary="角色更新", **has_perm),
|
||||
Route.put(
|
||||
"/role/{pk}", endpoint=role_put, tags=["角色管理"], summary="角色更新", **has_perm
|
||||
),
|
||||
Route.post(
|
||||
"/role/query", endpoint=role_query, tags=["角色管理"], summary="角色条件查询", **has_perm
|
||||
),
|
||||
|
@@ -247,7 +247,7 @@ params = [
|
||||
type=2,
|
||||
component=None,
|
||||
pid=4,
|
||||
identifier="",
|
||||
identifier="role:query",
|
||||
api="/role/query",
|
||||
method="POST",
|
||||
).dict(),
|
||||
@@ -276,7 +276,7 @@ params = [
|
||||
component=None,
|
||||
pid=4,
|
||||
identifier="role:update",
|
||||
api="/role",
|
||||
api="/role/{pk}",
|
||||
method="PUT",
|
||||
).dict(),
|
||||
),
|
||||
|
Reference in New Issue
Block a user