修复: 用户更新API支持新字段/登录次数更新

This commit is contained in:
longda 2026-03-24 23:20:12 +08:00
parent 1fe912ac76
commit 0db9215587
2 changed files with 36 additions and 0 deletions

View File

@ -100,6 +100,12 @@ def login(
headers={"WWW-Authenticate": "Bearer"}, 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 # 生成 token
access_token = create_access_token(data={"sub": user.f99_90_id}) access_token = create_access_token(data={"sub": user.f99_90_id})

View File

@ -182,6 +182,12 @@ def update_user(
role: Optional[str] = Body(None), role: Optional[str] = Body(None),
password: Optional[str] = Body(None), password: Optional[str] = Body(None),
user_code: 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), current_user: User = Depends(get_current_user),
db: Session = Depends(get_db) db: Session = Depends(get_db)
): ):
@ -201,6 +207,30 @@ def update_user(
if role is not None: if role is not None:
user.role = role 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: if user_code is not None:
# 只有非空字符串才检查唯一性 # 只有非空字符串才检查唯一性