This commit is contained in:
zlwu committed 2026-05-25 15:14:06 +08:00
1 parent 575e63e7e8
commit 771f010a39
165 files changed
+67359 -21698

No files matched your search

+17
View File
@@ -69,11 +69,20 @@ class CustomerUpdateBody(BaseModel):
remark: Optional[str] = None
def _normalize_date_bound(value: str, *, end_of_day: bool = False) -> str:
val = (value or "").strip()
if len(val) == 10:
return f"{val} 23:59:59" if end_of_day else f"{val} 00:00:00"
return val
@router.get("/customers")
async def list_customers(
page: int = Query(1, ge=1),
pageSize: int = Query(10, ge=1, le=100, alias="pageSize"),
keyword: Optional[str] = None,
createTimeStart: Optional[str] = Query(None, alias="createTimeStart"),
createTimeEnd: Optional[str] = Query(None, alias="createTimeEnd"),
user: dict = Depends(require_menu_code("biz:customer:list")),
db: Session = Depends(get_db),
):
@@ -94,6 +103,14 @@ async def list_customers(
BizCustomer.customer_tags.like(like),
)
)
if createTimeStart:
query = query.filter(
BizCustomer.create_time >= _normalize_date_bound(createTimeStart)
)
if createTimeEnd:
query = query.filter(
BizCustomer.create_time <= _normalize_date_bound(createTimeEnd, end_of_day=True)
)
query = apply_data_scope(query, BizCustomer, user, db, tenant_no)
total = query.count()
items = query.order_by(BizCustomer.create_time.desc()).offset((page - 1) * pageSize).limit(pageSize).all()