"""岗位下拉选项(基础数据与报表筛选共用)。 岗位管理本身仅管理员可用(FR-006),但报表的「岗位」筛选对财务/领导 开放(FR-029)。为避免把管理接口整体放开,这里提供只读、登录即可的 启用岗位选项;写操作仍走 `/system/business-roles` 的管理员端点。 """ from typing import Annotated from fastapi import APIRouter, Depends from app.api.deps import DbSession, get_current_user from app.core.response import ApiResponse, ok from app.models import User from app.repositories import business_role_repository router = APIRouter(prefix="/business-roles", tags=["人员管理"]) # 基础数据是业务操作:登录即可,不要求管理员 CurrentUser = Annotated[User, Depends(get_current_user)] @router.get("/options", response_model=ApiResponse[list[dict]], summary="岗位下拉选项") def list_options(session: DbSession, _: CurrentUser) -> ApiResponse[list[dict]]: """岗位选项(登录即可;含停用——人员档案可能仍引用停用岗位)。 岗位规模有限(内置 + 自定义),一次取足够上限,不做分页。 """ roles = business_role_repository.list_roles(session, offset=0, limit=1000) return ok( [ { "id": role.id, "role_code": role.role_code, "role_name": role.role_name, "status": role.status, } for role in roles ] )