2024-08-20 18:14:57 +08:00
|
|
|
// Package abstract ...
|
|
|
|
//
|
|
|
|
// Description : abstract ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2024-08-20 17:59
|
|
|
|
package abstract
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.zhangdeman.cn/zhangdeman/database/define"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// IWrapperDatabaseClient 包装gorm
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 18:00 2024/8/20
|
|
|
|
type IWrapperDatabaseClient interface {
|
|
|
|
// Init 初始化客户端连接
|
2024-08-21 16:01:48 +08:00
|
|
|
Init(databaseConfig *define.Database, cacheTableStructureConfig *define.CacheTableStructureConfig) error
|
2024-08-20 18:14:57 +08:00
|
|
|
// GetMaster 获取master连接
|
|
|
|
GetMaster(ctx context.Context) *gorm.DB
|
|
|
|
// GetSlave 获取slave连接
|
|
|
|
GetSlave(ctx context.Context) *gorm.DB
|
|
|
|
// GetDatabaseClient 获取数据库连接
|
|
|
|
GetDatabaseClient(conf *define.Driver, logInstance *zap.Logger) (*gorm.DB, error)
|
2024-08-21 16:01:48 +08:00
|
|
|
// CacheDataTableStructureConfig 缓存数据表结构的配置
|
|
|
|
CacheDataTableStructureConfig() *define.CacheTableStructureConfig
|
|
|
|
// GetTableFieldList 获取指定表数据字段列表
|
2024-08-23 17:29:11 +08:00
|
|
|
GetTableFieldList(tableName string) ([]*define.ColumnConfig, error)
|
|
|
|
// SetTableStructure 设置数据表结构
|
|
|
|
SetTableStructure(tableConfigTable map[string][]*define.ColumnConfig)
|
2024-08-20 18:14:57 +08:00
|
|
|
}
|