|
@@ -566,6 +566,7 @@ async def authRoleUpdate( userId: int = Query(None ,description='用户id'),
|
|
|
except Exception as e:
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
@router.get('/profile')
|
|
|
async def userlist( #user_id_1: int = Query(None ,description='用户id'),
|
|
|
db: Session = Depends(get_db),
|
|
@@ -641,13 +642,59 @@ async def userlist( #user_id_1: int = Query(None ,description='用户id'),
|
|
|
# "posts":[]
|
|
|
# }
|
|
|
"postGroup":"工作人员",
|
|
|
- "roleGroup":"工作人员"
|
|
|
+ "roleGroup":'/'.join([i["roleName"] for i in user_roles])
|
|
|
}
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+@router.put('/profile')
|
|
|
+async def userlist( #user_id_1: int = Query(None ,description='用户id'),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ user_id: int = Depends(valid_access_token)):
|
|
|
+ try:
|
|
|
+
|
|
|
+ user = user_id_get_user_info(db,user_id)
|
|
|
+ if "email" in body:
|
|
|
+ user.email=body['email']
|
|
|
+ user.update_by=user_id
|
|
|
+ if "nickName" in body:
|
|
|
+ user.nick_name = body['nickName']
|
|
|
+ user.update_by=user_id
|
|
|
+ if "phonenumber" in body:
|
|
|
+ user.phonenumber = body['phonenumber']
|
|
|
+ user.update_by=user_id
|
|
|
+ if "sex" in body:
|
|
|
+ user.nick_name = body['sex']
|
|
|
+ user.update_by=user_id
|
|
|
+ db.commit()
|
|
|
+ return {"code":200,"msg":"成功","data":None}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+@router.put('/profile/updatePwd')
|
|
|
+async def userlist( #user_id_1: int = Query(None ,description='用户id'),
|
|
|
+ db: Session = Depends(get_db),
|
|
|
+ body = Depends(remove_xss_json),
|
|
|
+ user_id: int = Depends(valid_access_token)):
|
|
|
+ try:
|
|
|
+
|
|
|
+ user = user_id_get_user_info(db,user_id)
|
|
|
+ if user.password!=body['oldPassword']:
|
|
|
+ return JSONResponse(status_code=404,content={"code":404,"msg":"密码错误"})
|
|
|
+ if "newPassword" in body:
|
|
|
+ user.nick_name = body['newPassword']
|
|
|
+ user.update_by=user_id
|
|
|
+
|
|
|
+ db.commit()
|
|
|
+ return {"code":200,"msg":"成功","data":None}
|
|
|
+ except Exception as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@router.get('/authRole/{user_id_1}')
|
|
|
@router.get('/{user_id_1}')
|