Files
bj_power/bj_power_mes/internal/config/config.go
T

75 lines
2.5 KiB
Go
Raw Normal View History

2026-08-28 15:06:01 +08:00
package config
import (
"bj_power_mes/common/logx"
"bj_power_mes/internal/db"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/rest"
)
// Config 全局配置
type Config struct {
rest.RestConf // 自带 Host/Port 等
Database db.DatabaseConf
Redis RedisConfWrapper
Auth AuthConf
Internal InternalConf
Cli CliConf
Logger logx.LogConf
Wms WmsConf
Plc PlcConf
Upload UploadConf
2026-08-28 15:06:01 +08:00
}
type RedisConfWrapper struct {
redis.RedisConf
}
// AuthConf 鉴权配置:JWT Secret / 有效期
// 只保留滑动续签:AccessExpire = 会话闲置窗口
2026-08-28 15:06:01 +08:00
type AuthConf struct {
AccessSecret string `json:",default=Hardman_2026"`
AccessExpire int64 `json:",default=3600"` // 会话闲置窗口(秒),滑动续签下 = 距最后请求多久后需重登
2026-08-28 15:06:01 +08:00
}
// InternalConf 内部服务间鉴权
type InternalConf struct {
Token string `json:",default=Hardman_2026"`
}
// CliConf 命令行敏感操作门禁密码(与管理员账号密码保持一致,改密时自动同步)
type CliConf struct {
AdminPassword string `json:"AdminPassword,default=Hardman_2026"`
}
2026-08-28 15:06:01 +08:00
// WmsConf WMS 内部服务地址
type WmsConf struct {
BaseURL string `json:",default="`
Token string `json:",default=Hardman_2026"`
}
// PlcConf PLC 对接配置(mock 时不用)
type PlcConf struct {
Enable bool `json:",default=false"`
Host string `json:",default=127.0.0.1"`
Port int `json:",default=102"`
}
// UploadConf 附件统一存储配置。
// Dir 即附件根目录(相对服务启动目录或绝对路径),落盘结构:Dir/年/月/日/<文件类型>/<uuid>.<ext>。
type UploadConf struct {
Dir string `json:",default=uploads"`
MaxMB int64 `json:",default=20"` // 单文件默认上限(MB
// 按文件类型覆盖上限(字节),键为大写枚举,如 PROCESS_PDF: 52428800
MaxSize map[string]int64 `json:",optional"`
// 本地保留年数(超过该年数的附件可归档到 ArchiveDir 后释放本地空间)
LocalRetentionYears int `json:",default=1"`
// 归档备份目录(NAS/移动硬盘等);为空时归档只标记不移动
ArchiveDir string `json:",default="`
// 磁盘空间监控:每天 DiskCheckHour 点检测一次
DiskWarnPercent int `json:",default=20"` // 剩余低于该百分比告警
DiskCriticalPercent int `json:",default=10"` // 剩余低于该百分比提示清理
DiskCheckHour int `json:",default=7"` // 每天检测时刻(0~23
}