(
session: SessionDep,
current_user: CurrentUser,
trans: Trans,
pageNum: int,
pageSize: int,
keyword: Optional[str] = Query(None, description="搜索关键字(可选)"),
oid: Optional[int] = Query(None, description="空间ID(仅admin用户生效)"),
)
| 84 | @router.get("/uws/pager/{pageNum}/{pageSize}", response_model=PaginatedResponse[WorkspaceUser], include_in_schema=False) |
| 85 | @require_permissions(permission=SqlbotPermission(role=['ws_admin'])) |
| 86 | async def pager( |
| 87 | session: SessionDep, |
| 88 | current_user: CurrentUser, |
| 89 | trans: Trans, |
| 90 | pageNum: int, |
| 91 | pageSize: int, |
| 92 | keyword: Optional[str] = Query(None, description="搜索关键字(可选)"), |
| 93 | oid: Optional[int] = Query(None, description="空间ID(仅admin用户生效)"), |
| 94 | ): |
| 95 | if not current_user.isAdmin and current_user.weight == 0: |
| 96 | raise Exception(trans('i18n_permission.no_permission', url = '', msg = '')) |
| 97 | if current_user.isAdmin: |
| 98 | workspace_id = oid if oid else current_user.oid |
| 99 | else: |
| 100 | workspace_id = current_user.oid |
| 101 | pagination = PaginationParams(page=pageNum, size=pageSize) |
| 102 | paginator = Paginator(session) |
| 103 | stmt = select(UserModel.id, UserModel.account, UserModel.name, UserModel.email, UserModel.status, UserModel.create_time, UserModel.oid, UserWsModel.weight).join( |
| 104 | UserWsModel, UserModel.id == UserWsModel.uid |
| 105 | ).where( |
| 106 | UserWsModel.oid == workspace_id, |
| 107 | UserModel.id != 1 |
| 108 | ).order_by(UserModel.account, UserModel.create_time) |
| 109 | |
| 110 | if keyword: |
| 111 | keyword_pattern = f"%{keyword}%" |
| 112 | stmt = stmt.where( |
| 113 | or_( |
| 114 | UserModel.account.ilike(keyword_pattern), |
| 115 | UserModel.name.ilike(keyword_pattern), |
| 116 | UserModel.email.ilike(keyword_pattern) |
| 117 | ) |
| 118 | ) |
| 119 | return await paginator.get_paginated_response( |
| 120 | stmt=stmt, |
| 121 | pagination=pagination, |
| 122 | ) |
| 123 | |
| 124 | |
| 125 | @router.post("/uws", summary=f"{PLACEHOLDER_PREFIX}ws_user_bind_api", description=f"{PLACEHOLDER_PREFIX}ws_user_bind_api") |
nothing calls this directly
no test coverage detected