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

@ -58,8 +58,12 @@ func (q ArticleQuery) Offset() int { return (q.Page - 1) * q.Size }
// ---------- 响应 ----------
// PublicArticleImage 对外展示用的图片结构(仅 url + 名称)。
// PublicArticleImage 对外展示用的图片结构。
//
// ID 是图片自身的编码 id(hashid,i=走秀单图 / j=街拍单图),供「单图收藏」定位到具体某一张;
// 此前只有 image + name,前端无法稳定标识单张图片,故补充该字段。
type PublicArticleImage struct {
ID string `json:"id"`
Image string `json:"image"`
Name string `json:"name"`
}

View File

@ -2,23 +2,40 @@ package dto
// ---------- 收藏 ----------
// 收藏粒度:与 model.Favorite.Kind 对应。
const (
FavoriteKindGallery = "gallery" // 整篇图集(runway / street)
FavoriteKindImage = "image" // 单张图片(runway_image / snap_image)
)
// FavoriteItem 对外返回的收藏项:id 即 target_uid,便于前端直接比对卡片 id。
//
// kind=image 时 image_url 是这一张图、parent_uid 是所属图集,前端用这两项渲染与回跳;
// kind=gallery 时沿用 cover / title / brand 快照。
type FavoriteItem struct {
ID string `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Cover string `json:"cover"`
Brand string `json:"brand"`
AddedAt uint32 `json:"added_at"`
ID string `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Cover string `json:"cover"`
Brand string `json:"brand"`
AddedAt uint32 `json:"added_at"`
Kind string `json:"kind"`
ImageURL string `json:"image_url"`
ParentUID string `json:"parent_uid"`
}
// FavoriteAdd 添加收藏请求体。target_uid 为前端卡片的 it.id(编码串)。
// FavoriteAdd 添加收藏请求体。target_uid 为前端卡片的 id(图集或图片的编码串)。
type FavoriteAdd struct {
TargetType string `json:"target_type" binding:"required"` // runway | street
TargetType string `json:"target_type" binding:"required"` // runway | street | runway_image | snap_image
TargetUID string `json:"target_uid" binding:"required"`
Title string `json:"title"`
Cover string `json:"cover"`
Brand string `json:"brand"`
// 图片收藏可选字段。kind 留空时由 target_type 推断(*_image → image,否则 gallery)。
Kind string `json:"kind"`
ImageURL string `json:"image_url"`
ParentUID string `json:"parent_uid"`
}
// FavoriteCheck 批量查询哪些 target_uid 已收藏(列表页打勾用,与收藏总量解耦)。