1. 海报

This commit is contained in:
李琦
2026-08-03 10:22:04 +08:00
parent 807adbc6a4
commit 211305c10c
5 changed files with 137 additions and 41 deletions

View File

@@ -23,7 +23,7 @@ func Register(api *gin.RouterGroup, database *gorm.DB, adminGuard func(*gin.Cont
api.POST("/poster/config", handleSavePosterConfig)
}
// resolveSide 返回 "1"(男方)"2"(女方);无法识别返回空
// resolveSide 返回 "1"(男方)"2"(女方)或 "3"(回门宴);无法识别返回空
func resolveSide(raw string) string {
v := strings.ToLower(strings.TrimSpace(raw))
switch v {
@@ -31,6 +31,8 @@ func resolveSide(raw string) string {
return "1"
case "2", "female", "nv", "f", "bride":
return "2"
case "3", "hm", "hmy", "return", "huimen":
return "3"
default:
return ""
}
@@ -40,7 +42,7 @@ func isLegacyFlat(m map[string]interface{}) bool {
if m == nil {
return false
}
for _, k := range []string{"1", "2", "male", "female"} {
for _, k := range []string{"1", "2", "3", "male", "female", "hm"} {
if _, ok := m[k]; ok {
return false
}
@@ -73,7 +75,7 @@ func takeSide(raw map[string]interface{}, keys ...string) map[string]interface{}
return emptyObj()
}
// normalizeBundle 统一为 { "1", "2" };兼容旧 male/female 与扁平配置
// normalizeBundle 统一为 { "1", "2", "3" };兼容旧 male/female 与扁平配置
func normalizeBundle(raw map[string]interface{}) map[string]interface{} {
if raw == nil {
raw = emptyObj()
@@ -81,6 +83,7 @@ func normalizeBundle(raw map[string]interface{}) map[string]interface{} {
out := map[string]interface{}{
"1": emptyObj(),
"2": emptyObj(),
"3": emptyObj(),
}
if isLegacyFlat(raw) {
out["1"] = raw
@@ -92,6 +95,9 @@ func normalizeBundle(raw map[string]interface{}) map[string]interface{} {
if f := takeSide(raw, "2", "female"); len(f) > 0 {
out["2"] = f
}
if h := takeSide(raw, "3", "hm", "hmy"); len(h) > 0 {
out["3"] = h
}
return out
}