修复: 用户更新API支持新字段/登录次数更新
This commit is contained in:
parent
1fe912ac76
commit
0db9215587
|
|
@ -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})
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
# 只有非空字符串才检查唯一性
|
||||
|
|
|
|||
Loading…
Reference in New Issue