refactor: 清理废弃业务模块并更新全栈配置
- 移除后端产品、目的地、活动专题等废弃模块的数据库表与业务代码,删除冗余API接口 - 删除小程序端详情页、线路组件等冗余代码,移除搜索工具与测试用例,调整导航逻辑 - 清理管理端废弃的类型定义、编辑器与测试代码 - 更新项目文档,修正模块维护说明与接口文档内容
This commit is contained in:
1 parent
72e6071bb1
commit
548f91c37f
80 files changed
+953
-12702
No files matched your search
@@ -1,12 +1,11 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
from sqlalchemy import or_, select
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
from .shared import site_config
|
||||
from ..auth import create_customer_token, require_customer
|
||||
from ..database import get_db
|
||||
from ..models import Customer, Destination, DestinationAlias, Lead, Product
|
||||
from ..schemas import LeadCreateIn, PhoneLoginIn, ProductQuery, ProductStatus
|
||||
from ..serializers import destination_dict, public_product_dict
|
||||
from ..models import Customer, Lead
|
||||
from ..schemas import LeadCreateIn, PhoneLoginIn
|
||||
from ..wechat import WechatApiError, WechatConfigError, exchange_phone_code
|
||||
|
||||
|
||||
@@ -34,68 +33,6 @@ def get_site_config(db: Session = Depends(get_db)):
|
||||
return site_config(db, active_only=True)
|
||||
|
||||
|
||||
@router.get("/api/public/products")
|
||||
def list_products(
|
||||
keyword: str | None = None,
|
||||
destinationId: str | None = None,
|
||||
status_value: ProductStatus = Query(default="published", alias="status"),
|
||||
take: int = Query(default=48, ge=1, le=100),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
query = ProductQuery(keyword=keyword, destinationId=destinationId, status=status_value, take=take)
|
||||
stmt = (
|
||||
select(Product)
|
||||
.options(selectinload(Product.destination).selectinload(Destination.aliases), selectinload(Product.images))
|
||||
.where(Product.status == query.status)
|
||||
.order_by(Product.sortWeight.asc(), Product.createdAt.asc())
|
||||
.limit(query.take)
|
||||
)
|
||||
if query.destinationId:
|
||||
stmt = stmt.where(Product.destinationId == query.destinationId)
|
||||
if query.keyword:
|
||||
pattern = f"%{query.keyword}%"
|
||||
stmt = (
|
||||
stmt.outerjoin(Product.destination)
|
||||
.outerjoin(Destination.aliases)
|
||||
.where(
|
||||
or_(
|
||||
Product.title.ilike(pattern),
|
||||
Product.subtitle.ilike(pattern),
|
||||
Product.tags.any(query.keyword),
|
||||
Destination.name.ilike(pattern),
|
||||
DestinationAlias.alias.ilike(pattern),
|
||||
)
|
||||
)
|
||||
.distinct()
|
||||
)
|
||||
products = db.scalars(stmt).unique().all()
|
||||
return {"items": [public_product_dict(product) for product in products]}
|
||||
|
||||
|
||||
@router.get("/api/public/products/{product_id}")
|
||||
def get_product(product_id: str, db: Session = Depends(get_db)):
|
||||
stmt = select(Product).options(selectinload(Product.destination), selectinload(Product.images))
|
||||
if product_id.isdigit():
|
||||
stmt = stmt.where(Product.sourceId == int(product_id))
|
||||
else:
|
||||
stmt = stmt.where(Product.id == product_id)
|
||||
product = db.scalars(stmt).first()
|
||||
if not product:
|
||||
raise HTTPException(status_code=404, detail="线路不存在")
|
||||
return public_product_dict(product)
|
||||
|
||||
|
||||
@router.get("/api/public/destinations")
|
||||
def list_destinations(db: Session = Depends(get_db)):
|
||||
destinations = db.scalars(
|
||||
select(Destination)
|
||||
.options(selectinload(Destination.aliases))
|
||||
.where(Destination.isActive.is_(True))
|
||||
.order_by(Destination.sortOrder.asc())
|
||||
).all()
|
||||
return {"items": [destination_dict(destination) for destination in destinations]}
|
||||
|
||||
|
||||
@router.post("/api/public/auth/phone-login")
|
||||
def phone_login(body: PhoneLoginIn, db: Session = Depends(get_db)):
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user