- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE - WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置 - WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页 - 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面 - Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理 - 清理各项目球形磨遗留代码,新增部署手册.md
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
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 token(X-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
|
||
}
|