This commit is contained in:
toom1996
2026-09-03 00:32:52 +08:00
parent 1fd9c48f58
commit ffe84efc4c
9 changed files with 143 additions and 39 deletions

View File

@ -122,14 +122,19 @@ func (s *articleService) Detail(ctx context.Context, id string, locale string) (
}
// IDs 返回全部文章的编码 uid(供 SSG 枚举详情页路径使用,对外暴露的即编码串)。
// toPublicImages 把图片实体映射为对外结构(只保留 url 与名称)。
// toPublicImages 把图片实体映射为对外结构(url + 名称 + 图片自身的编码 id)。
// ID 用 TypeRunwayImage 前缀编码,与文章 uid(r 前缀)区分开,供单图收藏定位。
func toPublicImages(imgs []model.BrandRunwayImage) []dto.PublicArticleImage {
if len(imgs) == 0 {
return nil
}
out := make([]dto.PublicArticleImage, 0, len(imgs))
for _, im := range imgs {
out = append(out, dto.PublicArticleImage{Image: im.Image, Name: im.Name})
out = append(out, dto.PublicArticleImage{
ID: hashid.EncodeTyped(hashid.TypeRunwayImage, im.ID),
Image: im.Image,
Name: im.Name,
})
}
return out
}