26 lines
1.1 KiB
Go
26 lines
1.1 KiB
Go
package models
|
||
|
||
import (
|
||
"time"
|
||
)
|
||
|
||
// DbConnection 数据库连接配置
|
||
type DbConnection struct {
|
||
ID uint `gorm:"primaryKey" json:"id"`
|
||
Name string `gorm:"type:varchar(100);not null" json:"name"` // 连接名称
|
||
Type string `gorm:"type:varchar(20);not null" json:"type"` // 数据库类型: mysql/redis/mongo
|
||
Host string `gorm:"type:varchar(255);not null" json:"host"` // 主机地址
|
||
Port int `gorm:"not null" json:"port"` // 端口
|
||
Username string `gorm:"type:varchar(100)" json:"username"` // 用户名
|
||
Password string `gorm:"type:varchar(500)" json:"-"` // 密码(加密存储,不返回)
|
||
Database string `gorm:"type:varchar(100)" json:"database"` // 数据库名(MySQL/MongoDB)
|
||
Options string `gorm:"type:text" json:"options"` // 额外选项(JSON格式)
|
||
CreatedAt time.Time `json:"created_at"`
|
||
UpdatedAt time.Time `json:"updated_at"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (DbConnection) TableName() string {
|
||
return "db_connection"
|
||
}
|