fix: handle Optional[User] in update_information
This commit is contained in:
parent
38f1da12b5
commit
d2c4d5bf5f
|
|
@ -525,12 +525,14 @@ def create_information(
|
||||||
def update_information(
|
def update_information(
|
||||||
info_id: str,
|
info_id: str,
|
||||||
data: InformationUpdate,
|
data: InformationUpdate,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: Optional[User] = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""更新资讯"""
|
"""更新资讯"""
|
||||||
|
if not current_user:
|
||||||
|
raise HTTPException(status_code=401, detail="请先登录")
|
||||||
# 处理f99_90_id为None的情况
|
# 处理f99_90_id为None的情况
|
||||||
user_filter = current_user.f99_90_id if current_user.f99_90_id else Information.user_id
|
user_filter = current_user.f99_90_id if current_user and current_user.f99_90_id else Information.user_id
|
||||||
info = db.query(Information).filter(
|
info = db.query(Information).filter(
|
||||||
Information.id == info_id,
|
Information.id == info_id,
|
||||||
Information.user_id == user_filter
|
Information.user_id == user_filter
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue