This commit is contained in:
toom1996
2026-09-16 00:56:15 +08:00
parent 5e4803b97f
commit 7dd3fda73c
10 changed files with 184 additions and 54 deletions

View File

@ -70,7 +70,7 @@ func (s *articleService) List(ctx context.Context, q dto.ArticleQuery) ([]dto.Pu
for _, r := range rows {
ids = append(ids, r.ID)
list = append(list, dto.PublicArticle{
UID: hashid.EncodeTyped(hashid.TypeRunway, r.ID),
UID: hashid.EncodeWithType(r.ID, hashid.TypeRunway),
BrandUID: hashid.Encode(r.BrandID),
Title: pickLocale(r.TitleEn, r.TitleCn, q.Locale),
Cover: s.img.ComposeThumb(r.Cover), // 列表封面走缩略图样式(小尺寸省流量)
@ -98,7 +98,7 @@ func (s *articleService) AdminList(ctx context.Context, q dto.ArticleQuery) ([]d
list := make([]dto.AdminRunway, 0, len(rows))
for _, r := range rows {
list = append(list, dto.AdminRunway{
UID: hashid.EncodeTyped(hashid.TypeRunway, r.ID),
UID: hashid.EncodeWithType(r.ID, hashid.TypeRunway),
BrandUID: hashid.Encode(r.BrandID),
BrandName: pickLocale(r.BrandNameEn, r.BrandNameCn, "en"),
Title: pickLocale(r.TitleEn, r.TitleCn, q.Locale),
@ -190,7 +190,7 @@ func (s *articleService) Detail(ctx context.Context, id string, locale string) (
}
return &dto.PublicArticleDetail{
UID: hashid.EncodeTyped(hashid.TypeRunway, row.ID),
UID: hashid.EncodeWithType(row.ID, hashid.TypeRunway),
BrandUID: hashid.Encode(row.BrandID),
Title: pickLocale(row.TitleEn, row.TitleCn, locale),
Description: pickLocale(row.DescriptionEn, row.DescriptionCn, locale),
@ -274,7 +274,7 @@ func (s *articleService) toPublicImages(imgs []model.BrandRunwayImage) []dto.Pub
out := make([]dto.PublicArticleImage, 0, len(imgs))
for _, im := range imgs {
out = append(out, dto.PublicArticleImage{
ID: hashid.EncodeTyped(hashid.TypeRunwayImage, im.ID),
ID: hashid.EncodeWithType(im.ID, hashid.TypeRunwayImage),
Image: s.img.Compose(im.Image),
Thumb: s.img.ComposeThumb(im.Image),
Name: im.Name,
@ -294,7 +294,7 @@ func (s *articleService) toThumbImages(imgs []model.BrandRunwayImage) []dto.Publ
out := make([]dto.PublicArticleImage, 0, len(imgs))
for _, im := range imgs {
out = append(out, dto.PublicArticleImage{
ID: hashid.EncodeTyped(hashid.TypeRunwayImage, im.ID),
ID: hashid.EncodeWithType(im.ID, hashid.TypeRunwayImage),
Image: s.img.ComposeThumb(im.Image),
Name: im.Name,
IsDetail: im.IsDetail,