(session: SessionDep, trans: Trans, pageNum: int, pageSize: int, variable: SystemVariable)
| 54 | |
| 55 | |
| 56 | async def list_page(session: SessionDep, trans: Trans, pageNum: int, pageSize: int, variable: SystemVariable): |
| 57 | pagination = PaginationParams(page=pageNum, size=pageSize) |
| 58 | paginator = Paginator(session) |
| 59 | filters = {} |
| 60 | |
| 61 | if variable.name is None: |
| 62 | stmt = select(SystemVariable).order_by(SystemVariable.type.desc(), SystemVariable.name.asc()) |
| 63 | else: |
| 64 | stmt = select(SystemVariable).where( |
| 65 | and_(SystemVariable.name.ilike(f'%{variable.name}%'), SystemVariable.type != 'system')).order_by( |
| 66 | SystemVariable.type.desc(), SystemVariable.name.asc()) |
| 67 | |
| 68 | variable_page = await paginator.get_paginated_response( |
| 69 | stmt=stmt, |
| 70 | pagination=pagination, |
| 71 | **filters) |
| 72 | |
| 73 | res = [] |
| 74 | for r in variable_page.items: |
| 75 | data = SystemVariable(**r) |
| 76 | if data.type == 'system': |
| 77 | data.name = trans(data.name) |
| 78 | res.append(data) |
| 79 | |
| 80 | return {"items": res, "page": variable_page.page, "size": variable_page.size, "total": variable_page.total, |
| 81 | "total_pages": variable_page.total_pages} |
| 82 | |
| 83 | |
| 84 | def checkName(session: SessionDep, trans: Trans, variable: SystemVariable): |
no test coverage detected