package dto // ---------- 街拍列表查询 ---------- // StreetSnapQuery 街拍列表查询条件(GET /public/street-snaps)。 // // 街拍不关联品牌,因此没有 brand_id / collection / season 等走秀特有的筛选维度; // 仅保留通用的年份过滤与排序(按图片数或年份)。分页 size 与附图 images 由服务端固定。 type StreetSnapQuery struct { Page int Size int // 服务端固定为 StreetSnapFixedSize,不从 query 读取 Year int // 单值年份,0 表示不过滤 City string // 地区/城市(精确匹配 city 列),'' 表示不过滤 Sort string // image_count(默认)/ year_desc / year_asc Images int // 服务端固定为 StreetSnapFixedImages,不从 query 读取 Locale string } // 列表分页与附图数量由服务端固定(前端无调整入口),不从 query 读取。 const ( StreetSnapFixedSize = 24 streetSnapMaxSize = 100 StreetSnapFixedImages = 6 streetSnapImagesMax = 12 ) // Normalize 校正分页与附图参数,防止非法值打穿数据库。 func (q *StreetSnapQuery) Normalize() { if q.Page < 1 { q.Page = 1 } if q.Size < 1 || q.Size > streetSnapMaxSize { q.Size = StreetSnapFixedSize } if q.Images < 0 { q.Images = 0 } if q.Images > streetSnapImagesMax { q.Images = streetSnapImagesMax } if q.Sort == "" { q.Sort = "image_count" } } // Offset 返回 SQL 偏移量。 func (q StreetSnapQuery) Offset() int { return (q.Page - 1) * q.Size } // ---------- 响应 ---------- // PublicStreetSnap 对外展示用的精简街拍结构(列表)。 // // 只返回前端真正渲染的字段:id(编码)/ title / cover / image_count / images(前 N 张缩略图)。 // 街拍不关联品牌,故无 brand_id / brand_name。 type PublicStreetSnap struct { UID string `json:"id"` // 编码后的街拍 id(无序串) Title string `json:"title"` Cover string `json:"cover"` ImageCount uint16 `json:"image_count"` // 该街拍图片总数(卡片 "N+" 角标用) Images []PublicArticleImage `json:"images"` // 列表附带的每篇前 N 张缩略图 } // PublicStreetSnapDetail 对外只读街拍详情:含完整图片集。 type PublicStreetSnapDetail struct { UID string `json:"id"` Title string `json:"title"` Cover string `json:"cover"` Images []PublicArticleImage `json:"images"` Favorited bool `json:"favorited,omitempty"` // 已登录时该图集是否被当前用户收藏(gallery 级,s= 前缀) }