Files
backend_v2/internal/pkg/season/season.go
toom1996 d6ed96624a fix: 男装季节码不再一律 FW + 本地图迁移到 S4 的工具
男装季节码
- prefixOf 里 menswear 原来直接 return "FW",导致同年 Spring/Fall 男装推出同一个
  season_code(如 Spring 2021 与 Fall 2021 都是 FW21)。实体键是
  (brand + season_code + collection_type),后到的那场被判「已存在」静默丢弃。
- 改为按真实季节:春男装 SSyy、秋男装 FWyy。
- 迁移 2026-10-25-03 把历史「Spring ... Menswear」行的 season_code 由 FWyy 改写为 SSyy;
  实测无唯一键冲突(同品牌春夏男装此前必然因撞键未入库)。

s4migrate
- 新增 cmd/s4migrate:把库里 /uploads/... 的历史图片按内容寻址 key 上传到 S4,
  并改写图片行与封面,之后全站只保留 S4 一种存储(不再依赖 nginx 转发 /uploads)。
- 实测:136 张全部迁移成功,库内 /uploads 残留 0。
2026-10-25 14:55:30 +08:00

81 lines
2.3 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 season 走秀季节 / 年份 → season_code 的推导与解析辅助。
//
// season_code 是对外与排序共用的紧凑编码:SS26 / FW25 / RES26 / PF25,
// 规则:前缀由 collection_type 决定(resort→RES;pre_fall→PF;couture→FW;
// menswear→FW);rtw 无独立前缀,落入 season 分支(spring→SS / fall→FW),
// 后缀为两位年份。
// 历史代码 vogue.go 漏填 season_code 是已知 bug,这里集中推导逻辑,worker 与回填脚本复用。
package season
import (
"strconv"
)
// CollectionType / Season 取值白名单。
const (
ColRTW = "rtw"
ColMenswear = "menswear"
ColCouture = "couture"
ColResort = "resort"
ColPreFall = "pre_fall"
SeasonSpring = "spring"
SeasonFall = "fall"
)
// Derive 由年份 + 系列/季节推导 season_code(如 2026 + spring → "SS26")。
//
// 优先级:collection_type 先在(resort→RES、pre_fall→PF);否则用 season
// (spring→SS、fall→FW);二者皆空或无法识别时回落 "SS"。
// year 为 0 时返回空串(未知年份无法编码)。
func Derive(year uint16, collectionType, season string) string {
if year == 0 {
return ""
}
prefix := prefixOf(collectionType, season)
return prefix + twoDigit(year)
}
func prefixOf(collectionType, season string) string {
switch collectionType {
case ColResort:
return "RES"
case ColPreFall:
return "PF"
case ColCouture:
// 高定沿用秋冬编码(FW),与排序优先级一致
return "FW"
case ColMenswear:
// 男装必须按真实季节区分:曾经一律返回 FW,导致同年的
// 「Spring 2021 Menswear」与「Fall 2021 Menswear」推出同一个 season_code(FW21),
// 而实体键是(品牌 + season_code + 系列),于是后到的那场被判「已存在」静默丢弃。
// 实测 AMBUSH:Vogue 25 场只入库 21 场,缺的 4 场全是男装。
switch season {
case SeasonSpring:
return "SS"
case SeasonFall:
return "FW"
}
return "FW"
}
switch season {
case SeasonFall:
return "FW"
case SeasonSpring:
return "SS"
}
return "SS"
}
// twoDigit 取年份后两位(2026 → "26")。
func twoDigit(year uint16) string {
if year >= 2000 {
year -= 2000
}
s := strconv.Itoa(int(year))
if len(s) > 2 {
s = s[len(s)-2:]
}
return s
}