This commit is contained in:
toom1996
2026-09-07 00:01:48 +08:00
parent b049104a0b
commit 74ba700598
31 changed files with 1113 additions and 606 deletions

View File

@ -5,6 +5,7 @@ import (
"fashionapi/internal/dto"
"fashionapi/internal/pkg/hashid"
"fashionapi/internal/pkg/imgurl"
"fashionapi/internal/repository"
)
@ -27,11 +28,13 @@ type IndexRunwayData struct {
type indexService struct {
brands repository.BrandRepository
img *imgurl.Composer
}
// NewIndexService 创建首页数据服务。
func NewIndexService(brands repository.BrandRepository) IndexService {
return &indexService{brands: brands}
// img 负责把库里存储的七牛 key 拼装为可访问 URL(首页统一普通图)。
func NewIndexService(brands repository.BrandRepository, img *imgurl.Composer) IndexService {
return &indexService{brands: brands, img: img}
}
// Runway 首页 runway 区块数据。
@ -52,7 +55,7 @@ func (s *indexService) Runway(ctx context.Context, locale string) (IndexRunwayDa
ArticleUID: hashid.Encode(b.ArticleID),
// 品牌名强制优先英文("en"),不随 locale 切换,保持英文观感。
Brand: pickLocale(b.BrandEn, b.BrandCn, "en"),
Cover: b.Cover,
Cover: s.img.Compose(b.Cover, false), // 首页封面统一普通图
Title: pickLocale(b.TitleEn, b.TitleCn, locale),
})
}