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 {
|
2026-08-28 17:03:03 +08:00
|
|
|
|
rest.RestConf // 自带 Host/Port 等
|
|
|
|
|
|
Database db.DatabaseConf
|
|
|
|
|
|
Redis RedisConfWrapper
|
|
|
|
|
|
Auth AuthConf
|
|
|
|
|
|
Internal InternalConf
|
|
|
|
|
|
Cli CliConf
|
|
|
|
|
|
Logger logx.LogConf
|
|
|
|
|
|
Wms WmsConf
|
|
|
|
|
|
Plc PlcConf
|
2026-08-31 08:06:55 +08:00
|
|
|
|
Upload UploadConf
|
2026-08-28 15:06:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type RedisConfWrapper struct {
|
|
|
|
|
|
redis.RedisConf
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AuthConf 鉴权配置:JWT Secret / 有效期
|
2026-09-10 16:59:15 +08:00
|
|
|
|
// 只保留滑动续签:AccessExpire = 会话闲置窗口
|
2026-08-28 15:06:01 +08:00
|
|
|
|
type AuthConf struct {
|
2026-09-10 16:59:15 +08:00
|
|
|
|
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"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-28 17:03:03 +08:00
|
|
|
|
// 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 {
|
2026-08-28 17:03:03 +08:00
|
|
|
|
Enable bool `json:",default=false"`
|
|
|
|
|
|
Host string `json:",default=127.0.0.1"`
|
|
|
|
|
|
Port int `json:",default=102"`
|
|
|
|
|
|
}
|
2026-08-31 08:06:55 +08:00
|
|
|
|
|
2026-09-19 10:54:15 +08:00
|
|
|
|
// UploadConf 附件统一存储配置。
|
|
|
|
|
|
// Dir 即附件根目录(相对服务启动目录或绝对路径),落盘结构:Dir/年/月/日/<文件类型>/<uuid>.<ext>。
|
2026-08-31 08:06:55 +08:00
|
|
|
|
type UploadConf struct {
|
|
|
|
|
|
Dir string `json:",default=uploads"`
|
2026-09-19 10:54:15 +08:00
|
|
|
|
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)
|
2026-08-31 08:06:55 +08:00
|
|
|
|
}
|