支持具备 changeApplicant 权限时代填申请人及发票/余额联动;系统/CRM/BX/PL 主数据与下拉选项改为仅租户隔离,避免「仅本人」导致空选项。 Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
961 B
Python
34 lines
961 B
Python
"""民族码表 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]
|