This commit is contained in:
aaron 2025-02-15 16:31:26 +08:00
parent ab5d42fb65
commit 2a58fcc52d

View File

@ -106,18 +106,20 @@ async def update_address(
for key, value in update_data.items():
setattr(db_address, key, value)
# 查询社区名字和楼栋名字
# 更新社区名字和楼栋名字
if address.community_id:
community = db.query(CommunityDB).filter(
CommunityDB.id == address.community_id
).first()
db_address.community_name = community.name
if address.community_building_id:
community_building = db.query(CommunityBuildingDB).filter(
CommunityBuildingDB.id == address.community_building_id
).first()
db_address.community_name = community.name
db_address.community_building_name = community_building.building_name
db.commit()
db.refresh(db_address)
return success_response(data=AddressInfo.model_validate(db_address))