Documentation ¶
Index ¶
- Constants
- type Model
- type MultiTenancy
- func (mt *MultiTenancy) AddDB(tenantId string, db *gorm.DB)
- func (mt *MultiTenancy) AutoMigrate(db *gorm.DB, tenantId string, model Model)
- func (mt *MultiTenancy) DataIsolation(db *gorm.DB) (model Model, dataIsolation bool)
- func (mt *MultiTenancy) GetDBByTenantId(tenantId string) (db *gorm.DB, err error)
- func (mt *MultiTenancy) Initialize(db *gorm.DB) error
- func (mt *MultiTenancy) Name() string
- func (mt *MultiTenancy) Register(tenantTag string, conn TenantDBConn) *MultiTenancy
- func (mt *MultiTenancy) SetDataIsolation(model ...Model) (err error)
- func (mt *MultiTenancy) SetEncryptedSave(encrypt func(data string) (cipherTxt string, err error), ...)
- type MultiTenancyTag
- type TenantDBConn
Constants ¶
View Source
const DefaultTagName = "mt"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiTenancy ¶
MultiTenancy 多租户数据隔离插件
var MTPlugin *MultiTenancy
func (*MultiTenancy) AddDB ¶
func (mt *MultiTenancy) AddDB(tenantId string, db *gorm.DB)
AddDB *
- @Description: 注册数据库
- @receiver mt
- @param tenantId
- @param db
func (*MultiTenancy) AutoMigrate ¶
func (mt *MultiTenancy) AutoMigrate(db *gorm.DB, tenantId string, model Model)
AutoMigrate *
- @Description: 自动迁移
- @receiver mt
- @param db
- @param tenantId
- @param model
func (*MultiTenancy) DataIsolation ¶
func (mt *MultiTenancy) DataIsolation(db *gorm.DB) (model Model, dataIsolation bool)
DataIsolation *
- @Description: 是否进行数据隔离
- @receiver mt
- @param db
- @return dataIsolation
func (*MultiTenancy) GetDBByTenantId ¶
func (mt *MultiTenancy) GetDBByTenantId(tenantId string) (db *gorm.DB, err error)
GetDBByTenantId *
- @Description: 利用租户标识获取数据库
- @receiver mt
- @param tenantId
- @return db
- @return err
func (*MultiTenancy) Initialize ¶
func (mt *MultiTenancy) Initialize(db *gorm.DB) error
func (*MultiTenancy) Name ¶
func (mt *MultiTenancy) Name() string
func (*MultiTenancy) Register ¶
func (mt *MultiTenancy) Register(tenantTag string, conn TenantDBConn) *MultiTenancy
Register *
- @Description: 注册数据隔离插件
- @receiver mt
- @param dbMap 数据库Map
- @param tenantTag 数据隔离字段标识
- @return *MultiTenancy
func (*MultiTenancy) SetDataIsolation ¶
func (mt *MultiTenancy) SetDataIsolation(model ...Model) (err error)
SetDataIsolation *
- @Description: 获取数据隔离字段标识
- @receiver mt
- @return string
func (*MultiTenancy) SetEncryptedSave ¶
func (mt *MultiTenancy) SetEncryptedSave(encrypt func(data string) (cipherTxt string, err error), decrypt func(cipherTxt string) (data string, err error))
SetEncryptedSave *
- @Description: 注册加密存储
- @receiver mt
- @param encrypt
- @param decrypt
type MultiTenancyTag ¶
Click to show internal directories.
Click to hide internal directories.