25 lines
872 B
Python
25 lines
872 B
Python
"""民族码表(下拉检索)"""
|
|
from typing import Optional
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
from app.core.menu_guard import require_admin_or_super_admin
|
|
from app.core.response import success_response
|
|
from app.crud import ethnic as ethnic_svc
|
|
|
|
router = APIRouter(prefix="/web/admin", tags=["民族码表"])
|
|
|
|
|
|
@router.get("/ethnics")
|
|
async def list_ethnics_for_select(
|
|
keyword: Optional[str] = Query(None, description="民族名称模糊检索"),
|
|
limit: int = Query(200, ge=1, le=500),
|
|
_user: dict = Depends(require_admin_or_super_admin),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
"""返回民族码表选项(按排序号升序)。"""
|
|
rows = ethnic_svc.list_ethnics(db, keyword=keyword, limit=limit, user_info=_user)
|
|
return success_response({"list": rows})
|