重构代码结构,迁移Baiyin SDK相关逻辑至globals包,并添加支付宝客户端初始化

This commit is contained in:
2025-04-16 14:01:30 +08:00
parent f1456d01ea
commit 083fabb308
12 changed files with 200 additions and 76 deletions

43
pkg/env/env.go vendored
View File

@@ -182,6 +182,48 @@ func loadRemote() {
// endregion
// region alipay
var (
AlipayAppId string
AlipayAppPrivateKey string
AlipayPublicKey string
AlipayEncryptKey string
AlipayProduction = false
)
func loadAlipay() {
AlipayAppId := os.Getenv("ALIPAY_APP_ID")
if AlipayAppId == "" {
panic("环境变量 ALIPAY_APP_ID 的值不能为空")
}
AlipayAppPrivateKey := os.Getenv("ALIPAY_APP_PRIVATE_KEY")
if AlipayAppPrivateKey == "" {
panic("环境变量 ALIPAY_APP_PRIVATE_KEY 的值不能为空")
}
AlipayPublicKey := os.Getenv("ALIPAY_PUBLIC_KEY")
if AlipayPublicKey == "" {
panic("环境变量 ALIPAY_PUBLIC_KEY 的值不能为空")
}
AlipayEncryptKey := os.Getenv("ALIPAY_ENCRYPT_KEY")
if AlipayEncryptKey == "" {
panic("环境变量 ALIPAY_ENCRYPT_KEY 的值不能为空")
}
_AlipayProduction := os.Getenv("ALIPAY_PRODUCTION")
if _AlipayProduction != "" {
value, err := strconv.ParseBool(_AlipayProduction)
if err != nil {
panic("环境变量 ALIPAY_PRODUCTION 的值不是布尔值")
}
AlipayProduction = value
}
}
// endregion
// region debug
var (
@@ -228,4 +270,5 @@ func Init() {
loadLog()
loadDebug()
loadRemote()
loadAlipay()
}