refactor(home-api): 统一首页API响应格式并迁移配套代码
完成首页数据模型的统一重构,具体变更如下: 1. 重构公共首页API接口,移除`playRecommendations`字段,将玩法推荐数据统一放入`experiences`字段 2. 更新前后端类型定义、序列化逻辑与前端页面组件,适配新的API响应结构 3. 为微信登录相关接口添加`trust_env=True`配置,支持企业代理环境并新增`socksio`依赖 4. 新增图片画廊上传组件,重构SingleImageUploader组件支持自定义宽高比 5. 重构Toast与Select组件的实现与样式,统一后台UI设计系统 6. 移除个人中心页面不必要的返回事件与顶部标题组件,优化详情卡片布局 7. 新增微信接口单元测试,更新官方文档与测试用例适配变更 8. 删除过期的文档图片资源
This commit is contained in:
1 parent
d3a246a873
commit
6296392e80
27 files changed
+1055
-218
No files matched your search
@@ -5,11 +5,10 @@ from .shared import site_config
|
||||
from ..auth import create_customer_token, require_customer
|
||||
from ..api_response import success_response
|
||||
from ..database import get_db
|
||||
from ..models import ConciergeAdvisor, Customer, DetailRecord, HomeExperience, HomeTeamBuilding, HomeWanfaRecommendation, HomeWildArchive, Lead, WanfaCategory
|
||||
from ..models import ConciergeAdvisor, Customer, DetailRecord, HomeTeamBuilding, HomeWanfaRecommendation, HomeWildArchive, Lead, WanfaCategory
|
||||
from ..schemas import LeadCreateIn, PhoneLoginIn
|
||||
from ..serializers import (
|
||||
public_concierge_advisor_dict,
|
||||
public_home_experience_dict,
|
||||
public_home_team_building_dict,
|
||||
public_home_team_building_detail_dict,
|
||||
public_home_wanfa_recommendation_dict,
|
||||
@@ -80,11 +79,6 @@ def get_public_concierge_advisors(db: Session = Depends(get_db)):
|
||||
|
||||
@router.get("/api/public/home")
|
||||
def get_public_home(db: Session = Depends(get_db)):
|
||||
experiences = db.scalars(
|
||||
select(HomeExperience)
|
||||
.where(HomeExperience.isActive.is_(True))
|
||||
.order_by(HomeExperience.sortOrder.asc())
|
||||
).all()
|
||||
team_buildings = db.scalars(
|
||||
select(HomeTeamBuilding)
|
||||
.where(HomeTeamBuilding.isActive.is_(True))
|
||||
@@ -103,10 +97,9 @@ def get_public_home(db: Session = Depends(get_db)):
|
||||
).all()
|
||||
return success_response(
|
||||
{
|
||||
"experiences": [public_home_experience_dict(item) for item in experiences],
|
||||
"experiences": [public_home_wanfa_recommendation_dict(item) for item in play_recommendations],
|
||||
"teamBuildings": [public_home_team_building_dict(item) for item in team_buildings],
|
||||
"wildArchives": [public_home_wild_archive_dict(item) for item in wild_archives],
|
||||
"playRecommendations": [public_home_wanfa_recommendation_dict(item) for item in play_recommendations],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ def get_access_token(settings: Settings | None = None) -> str:
|
||||
"https://api.weixin.qq.com/cgi-bin/token",
|
||||
params={"grant_type": "client_credential", "appid": appid, "secret": secret},
|
||||
timeout=8,
|
||||
trust_env=True,
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
raise WechatApiError("微信登录服务暂时不可用") from exc
|
||||
@@ -66,6 +67,7 @@ def exchange_phone_code(code: str, settings: Settings | None = None) -> str:
|
||||
params={"access_token": access_token},
|
||||
json={"code": code},
|
||||
timeout=8,
|
||||
trust_env=True,
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
raise WechatApiError("手机号授权服务暂时不可用") from exc
|
||||
|
||||
Reference in new issue
Block a user