71 lines
1.8 KiB
Go
71 lines
1.8 KiB
Go
// 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:
|
||
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
|
||
}
|