From 7b7dcc66d693de114b1728f8d6f827668377e80d Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Thu, 18 Dec 2025 15:28:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(api):=20=E4=BC=98=E5=8C=96=E7=AB=8B?= =?UTF-8?q?=E5=87=8F=E9=87=91=E6=89=93=E5=BC=80=E6=96=B9=E5=BC=8F=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 voucher.is_webview 的打开方式映射从 switch 改为统一的map查询 - 在 constants 中新增 VoucherOpenMode 映射表,提升代码可维护性 - 移除冗余的分支判断,代码更简洁清晰 - 保持功能一致,确保映射结果不变 --- server/internal/api/exports.go | 11 ++++------- server/internal/constants/enums.go | 7 +++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/server/internal/api/exports.go b/server/internal/api/exports.go index b4e6c65..9dde141 100644 --- a/server/internal/api/exports.go +++ b/server/internal/api/exports.go @@ -1133,13 +1133,10 @@ func transformRow(ds string, fields []string, vals []string) []string { } // voucher.is_webview - 打开方式 if f == "voucher.is_webview" { - switch v { - case "0": - vals[i] = "微信小程序" - case "1": - vals[i] = "公众号" - case "2": - vals[i] = "通用" + if n := parseIntVal(v); n >= 0 { + if label, ok := constants.VoucherOpenMode[n]; ok { + vals[i] = label + } } continue } diff --git a/server/internal/constants/enums.go b/server/internal/constants/enums.go index 3cb23d7..069e1e2 100644 --- a/server/internal/constants/enums.go +++ b/server/internal/constants/enums.go @@ -122,6 +122,13 @@ var MarketingRechargeType = map[int]string{ 2: "组合商品充值", } +// VoucherOpenMode 立减金打开方式映射 +var VoucherOpenMode = map[int]string{ + 0: "微信小程序", + 1: "公众号", + 2: "通用", +} + // ==================== 通用枚举 ==================== // ThirdPartyType 第三方类型映射