feat: 统一后端分页查询与前端服务层适配
后端新增通用分页模块,为报销单、员工、预算、agent 资产等 端点统一接入分页参数和游标查询,优化 repository 层分页实 现,前端服务层适配分页响应结构,完善预算图表和全局样式, 优化侧边栏和企业选择器组件,引入 Element Plus 插件注册。
This commit is contained in:
@@ -6,13 +6,14 @@ from sqlalchemy.orm import Session, selectinload
|
||||
from app.models.employee import Employee
|
||||
from app.models.organization import OrganizationUnit
|
||||
from app.models.role import Role
|
||||
from app.services.pagination import PageResult, paginate_select
|
||||
|
||||
|
||||
class EmployeeRepository:
|
||||
def __init__(self, db: Session) -> None:
|
||||
self.db = db
|
||||
|
||||
def list(self, status: str | None = None, keyword: str | None = None) -> list[Employee]:
|
||||
def _list_stmt(self, status: str | None = None, keyword: str | None = None):
|
||||
stmt = (
|
||||
select(Employee)
|
||||
.options(
|
||||
@@ -38,8 +39,23 @@ class EmployeeRepository:
|
||||
)
|
||||
)
|
||||
|
||||
return stmt
|
||||
|
||||
def list(self, status: str | None = None, keyword: str | None = None) -> list[Employee]:
|
||||
stmt = self._list_stmt(status=status, keyword=keyword)
|
||||
return list(self.db.execute(stmt).scalars().unique().all())
|
||||
|
||||
def list_page(
|
||||
self,
|
||||
*,
|
||||
status: str | None = None,
|
||||
keyword: str | None = None,
|
||||
page: int | None,
|
||||
page_size: int | None,
|
||||
) -> PageResult[Employee]:
|
||||
stmt = self._list_stmt(status=status, keyword=keyword)
|
||||
return paginate_select(self.db, stmt, page=page, page_size=page_size, unique=True)
|
||||
|
||||
def get(self, employee_id: str) -> Employee | None:
|
||||
stmt = (
|
||||
select(Employee)
|
||||
|
||||
Reference in New Issue
Block a user