120 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package define ...
 | |
| //
 | |
| // Description : 数据定义
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 2021-03-01 9:27 下午
 | |
| package define
 | |
| 
 | |
| import "git.zhangdeman.cn/zhangdeman/consts"
 | |
| 
 | |
| // DBConfig 数据库连接的配置
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 9:32 下午 2021/3/1
 | |
| type DBConfig struct {
 | |
| 	Host       string     `json:"host" yaml:"host"`             // 主机
 | |
| 	Port       int        `json:"port" yaml:"port"`             // 端口
 | |
| 	Database   string     `json:"database" yaml:"database"`     // 数据库
 | |
| 	Username   string     `json:"username"  yaml:"username"`    // 账号
 | |
| 	Password   string     `json:"password" yaml:"password"`     // 密码
 | |
| 	Charset    string     `json:"charset" yaml:"charset"`       // 编码
 | |
| 	Connection Connection `json:"connection" yaml:"connection"` // 连接数量配置
 | |
| }
 | |
| 
 | |
| // CfgFile 配置文件定义
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 14:47 2022/6/9
 | |
| type CfgFile struct {
 | |
| 	Flag   string          `json:"flag"`   // 数据库标识
 | |
| 	Path   string          `json:"path"`   // 配置文件路径
 | |
| 	Type   consts.FileType `json:"type"`   // 配置文件类型
 | |
| 	Config *Database       `json:"config"` // 解析之后的配置文件
 | |
| }
 | |
| 
 | |
| // Database 数据库配置
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 15:19 2022/6/9
 | |
| type Database struct {
 | |
| 	Master *Driver `json:"master" yaml:"master" toml:"master" ini:"master"` // 主库配置
 | |
| 	Slave  *Driver `json:"slave" yaml:"slave" toml:"slave" ini:"slave"`     // 从库配置
 | |
| }
 | |
| 
 | |
| // Driver ...
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 18:44 2022/5/14
 | |
| type Driver struct {
 | |
| 	DBType     string      `json:"db_type" yaml:"db_type" toml:"db_type" ini:"db_type"`             // 数据库驱动类型
 | |
| 	Host       string      `json:"host" yaml:"host" toml:"host" ini:"host"`                         // 数据库地址
 | |
| 	Port       int         `json:"port" yaml:"port" toml:"port" ini:"port"`                         // 数据库端口
 | |
| 	Username   string      `json:"username" yaml:"username" toml:"username" ini:"username"`         // 用户名
 | |
| 	Password   string      `json:"password" yaml:"password" toml:"password" ini:"password"`         // 密码
 | |
| 	Database   string      `json:"database" yaml:"database" toml:"database" ini:"database"`         // 数据库
 | |
| 	Charset    string      `json:"charset" yaml:"charset" toml:"charset" ini:"charset"`             // 数据库编码
 | |
| 	Connection *Connection `json:"connection" yaml:"connection" toml:"connection" ini:"connection"` // 连接配置
 | |
| 	Timezone   string      `json:"timezone" yaml:"timezone" toml:"timezone" ini:"timezone"`         // 时区
 | |
| }
 | |
| 
 | |
| // Connection 连接数配置
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 15:18 2022/6/9
 | |
| type Connection struct {
 | |
| 	MaxOpen int `json:"max_open" yaml:"max_open" toml:"max_open" ini:"max_open"` // 最大打开连接数
 | |
| 	MaxIdle int `json:"max_idle" yaml:"max_idle" toml:"max_idle" ini:"max_idle"` // 最大的处理连接数
 | |
| }
 | |
| 
 | |
| // DescTableItem 表结构的描述
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 22:45 2023/8/16
 | |
| type DescTableItem struct {
 | |
| 	Default *string `json:"Default"` // 默认值
 | |
| 	Extra   string  `json:"Extra"`   // 扩展信息
 | |
| 	Field   string  `json:"field"`   // 字段名
 | |
| 	Key     string  `json:"Key"`     // 索引信息
 | |
| 	Null    string  `json:"Null"`    // 是否允许为NUll
 | |
| 	Type    string  `json:"Type"`    // 字段类型
 | |
| 	Comment string  `json:"Comment"` // 字段注释
 | |
| }
 | |
| 
 | |
| // ColumnInfo 表字段结构,INFORMATION_SCHEMA.COLUMNS 标的查询结果
 | |
| //
 | |
| // Author : go_developer@163.com<白茶清欢>
 | |
| //
 | |
| // Date : 23:00 2023/8/16
 | |
| type ColumnInfo struct {
 | |
| 	TableCatalog           string `json:"TABLE_CATALOG" gorm:"column:TABLE_CATALOG;default:;NOT NULL"`                         // TABLE_CATALOG
 | |
| 	TableSchema            string `json:"TABLE_SCHEMA" gorm:"column:TABLE_SCHEMA;default:;NOT NULL"`                           // TABLE_SCHEMA
 | |
| 	TableName              string `json:"TABLE_NAME" gorm:"column:TABLE_NAME;default:;NOT NULL"`                               // TABLE_NAME
 | |
| 	ColumnName             string `json:"COLUMN_NAME" gorm:"column:COLUMN_NAME;default:;NOT NULL"`                             // COLUMN_NAME
 | |
| 	OrdinalPosition        int64  `json:"ORDINAL_POSITION" gorm:"column:ORDINAL_POSITION;default:;NOT NULL"`                   // ORDINAL_POSITION
 | |
| 	ColumnDefault          string `json:"COLUMN_DEFAULT" gorm:"column:COLUMN_DEFAULT;default:;{NOT_NULL}"`                     // COLUMN_DEFAULT
 | |
| 	IsNullable             string `json:"IS_NULLABLE" gorm:"column:IS_NULLABLE;default:;NOT NULL"`                             // IS_NULLABLE
 | |
| 	DataType               string `json:"DATA_TYPE" gorm:"column:DATA_TYPE;default:;NOT NULL"`                                 // DATA_TYPE
 | |
| 	CharacterMaximumLength int64  `json:"CHARACTER_MAXIMUM_LENGTH" gorm:"column:CHARACTER_MAXIMUM_LENGTH;default:;{NOT_NULL}"` // CHARACTER_MAXIMUM_LENGTH
 | |
| 	CharacterOctetLength   int64  `json:"CHARACTER_OCTET_LENGTH" gorm:"column:CHARACTER_OCTET_LENGTH;default:;{NOT_NULL}"`     // CHARACTER_OCTET_LENGTH
 | |
| 	NumericPrecision       int64  `json:"NUMERIC_PRECISION" gorm:"column:NUMERIC_PRECISION;default:;{NOT_NULL}"`               // NUMERIC_PRECISION
 | |
| 	NumericScale           int64  `json:"NUMERIC_SCALE" gorm:"column:NUMERIC_SCALE;default:;{NOT_NULL}"`                       // NUMERIC_SCALE
 | |
| 	DatetimePrecision      int64  `json:"DATETIME_PRECISION" gorm:"column:DATETIME_PRECISION;default:;{NOT_NULL}"`             // DATETIME_PRECISION
 | |
| 	CharacterSetName       string `json:"CHARACTER_SET_NAME" gorm:"column:CHARACTER_SET_NAME;default:;{NOT_NULL}"`             // CHARACTER_SET_NAME
 | |
| 	CollationName          string `json:"COLLATION_NAME" gorm:"column:COLLATION_NAME;default:;{NOT_NULL}"`                     // COLLATION_NAME
 | |
| 	ColumnType             string `json:"COLUMN_TYPE" gorm:"column:COLUMN_TYPE;default:;NOT NULL"`                             // COLUMN_TYPE
 | |
| 	ColumnKey              string `json:"COLUMN_KEY" gorm:"column:COLUMN_KEY;default:;NOT NULL"`                               // COLUMN_KEY
 | |
| 	Extra                  string `json:"EXTRA" gorm:"column:EXTRA;default:;NOT NULL"`                                         // EXTRA
 | |
| 	Privileges             string `json:"PRIVILEGES" gorm:"column:PRIVILEGES;default:;NOT NULL"`                               // PRIVILEGES
 | |
| 	ColumnComment          string `json:"COLUMN_COMMENT" gorm:"column:COLUMN_COMMENT;default:;NOT NULL"`                       // COLUMN_COMMENT
 | |
| 	IsGenerated            string `json:"IS_GENERATED" gorm:"column:IS_GENERATED;default:;NOT NULL"`                           // IS_GENERATED
 | |
| 	GenerationExpression   string `json:"GENERATION_EXPRESSION" gorm:"column:GENERATION_EXPRESSION;default:;{NOT_NULL}"`       // GENERATION_EXPRESSION
 | |
| }
 |