mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-10-13 12:49:26 +00:00
* feat: 调整AI工作模式,更符合harness基准 * feat: 添加BusinessDB字段到PluginInitializeGorm结构体,并增加相关测试用例 * [middleware/jwt.go]: fix #2192 issues bug * docs: add auto plugin design spec * chore: ignore worktrees directory * feat: 调整代码辅助能力至插件 * feat: 添加警告条组件,提示授权用户访问限制 * fix: 修正商业用途版权声明链接 * feat: 调整agent.md 更加节省token * fix: 修改casbin版本为v3 * feat: 更新JSONMap和JSONSlice类型,优化GORM数据类型处理 * feat: 添加数据库就绪通知机制,优化插件注册流程 * feat: 重构API路径和描述,优化代码生成器和模板配置分组 * feat: 优化 person 页面的 css 作用域限制 * feat: 更新 vite 至 vite8 * 新增:MCP工具为指定URL的角色ID授权 * fix: 增加文件名合法性检查,拒绝包含非法字符的文件写入 * chore: 更新CI配置,升级Node.js和Go版本,调整checkout和setup动作版本 * feat: 为数据库连接增加最大复用时间配置 * feat: 为各数据库连接配置增加最大连接生命周期设置 * feat: 更新插件注册逻辑并优化API和菜单组件的标签显示 * feat: 更新版本号至v2.9.2并添加新插件路径信息 --------- Co-authored-by: taincheng <zhangtc@gmail.com> Co-authored-by: Azir-11 <2075125282@qq.com> Co-authored-by: lanxi <1220lanxi@gmail.com>
55 lines
2.8 KiB
Go
55 lines
2.8 KiB
Go
package config
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"gorm.io/gorm/logger"
|
|
)
|
|
|
|
type DsnProvider interface {
|
|
Dsn() string
|
|
}
|
|
|
|
// Embeded 结构体可以压平到上一层,从而保持 config 文件的结构和原来一样
|
|
// 见 playground: https://go.dev/play/p/KIcuhqEoxmY
|
|
|
|
// GeneralDB 也被 Pgsql 和 Mysql 原样使用
|
|
type GeneralDB struct {
|
|
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 数据库前缀
|
|
Port string `mapstructure:"port" json:"port" yaml:"port"` // 数据库端口
|
|
Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置
|
|
Dbname string `mapstructure:"db-name" json:"db-name" yaml:"db-name"` // 数据库名
|
|
Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库账号
|
|
Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码
|
|
Path string `mapstructure:"path" json:"path" yaml:"path"` // 数据库地址
|
|
Engine string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"` // 数据库引擎,默认InnoDB
|
|
LogMode string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"` // 是否开启Gorm全局日志
|
|
MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数
|
|
MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
|
|
ConnMaxLifetime int `mapstructure:"conn-max-lifetime" json:"conn-max-lifetime" yaml:"conn-max-lifetime"` // 连接最长复用时间,单位秒
|
|
Singular bool `mapstructure:"singular" json:"singular" yaml:"singular"` // 是否开启全局禁用复数,true表示开启
|
|
LogZap bool `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"` // 是否通过zap写入日志文件
|
|
}
|
|
|
|
func (c GeneralDB) LogLevel() logger.LogLevel {
|
|
switch strings.ToLower(c.LogMode) {
|
|
case "silent":
|
|
return logger.Silent
|
|
case "error":
|
|
return logger.Error
|
|
case "warn":
|
|
return logger.Warn
|
|
case "info":
|
|
return logger.Info
|
|
default:
|
|
return logger.Info
|
|
}
|
|
}
|
|
|
|
type SpecializedDB struct {
|
|
Type string `mapstructure:"type" json:"type" yaml:"type"`
|
|
AliasName string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name"`
|
|
GeneralDB `yaml:",inline" mapstructure:",squash"`
|
|
Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"`
|
|
}
|