feat(frontend): 首页广告位网格溢出根治(minmax(0,1fr) minmax(0,1.2fr)+min-width:0) + 精选推荐对接平台广告接口 GET /app/api/market/ads
This commit is contained in:
1 parent
e38e18fbe7
commit
9b87012248
3 files changed
+74
-7
No files matched your search
@@ -9,7 +9,7 @@ from datetime import datetime
|
||||
from ..database import get_db
|
||||
from ..models import (
|
||||
User, MarketApp, AppPurchase, AppReview, AppInstallation, Order,
|
||||
gen_uuid
|
||||
AdBanner, gen_uuid
|
||||
)
|
||||
from ..auth import get_current_user, get_current_user_id, get_current_user_id_optional
|
||||
from ..middleware.log_service import LogService
|
||||
@@ -17,6 +17,34 @@ from ..middleware.log_service import LogService
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/ads")
|
||||
def list_public_ads(db: Session = Depends(get_db)):
|
||||
"""
|
||||
前台首页「精选推荐」广告位:返回已上架(active)广告,按排序升序,无需登录。
|
||||
供 LandingPage 轮播调用,无鉴权依赖。
|
||||
"""
|
||||
ads = (
|
||||
db.query(AdBanner)
|
||||
.filter(AdBanner.status == "active")
|
||||
.order_by(AdBanner.sort_order.asc())
|
||||
.all()
|
||||
)
|
||||
return [
|
||||
{
|
||||
"id": a.id,
|
||||
"title": a.title,
|
||||
"image_url": a.image_url,
|
||||
"link_app_id": a.link_app_id,
|
||||
"link_app_name": a.link_app_name,
|
||||
"sort_order": a.sort_order,
|
||||
"click_count": a.click_count,
|
||||
"status": a.status,
|
||||
"created_at": a.created_at.isoformat() if a.created_at else None,
|
||||
}
|
||||
for a in ads
|
||||
]
|
||||
|
||||
|
||||
class UploadAppRequest(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=200)
|
||||
description: Optional[str] = None
|
||||
|
||||
Reference in new issue
Block a user