Files
zlwuandCursor 31b0db6840 feat(bx): 报销可代选申请人,并放宽主数据选项的数据权限过滤
支持具备 changeApplicant 权限时代填申请人及发票/余额联动;系统/CRM/BX/PL 主数据与下拉选项改为仅租户隔离,避免「仅本人」导致空选项。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-25 23:27:23 +08:00

34 lines
961 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""民族码表 CRUD(全局 sys_ethnic)"""
from typing import Any, Dict, List, Optional
from sqlalchemy.orm import Session
from app.models.models import SysEthnic
def _row_to_dict(row: SysEthnic) -> Dict[str, Any]:
return {
"id": row.id,
"ethnicName": row.ethnic_name or "",
"ethnicCode": row.ethnic_code or "",
"orderNum": row.order_num,
}
def list_ethnics(
db: Session,
*,
keyword: Optional[str] = None,
limit: int = 200,
user_info=None,
) -> List[Dict[str, Any]]:
q = db.query(SysEthnic).filter(SysEthnic.del_flag == 0)
kw = (keyword or "").strip()
if kw:
like = f"%{kw}%"
q = q.filter(SysEthnic.ethnic_name.like(like))
# 民族码表为全局主数据,不做数据范围过滤
_ = user_info
rows = q.order_by(SysEthnic.order_num.asc(), SysEthnic.ethnic_code.asc()).limit(max(1, min(limit, 500))).all()
return [_row_to_dict(x) for x in rows]