diff --git a/backend/app/routers/auth.py b/backend/app/routers/auth.py index d3b7730..18e8797 100644 --- a/backend/app/routers/auth.py +++ b/backend/app/routers/auth.py @@ -100,6 +100,12 @@ def login( headers={"WWW-Authenticate": "Bearer"}, ) + # 更新登录次数和最后登录时间 + from datetime import datetime + user.f99_98_login_count = (user.f99_98_login_count or 0) + 1 + user.f99_99_last_login = datetime.now() + db.commit() + # 生成 token access_token = create_access_token(data={"sub": user.f99_90_id}) diff --git a/backend/app/routers/users.py b/backend/app/routers/users.py index 1914635..a94ea85 100644 --- a/backend/app/routers/users.py +++ b/backend/app/routers/users.py @@ -182,6 +182,12 @@ def update_user( role: Optional[str] = Body(None), password: Optional[str] = Body(None), user_code: Optional[str] = Body(None), + level: Optional[str] = Body(None), + points: Optional[int] = Body(None), + balance: Optional[float] = Body(None), + totalAmount: Optional[float] = Body(None), + aiCount: Optional[int] = Body(None), + searchCount: Optional[int] = Body(None), current_user: User = Depends(get_current_user), db: Session = Depends(get_db) ): @@ -201,6 +207,30 @@ def update_user( if role is not None: user.role = role + # 更新会员等级 + if level is not None: + user.f99_94_level = level + + # 更新积分 + if points is not None: + user.f99_100_points = points + + # 更新余额 + if balance is not None: + user.f01_11_balance = balance + + # 更新累计金额 + if totalAmount is not None: + user.f01_12_total_amount = totalAmount + + # 更新AI识别次数 + if aiCount is not None: + user.f99_95_ai_count = aiCount + + # 更新寻号次数 + if searchCount is not None: + user.f99_96_search_count = searchCount + # 更新用户编码 if user_code is not None: # 只有非空字符串才检查唯一性