Documentation
¶
Index ¶
- Variables
- func CloseDB(ctx context.Context) error
- func InitMysql(ctx context.Context)
- type AppConfigLoadedEventListener
- type AppShutDownEventListener
- type BaseDao
- func (b *BaseDao[T]) Delete(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) DeleteById(ctx context.Context, id any, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) DeleteByIds(ctx context.Context, ids any, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) Exists(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (bool, error)
- func (b *BaseDao[T]) Insert(ctx context.Context, entity *T, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) InsertBatch(ctx context.Context, entities []*T, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) InsertBatchSize(ctx context.Context, entities []*T, batchSize int, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) NewQueryCond() (*gplus.QueryCond[T], *T)
- func (b *BaseDao[T]) SelectById(ctx context.Context, id any, opts ...gplus.OptionFunc) (*T, error)
- func (b *BaseDao[T]) SelectByIds(ctx context.Context, ids any, opts ...gplus.OptionFunc) ([]*T, error)
- func (b *BaseDao[T]) SelectCount(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (int64, error)
- func (b *BaseDao[T]) SelectList(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ([]*T, error)
- func (b *BaseDao[T]) SelectOne(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (*T, error)
- func (b *BaseDao[T]) SelectPage(ctx context.Context, page *gplus.Page[T], q *gplus.QueryCond[T], ...) (*gplus.Page[T], error)
- func (b *BaseDao[T]) Update(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) UpdateById(ctx context.Context, entity *T, opts ...gplus.OptionFunc) error
- func (b *BaseDao[T]) UpdateZeroById(ctx context.Context, entity *T, opts ...gplus.OptionFunc) error
- type BaseDaoGeneric
- type BaseDaoStreamingGeneric
- type BaseDaoWithComparable
- type GormLogger
- func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *GormLogger) LogMode(level logger.LogLevel) logger.Interface
- func (l *GormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalDB *gorm.DB
GlobalDB 全局数据库实例
Functions ¶
Types ¶
type AppConfigLoadedEventListener ¶
type AppConfigLoadedEventListener struct{}
func (*AppConfigLoadedEventListener) GetOrder ¶
func (ace *AppConfigLoadedEventListener) GetOrder() int
func (*AppConfigLoadedEventListener) OnApplicationEvent ¶
func (ace *AppConfigLoadedEventListener) OnApplicationEvent(ctx context.Context, event *listener.AppConfigLoadedEvent)
type AppShutDownEventListener ¶
type AppShutDownEventListener struct{}
func (*AppShutDownEventListener) GetOrder ¶
func (l *AppShutDownEventListener) GetOrder() int
func (*AppShutDownEventListener) OnApplicationEvent ¶
func (l *AppShutDownEventListener) OnApplicationEvent(ctx context.Context, event *listener.AppShutdownEvent)
type BaseDao ¶
type BaseDao[T any] struct { }
func NewBaseDao ¶
func (*BaseDao[T]) Delete ¶
func (b *BaseDao[T]) Delete(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) error
Delete 根据条件删除记录
func (*BaseDao[T]) DeleteById ¶
DeleteById 根据 ID 删除记录
func (*BaseDao[T]) DeleteByIds ¶
DeleteByIds 根据 ID 批量删除记录
func (*BaseDao[T]) Exists ¶
func (b *BaseDao[T]) Exists(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (bool, error)
Exists 根据条件判断记录是否存在
func (*BaseDao[T]) InsertBatch ¶
func (b *BaseDao[T]) InsertBatch(ctx context.Context, entities []*T, opts ...gplus.OptionFunc) error
InsertBatch 批量插入多条记录
func (*BaseDao[T]) InsertBatchSize ¶
func (b *BaseDao[T]) InsertBatchSize( ctx context.Context, entities []*T, batchSize int, opts ...gplus.OptionFunc) error
InsertBatchSize 批量插入多条记录
func (*BaseDao[T]) NewQueryCond ¶
NewQueryCond 创建查询条件
func (*BaseDao[T]) SelectById ¶
SelectById 根据 ID 查询单条记录
func (*BaseDao[T]) SelectByIds ¶
func (b *BaseDao[T]) SelectByIds(ctx context.Context, ids any, opts ...gplus.OptionFunc) ([]*T, error)
SelectByIds 根据 ID 查询多条记录
func (*BaseDao[T]) SelectCount ¶
func (b *BaseDao[T]) SelectCount(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (int64, error)
SelectCount 根据条件查询记录数量
func (*BaseDao[T]) SelectList ¶
func (b *BaseDao[T]) SelectList(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ([]*T, error)
SelectList 根据条件查询多条记录
func (*BaseDao[T]) SelectOne ¶
func (b *BaseDao[T]) SelectOne(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) (*T, error)
SelectOne 根据条件查询单条记录
func (*BaseDao[T]) SelectPage ¶
func (b *BaseDao[T]) SelectPage( ctx context.Context, page *gplus.Page[T], q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ( *gplus.Page[T], error)
SelectPage 根据条件分页查询记录
func (*BaseDao[T]) Update ¶
func (b *BaseDao[T]) Update(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) error
Update 根据 Map 更新
func (*BaseDao[T]) UpdateById ¶
UpdateById 根据 ID 更新,默认零值不更新
func (*BaseDao[T]) UpdateZeroById ¶
UpdateZeroById 根据 ID 零值更新
type BaseDaoGeneric ¶
func NewBaseDaoGeneric ¶
func NewBaseDaoGeneric[T any, R any]() *BaseDaoGeneric[T, R]
func (*BaseDaoGeneric[T, R]) SelectGeneric ¶
func (b *BaseDaoGeneric[T, R]) SelectGeneric(ctx context.Context, q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ( R, error)
SelectGeneric 根据传入的泛型封装记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
func (*BaseDaoGeneric[T, R]) SelectPageGeneric ¶
func (b *BaseDaoGeneric[T, R]) SelectPageGeneric( ctx context.Context, page *gplus.Page[R], q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ( *gplus.Page[R], error)
SelectPageGeneric 根据传入的泛型封装分页记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
type BaseDaoStreamingGeneric ¶
type BaseDaoStreamingGeneric[T any, R any, V gplus.Comparable] struct { *BaseDao[T] }
func NewBaseDaoStreamingGeneric ¶
func NewBaseDaoStreamingGeneric[T any, R any, V gplus.Comparable]() *BaseDaoStreamingGeneric[T, R, V]
func (*BaseDaoStreamingGeneric[T, R, V]) SelectStreamingPageGeneric ¶
func (b *BaseDaoStreamingGeneric[T, R, V]) SelectStreamingPageGeneric( ctx context.Context, page *gplus.StreamingPage[R, V], q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ( *gplus.StreamingPage[R, V], error)
SelectStreamingPageGeneric 根据传入的泛型封装分页记录 第一个泛型代表数据库表实体 第二个泛型代表返回记录实体
type BaseDaoWithComparable ¶
type BaseDaoWithComparable[T any, V gplus.Comparable] struct { *BaseDao[T] }
func NewBaseDaoWithComparable ¶
func NewBaseDaoWithComparable[T any, V gplus.Comparable]() *BaseDaoWithComparable[T, V]
func (*BaseDaoWithComparable[T, V]) SelectStreamingPage ¶
func (b *BaseDaoWithComparable[T, V]) SelectStreamingPage( ctx context.Context, page *gplus.StreamingPage[T, V], q *gplus.QueryCond[T], opts ...gplus.OptionFunc) ( *gplus.StreamingPage[T, V], error)
SelectStreamingPage 根据条件分页查询记录
type GormLogger ¶
type GormLogger struct {
LogLevel logger.LogLevel // GORM 日志级别
SlowThreshold time.Duration // 慢查询阈值
}
GormLogger 实现 GORM 的 logger.Interface 接口
func (*GormLogger) Error ¶
func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
func (*GormLogger) Info ¶
func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
func (*GormLogger) LogMode ¶
func (l *GormLogger) LogMode(level logger.LogLevel) logger.Interface
LogMode 设置当前的logger level
Click to show internal directories.
Click to hide internal directories.