基本完成

This commit is contained in:
2026-08-25 22:53:57 +08:00
parent 05fa686749
commit 252d5b53ac
39 changed files with 3853 additions and 447 deletions
+17 -1
View File
@@ -1,7 +1,7 @@
"""
投递记录路由:上报投递结果、查询历史、统计
"""
from datetime import datetime
from datetime import datetime, timedelta
from typing import Optional
from fastapi import APIRouter, Depends, HTTPException, Query
from sqlalchemy.orm import Session
@@ -82,6 +82,22 @@ def check_applied(
return {"job_id": job_id, "applied": record is not None}
@router.get("/today-count", response_model=dict)
def today_count(
current_user: User = Depends(get_current_user),
db: Session = Depends(get_db),
):
"""当前用户当天(北京时间)实际投递数量,用于客户端每日上限判断"""
now_cn = datetime.utcnow() + timedelta(hours=8)
start_utc = now_cn.replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(hours=8)
count = db.query(JobApplication).filter(
JobApplication.user_id == current_user.id,
JobApplication.apply_type.in_(["chat", "deliver"]),
JobApplication.applied_at >= start_utc,
).count()
return {"count": count}
@router.get("/history", response_model=list[ApplicationOut])
def list_applications(
apply_type: Optional[str] = Query(None, description="过滤投递类型"),