diff --git a/app/api/endpoints/user.py b/app/api/endpoints/user.py index 38187dc..35334d6 100644 --- a/app/api/endpoints/user.py +++ b/app/api/endpoints/user.py @@ -137,9 +137,11 @@ async def get_user_info( user_data = user_info.model_dump() # 获取用户归属小区信息 - if current_user.community_id: + if current_user.community_id > 0: user_data['community_id'] = current_user.community_id - user_data['community_name'] = db.query(CommunityDB.name).filter(CommunityDB.id == current_user.community_id).first().name + community = db.query(CommunityDB).filter(CommunityDB.id == current_user.community_id).first() + if community: + user_data['community_name'] = community.name # 处理默认地址 if default_address: diff --git a/app/core/config.py b/app/core/config.py index afb7678..d6a6221 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -39,7 +39,7 @@ class Settings(BaseSettings): MYSQL_PORT: int = 27469 MYSQL_USER: str = "root" MYSQL_PASSWORD: str = "Aa#223388" - MYSQL_DB: str = "beefastapp" + MYSQL_DB: str = "beefast" @property