1 Star 1 Fork 1

xiaoyutab / xgotool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
init.go 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
xiaoyutab 提交于 2024-04-17 10:21 . xlog结构调整
// 数据库存储数据
package xdist
import (
"sync"
"gorm.io/gorm"
)
// 配置信息
type Config struct {
DB *gorm.DB // 数据库连接
DistTable string // 字典配置表名
nvk sync.Map // 字典的键值对缓存
vnk sync.Map // 字典的键值对对应的缓存
gpk sync.Map // 字典分组缓存
}
var _default Config = Config{
DistTable: "xdist",
}
func Regedit(c *Config) {
if c == nil {
return
}
if c.DB != nil {
_default.DB = c.DB
}
if c.DistTable != "" {
_default.DistTable = c.DistTable
}
if _default.DB != nil {
_default.DB.AutoMigrate(&DistInfo{})
}
}
// 字典表结构信息
type DistInfo struct {
Id uint `gorm:"column:id;type:int unsigned;primaryKey;autoIncrement;not null" form:"id" json:"id" xml:"id"`
Groups string `gorm:"column:groups;type:varchar(100);comment:所属分组" form:"groups" json:"groups" xml:"groups"` // 所属分组
Name string `gorm:"column:name;type:varchar(100);comment:下标名称" form:"name" json:"name" xml:"name"` // 下标名称
Value string `gorm:"column:value;type:varchar(300);comment:存储值" form:"value" json:"value" xml:"value"` // 存储的值
CreatedAt string `gorm:"column:created_at;type:datetime;comment:添加时间" form:"created_at" json:"created_at" xml:"created_at"` // 添加时间
}
func (c *DistInfo) TableName() string {
return _default.DistTable
}
Go
1
https://gitee.com/xiaoyutab/xgotool.git
git@gitee.com:xiaoyutab/xgotool.git
xiaoyutab
xgotool
xgotool
v0.3.9

搜索帮助

53164aa7 5694891 3bd8fe86 5694891