- 新增订单查询与发货结果推送开放接口,支持 can_ship 与幂等 - 鉴权采用 X-Api-Key + Timestamp + Nonce + HMAC-SHA256 签名 - 订单扩展发货字段与 ship_logs,管理端增加发货记录与开放文档页
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package config
|
||
|
||
import (
|
||
"os"
|
||
"strconv"
|
||
)
|
||
|
||
type Config struct {
|
||
Port string
|
||
JWTSecret string
|
||
DBPath string
|
||
Mode string // debug / release
|
||
// OpenAPIKey 皮肤源头开放接口标识(Header: X-Api-Key,可公开给对接方)
|
||
OpenAPIKey string
|
||
// OpenAPISecret 签名密钥(仅用于 HMAC,不走 Header)
|
||
OpenAPISecret string
|
||
// OpenSignSkew 签名时间戳允许偏差(秒)
|
||
OpenSignSkew int64
|
||
}
|
||
|
||
func Load() *Config {
|
||
return &Config{
|
||
Port: getEnv("PORT", "8080"),
|
||
JWTSecret: getEnv("JWT_SECRET", "affiliate-dash-dev-secret-change-me"),
|
||
DBPath: getEnv("DB_PATH", "data/app.db"),
|
||
Mode: getEnv("GIN_MODE", "debug"),
|
||
OpenAPIKey: getEnv("OPEN_API_KEY", "sk_source_dev_key_change_me"),
|
||
OpenAPISecret: getEnv("OPEN_API_SECRET", "sk_source_dev_secret_change_me"),
|
||
OpenSignSkew: int64(getEnvInt("OPEN_SIGN_SKEW", 300)),
|
||
}
|
||
}
|
||
|
||
func getEnv(key, def string) string {
|
||
if v := os.Getenv(key); v != "" {
|
||
return v
|
||
}
|
||
return def
|
||
}
|
||
|
||
func getEnvInt(key string, def int) int {
|
||
if v := os.Getenv(key); v != "" {
|
||
if n, err := strconv.Atoi(v); err == nil {
|
||
return n
|
||
}
|
||
}
|
||
return def
|
||
}
|