- 在 config.go 中增加对环境变量的读取逻辑 - 更新 Dockerfile,添加新的环境变量 - 移除 views/merchant.html 中的多余支付选项 - 在 supplier.go 中添加新的供应商 "七喜"
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/beego/beego/v2/core/config/env"
|
|
"github.com/beego/beego/v2/server/web"
|
|
"strings"
|
|
)
|
|
|
|
type RedisConfig struct {
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
Password string `json:"password"`
|
|
DB int `json:"db"`
|
|
}
|
|
|
|
type Secret struct {
|
|
Key string `json:"key"`
|
|
IV string `json:"iv"`
|
|
}
|
|
|
|
func GetGatewayHost() (url string) {
|
|
url = env.Get("gatewayAddr", url)
|
|
if url != "" {
|
|
if !strings.HasSuffix(url, "/") {
|
|
url += "/"
|
|
}
|
|
return
|
|
}
|
|
host, _ := web.AppConfig.String("gateway::host")
|
|
return host
|
|
}
|
|
|
|
func GetPortalHost() (url string) {
|
|
url = env.Get("portalAddr", url)
|
|
if url != "" {
|
|
return
|
|
}
|
|
host, _ := web.AppConfig.String("portal::host")
|
|
return host
|
|
}
|
|
|
|
func GetRedisConfig() (*RedisConfig, error) {
|
|
// 获取redis配置
|
|
redisConfig := &RedisConfig{}
|
|
err := web.AppConfig.Unmarshaler("redis", redisConfig)
|
|
// 使用redisConfig...}
|
|
return redisConfig, err
|
|
}
|
|
|
|
func GetSecret() *Secret {
|
|
// 获取secret配置
|
|
secret := &Secret{
|
|
Key: web.AppConfig.DefaultString("secret::key", "thisis32bitlongpassphraseimusing"),
|
|
IV: web.AppConfig.DefaultString("secret::iv", "1234567890123456"),
|
|
}
|
|
// 使用secret...
|
|
return secret
|
|
}
|