- 新增用户与上传错误码文件及 Recovery 中间件 - 修复 router.go 导入与中间件链,注册用户路由并补 handler 错误码导入 - 补充用户状态常量与 UserGetByWechatOpenID 查询,修订刷新令牌 dto - 移除 upload 包 OTel 调用,新增 FileUploadCos 上传封装 - 实现 UserService 微信登录/刷新令牌/我的信息/改资料/上传头像 - 裁剪 main.go 配置段并移除 OTel 桥接,补启动与优雅退出 - 新增 configs 示例配置、global 配置结构及 go.mod 依赖
85 lines
1.8 KiB
Go
85 lines
1.8 KiB
Go
package setting
|
||
|
||
// ServerSettingS 服务配置。时间字段单位为秒(int),避免 time.Duration 对整数配置按纳秒解析的歧义。
|
||
type ServerSettingS struct {
|
||
Domain string // 服务域名(用于 CORS 允许来源,如 test.com)
|
||
RunMode string
|
||
HttpPort string
|
||
ReadTimeout int // 秒
|
||
WriteTimeout int // 秒
|
||
}
|
||
|
||
type LogSettingS struct {
|
||
LogSavePath string
|
||
LogFileName string
|
||
LogFileExt string
|
||
MaxSize int
|
||
MaxBackups int
|
||
MaxAge int
|
||
LogLevel string
|
||
}
|
||
|
||
type MysqlSettingS struct {
|
||
UserName string
|
||
Password string
|
||
Host string
|
||
Port int
|
||
DBName string
|
||
MaxIdleConns int
|
||
MaxOpenConns int
|
||
ConnMaxLifeTime int
|
||
ConnMaxIdleTime int
|
||
}
|
||
|
||
type RedisSettingS struct {
|
||
Host string
|
||
Port int
|
||
Password string
|
||
DB int
|
||
PoolSize int
|
||
MaxIdleConns int
|
||
MinIdleConns int
|
||
MaxRetryBackoff int
|
||
MinRetryBackoff int
|
||
MaxRetries int
|
||
DialTimeout int
|
||
ReadTimeout int
|
||
WriteTimeout int
|
||
PoolTimeout int
|
||
}
|
||
|
||
type JWTSettingS struct {
|
||
SecretKey string
|
||
Issuer string
|
||
AccessTokenExpire int // 秒
|
||
RefreshTokenExpire int // 秒
|
||
}
|
||
|
||
type UploadSettingS struct {
|
||
TmpSavePath string
|
||
MaxSizeMB int
|
||
AllowedExtensions []string
|
||
}
|
||
|
||
type CosSettingS struct {
|
||
CosSecretID string
|
||
CosSecretKey string
|
||
CosUploadDomain string
|
||
CosDownloadDomain string
|
||
CdnDownloadSecretKey string
|
||
}
|
||
|
||
// WechatMiniSettingS 微信小程序配置(用于 code2session 登录)。
|
||
type WechatMiniSettingS struct {
|
||
AppID string
|
||
AppSecret string
|
||
}
|
||
|
||
func (s *Setting) ReadSection(k string, v any) error {
|
||
err := s.vp.UnmarshalKey(k, v)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
return nil
|
||
}
|