From e24b42fe4d9496547f6ad2d867438e160c7ff63b Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Fri, 28 Nov 2025 14:47:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0YMT=E5=AF=86=E9=92=A5?= =?UTF-8?q?=E8=A7=A3=E5=AF=86=E5=AF=86=E9=92=A5=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在配置文件中新增ymt_key_decrypt_key_b64字段,用于设置YMT密钥解密密钥 当配置项不为空时,自动将其设置为环境变量YMT_KEY_DECRYPT_KEY_B64 --- server/cmd/server/main.go | 2 ++ server/config_example.yaml | 1 + server/internal/config/config.go | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/cmd/server/main.go b/server/cmd/server/main.go index 0b91fe4..fd151a2 100644 --- a/server/cmd/server/main.go +++ b/server/cmd/server/main.go @@ -9,6 +9,7 @@ import ( "marketing-system-data-tool/server/internal/logging" "net/http" "time" + "os" ) func main() { @@ -51,3 +52,4 @@ func main() { } // buildDSN deprecated; use cfg.YMTDB.DSN()/cfg.MarketingDB.DSN() + if cfg.YMTKeyDecryptKeyB64 != "" { os.Setenv("YMT_KEY_DECRYPT_KEY_B64", cfg.YMTKeyDecryptKeyB64) } diff --git a/server/config_example.yaml b/server/config_example.yaml index 9526a29..7890205 100644 --- a/server/config_example.yaml +++ b/server/config_example.yaml @@ -12,3 +12,4 @@ app: user: "YOUR_YMT_DB_USER" password: "YOUR_YMT_DB_PASSWORD" name: "YOUR_YMT_DB_NAME" + ymt_key_decrypt_key_b64: "" diff --git a/server/internal/config/config.go b/server/internal/config/config.go index 19c4373..f328be9 100644 --- a/server/internal/config/config.go +++ b/server/internal/config/config.go @@ -18,9 +18,10 @@ type DB struct { } type App struct { - Port string `yaml:"port"` - MarketingDB DB `yaml:"marketing_db"` - YMTDB DB `yaml:"ymt_db"` + Port string `yaml:"port"` + MarketingDB DB `yaml:"marketing_db"` + YMTDB DB `yaml:"ymt_db"` + YMTKeyDecryptKeyB64 string `yaml:"ymt_key_decrypt_key_b64"` } type root struct {