mysql

package
v0.0.0-...-03f4900 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(dsn string)

Connect create db connection

func Migrate

func Migrate()

Migrate the db schema

Types

type Base

type Base struct {
	ID        int       `gorm:"primary_key"`
	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

base

type CloudInfo

type CloudInfo struct {
	Base
	Cloud            string `gorm:"type:varchar(10)"`      //云厂商
	InstanceId       string `gorm:"not null;index;unique"` //实例ID
	InstanceName     string `gorm:"type:varchar(100)"`     //实例名称
	PrivateIp        string `gorm:"type:varchar(20)"`      //内网IP
	Port             int    `gorm:"type:varchar(10)"`      //端口
	Region           string `gorm:"type:varchar(20)"`      //region
	Createtime       string `gorm:"type:varchar(20)"`      //创建时间
	Size             int    `gorm:"type:varchar(10)"`      //实例大小
	InstanceStatus   string `gorm:"type:varchar(10)"`      //实例状态
	RedisShardSize   int    `gorm:"type:varchar(10)"`      //分片大小
	RedisShardNum    int    `gorm:"type:varchar(10)"`      //分练数量
	RedisReplicasNum int    `gorm:"type:varchar(10)"`      //副本个数
	NoAuth           bool   `gorm:"type:varchar(10)"`      //是否需要密码
	PublicIp         string `gorm:"type:varchar(20)"`      //外网IP
	Password         string `gorm:"type:varchar(50)"`      //密码
}

cloud redis信息

func (CloudInfo) TableName

func (CloudInfo) TableName() string

type ClusterInfo

type ClusterInfo struct {
	Base
	Name     string `gorm:"not null;index;unique"`
	Nodes    string `gorm:"type:varchar(255)"` //ip:port,ip:port
	Password string `gorm:"type:varchar(255)"`
}

集群信息

func (ClusterInfo) TableName

func (ClusterInfo) TableName() string

type ClusterNode

type ClusterNode struct {
	Base
	CluserId   int    `gorm:"not null;index"`          //集群ID
	NodeId     string `gorm:"type:varchar(50);unique"` //node的ID
	Ip         string `gorm:"type:varchar(50)"`        //node的IP
	Port       string `gorm:"type:varchar(25)"`        //node的端口
	Flags      string `gorm:"type:varchar(50)"`        //node的身份
	MasterId   string `gorm:"type:varchar(50)"`        //如果是从的话master的ID
	LinkState  string `gorm:"type:varchar(50)"`        //链接状态
	RunStatus  bool   `gorm:"type:varchar(25)"`        //运行状态
	SlotRange  string `gorm:"type:varchar(50)"`        //slot区间
	SlotNumber int    `gorm:"type:varchar(25)"`        //solt个数
}

node信息

func (ClusterNode) TableName

func (ClusterNode) TableName() string

type CodisInfo

type CodisInfo struct {
	Base
	Curl  string `gorm:"not null;index;unique"`
	Cname string `gorm:"type:varchar(50)"`
}

codis信息

func (CodisInfo) TableName

func (CodisInfo) TableName() string

type GroupContain

type GroupContain struct {
	Base
	GroupId int `gorm:"not null;index"`
	UserId  int `gorm:"not null;index"`
}

组与用户的关系

func (GroupContain) TableName

func (GroupContain) TableName() string

type MySQL

type MySQL struct {
	*gorm.DB
}

MySQL refrence a mysql db

var DB MySQL

DB as the mysql client

func (*MySQL) AddAliCloudRedis

func (m *MySQL) AddAliCloudRedis(cloud string, redisinfo model.AliRedisInstancesKVStoreInstance) (int, bool)

func (*MySQL) AddCfg

func (m *MySQL) AddCfg(name, key, value string) (int, bool)

add cfg

func (*MySQL) AddCluster

func (m *MySQL) AddCluster(name, nodes, password string) (int, bool)

add cluster

func (*MySQL) AddClusterNode

func (m *MySQL) AddClusterNode(nodeid, ip, port, flags, masterid, linkstate, slotrange string, clusterid, slotnumber int) (int, bool)

func (*MySQL) AddCodis

func (m *MySQL) AddCodis(curl, cname string) (int, bool)

func (*MySQL) AddHistory

func (m *MySQL) AddHistory(userid int, opinfo, opparams string) (int, bool)

add cluster

func (*MySQL) AddTxCloudRedis

func (m *MySQL) AddTxCloudRedis(cloud string, redisinfo model.TxLResponseInstanceSet) (int, bool)

func (*MySQL) CreatUser

func (m *MySQL) CreatUser(nick_name, email, password string) bool

func (*MySQL) DelCfg

func (m *MySQL) DelCfg(key string) bool

func (*MySQL) DelCloud

func (m *MySQL) DelCloud(instanceid string) bool

func (*MySQL) DelUser

func (m *MySQL) DelUser(userid int) bool

func (*MySQL) ExistCfg

func (m *MySQL) ExistCfg(key string) bool

check cfg

func (*MySQL) ExistCloudredisId

func (m *MySQL) ExistCloudredisId(cloud, instanceId string) bool

func (*MySQL) ExistUserId

func (m *MySQL) ExistUserId(id int) bool

func (*MySQL) ExistUserName

func (m *MySQL) ExistUserName(username string) bool

func (*MySQL) FindEmail

func (m *MySQL) FindEmail(email string) bool

func (*MySQL) FindUser

func (m *MySQL) FindUser(ruser string) bool

func (*MySQL) FindUserPassword

func (m *MySQL) FindUserPassword(ruser string) (user UserInfo, err error)

func (*MySQL) GetAllCfg

func (m *MySQL) GetAllCfg() []Rconfig

get all cfg

func (*MySQL) GetAllCloudredis

func (m *MySQL) GetAllCloudredis() []CloudInfo

cloud redis list

func (*MySQL) GetAllCluster

func (m *MySQL) GetAllCluster() []ClusterInfo

get all cluster

func (*MySQL) GetAllCodis

func (m *MySQL) GetAllCodis() []CodisInfo

get codis

func (*MySQL) GetAllHistory

func (m *MySQL) GetAllHistory() []OpHistory

func (*MySQL) GetAllUser

func (m *MySQL) GetAllUser() []UserInfo

func (*MySQL) GetCloudAddress

func (m *MySQL) GetCloudAddress(cloud, instanceid string) (string, string, int)

func (*MySQL) GetCloudNumber

func (m *MySQL) GetCloudNumber(cloud string) int64

func (*MySQL) GetCloudRegion

func (m *MySQL) GetCloudRegion() []CloudInfo

func (*MySQL) GetCloudredis

func (m *MySQL) GetCloudredis(cloud, region string) []CloudInfo

func (*MySQL) GetClusterAddress

func (m *MySQL) GetClusterAddress(id string) (string, string)

func (*MySQL) GetClusterNode

func (m *MySQL) GetClusterNode(cluster string) []ClusterNode

func (*MySQL) GetClusterNodeMaster

func (m *MySQL) GetClusterNodeMaster(cluster string) []ClusterNode

func (*MySQL) GetClusterNodeMasterAddress

func (m *MySQL) GetClusterNodeMasterAddress(nodeid string) string

func (*MySQL) GetClusterNodeSlaverAddress

func (m *MySQL) GetClusterNodeSlaverAddress(nodeid string) string

func (*MySQL) GetClusterNumber

func (m *MySQL) GetClusterNumber() int64

func (*MySQL) GetClusterPassword

func (m *MySQL) GetClusterPassword(id string) string

func (*MySQL) GetCodisNumber

func (m *MySQL) GetCodisNumber() int64

func (*MySQL) GetOneCfg

func (m *MySQL) GetOneCfg(key string) Rconfig

get one cfg

func (*MySQL) GetOneCfgValue

func (m *MySQL) GetOneCfgValue(key string) string

get one cfg value

func (*MySQL) GetUserType

func (m *MySQL) GetUserType(userid int) string

func (*MySQL) UpdateCfg

func (m *MySQL) UpdateCfg(key, value string) bool

update cfg

func (*MySQL) UpdateCloudPassword

func (m *MySQL) UpdateCloudPassword(cloud, instanceid, password string) bool

func (*MySQL) UpdateUserPassword

func (m *MySQL) UpdateUserPassword(username string, password string) bool

func (*MySQL) UpdateUserType

func (m *MySQL) UpdateUserType(username string, usertype string) bool

func (*MySQL) UppdateAliCloudRedis

func (m *MySQL) UppdateAliCloudRedis(cloud string, redisinfo model.AliRedisInstancesKVStoreInstance) bool

ali

func (*MySQL) UppdateTxCloudRedis

func (m *MySQL) UppdateTxCloudRedis(cloud string, redisinfo model.TxLResponseInstanceSet) bool

tx

func (*MySQL) UserInfo

func (m *MySQL) UserInfo(username string) UserInfo

type OpHistory

type OpHistory struct {
	Base
	UserId   int    `gorm:"not null;index"`
	OpInfo   string `gorm:"type:varchar(100)"` // 操作动作
	OpParams string `gorm:"type:text"`         //操作参数属组或者对象
}

操作历史

func (OpHistory) TableName

func (OpHistory) TableName() string

type Rconfig

type Rconfig struct {
	Base
	Name  string `gorm:"type:varchar(255)"`
	Key   string `gorm:"not null:index:primary_key;unique"`
	Value string `gorm:"type:varchar(255)"`
}

config信息

func (Rconfig) TableName

func (Rconfig) TableName() string

type Tabler

type Tabler interface {
	TableName() string
}

type UserGroup

type UserGroup struct {
	Base
	GroupName     string `gorm:"not null;index;unique"`
	GroupDescribe string `gorm:"type:varchar(255)"`
	GroupType     string `gorm:"not null;index;type:varchar(50)"` //admin 管理组;visitor 访客组;staff 员工组
}

用户组

func (UserGroup) TableName

func (UserGroup) TableName() string

type UserInfo

type UserInfo struct {
	Base
	UserName string `gorm:"not null;index;unique"`
	Password string `gorm:"not null"`
	Email    string `gorm:"type:varchar(255)"`
	UserType string `gorm:"not null;index;type:varchar(50)"` //admin 管理员;visitor 访客;staff 员工
	Enable   bool   // 0是封禁False,1是可登录True
}

用户

func (UserInfo) TableName

func (UserInfo) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL