Files
backend_v2/internal/dto/favorite.go
toom1996 ffe84efc4c update
2026-09-03 00:32:52 +08:00

45 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"`
Kind string `json:"kind"`
ImageURL string `json:"image_url"`
ParentUID string `json:"parent_uid"`
}
// FavoriteAdd 添加收藏请求体。target_uid 为前端卡片的 id(图集或图片的编码串)。
type FavoriteAdd struct {
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 已收藏(列表页打勾用,与收藏总量解耦)。
type FavoriteCheck struct {
IDs []string `json:"ids" binding:"required"`
}