Files
bj_power/bj_power_wms/internal/config/config.go
T
2026-08-28 15:06:01 +08:00

48 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
import (
"strconv"
"github.com/zeromicro/go-zero/rest"
)
type PostgresConfig struct {
Host string `yaml:"Host"`
Port int `yaml:"Port"`
User string `yaml:"User"`
Password string `yaml:"Password"`
DBName string `yaml:"DBName"`
SSLMode string `yaml:"SSLMode"`
}
type AuthConfig struct {
AccessSecret string `yaml:"AccessSecret"`
AccessExpire int64 `yaml:"AccessExpire"`
}
// InternalConfig 项目间内部 API 配置
type InternalConfig struct {
Token string `yaml:"Token"` // 写死的项目间 API tokenX-API-TOKEN
}
type Config struct {
rest.RestConf
Postgres PostgresConfig `yaml:"Postgres"`
Auth AuthConfig `yaml:"Auth"`
Internal InternalConfig `yaml:"Internal"`
Redis struct {
Host string `yaml:"Host"`
Type string `yaml:"Type"`
} `yaml:"Redis"`
}
// DSN 返回 PostgreSQL 连接串
func (p PostgresConfig) DSN() string {
return "host=" + p.Host +
" port=" + strconv.Itoa(p.Port) +
" user=" + p.User +
" password=" + p.Password +
" dbname=" + p.DBName +
" sslmode=" + p.SSLMode
}