(
session: SessionDep,
current_user: CurrentUser,
trans: Trans,
pageNum: int = Path(description=f"{PLACEHOLDER_PREFIX}page_num"),
pageSize: int = Path(description=f"{PLACEHOLDER_PREFIX}page_size"),
oid: int = Query(description=f"{PLACEHOLDER_PREFIX}oid"),
keyword: Optional[str] = Query(None, description=f"{PLACEHOLDER_PREFIX}keyword"),
)
| 20 | @router.get("/uws/option/pager/{pageNum}/{pageSize}", response_model=PaginatedResponse[UserWsOption], summary=f"{PLACEHOLDER_PREFIX}ws_user_grid_api", description=f"{PLACEHOLDER_PREFIX}ws_user_grid_api") |
| 21 | @require_permissions(permission=SqlbotPermission(role=['ws_admin'])) |
| 22 | async def option_pager( |
| 23 | session: SessionDep, |
| 24 | current_user: CurrentUser, |
| 25 | trans: Trans, |
| 26 | pageNum: int = Path(description=f"{PLACEHOLDER_PREFIX}page_num"), |
| 27 | pageSize: int = Path(description=f"{PLACEHOLDER_PREFIX}page_size"), |
| 28 | oid: int = Query(description=f"{PLACEHOLDER_PREFIX}oid"), |
| 29 | keyword: Optional[str] = Query(None, description=f"{PLACEHOLDER_PREFIX}keyword"), |
| 30 | ): |
| 31 | if not current_user.isAdmin: |
| 32 | raise Exception(trans('i18n_permission.no_permission', url = ", ", msg = trans('i18n_permission.only_admin'))) |
| 33 | if not oid: |
| 34 | raise Exception(trans('i18n_miss_args', key = '[oid]')) |
| 35 | pagination = PaginationParams(page=pageNum, size=pageSize) |
| 36 | paginator = Paginator(session) |
| 37 | stmt = select(UserModel.id, UserModel.account, UserModel.name).where( |
| 38 | ~exists().where(UserWsModel.uid == UserModel.id, UserWsModel.oid == oid), |
| 39 | UserModel.id != 1 |
| 40 | ).order_by(UserModel.account, UserModel.create_time) |
| 41 | |
| 42 | if keyword: |
| 43 | keyword_pattern = f"%{keyword}%" |
| 44 | stmt = stmt.where( |
| 45 | or_( |
| 46 | UserModel.account.ilike(keyword_pattern), |
| 47 | UserModel.name.ilike(keyword_pattern), |
| 48 | ) |
| 49 | ) |
| 50 | return await paginator.get_paginated_response( |
| 51 | stmt=stmt, |
| 52 | pagination=pagination, |
| 53 | ) |
| 54 | |
| 55 | @router.get("/uws/option", response_model=UserWsOption | None, include_in_schema=False) |
| 56 | @require_permissions(permission=SqlbotPermission(role=['ws_admin'])) |
nothing calls this directly
no test coverage detected