Documentation
¶
Index ¶
- func InitializeMysql(config dirver.LinkParams) *gorm.DB
- func InitializeRedisPool(config RedisConfig) *redis.Client
- type CommonModel
- type Database
- func (d *Database) Begin() *gorm.DB
- func (d *Database) Create(model any) error
- func (d *Database) Delete(model any) error
- func (d *Database) DeleteByWhere(where any) error
- func (d *Database) ExecuteSql(sql string, logMod ...bool) error
- func (d *Database) Exist(where Where) (bool, error)
- func (d *Database) Find(id any) error
- func (d *Database) First(where Where, not ...Where) error
- func (d *Database) Get(where ...any) error
- func (d *Database) GetByPage(pagination PaginationQuery, where any) PageData
- func (d *Database) GetDb() *gorm.DB
- func (d *Database) Save(model any) error
- func (d *Database) SetMode() error
- func (d *Database) SetModel(executeModel any) *Database
- func (d *Database) SetResult(resultModel any) *Database
- type ModelAction
- type PageData
- type PageInfo
- type PaginationQuery
- type PipAction
- type RedisClient
- func (r *RedisClient) BLPop(key string, timeout time.Duration) ([]string, error)
- func (r *RedisClient) Delete(key ...string) error
- func (r *RedisClient) Get(key string) (bool, string, error)
- func (r *RedisClient) HGet(key, field string) (string, error)
- func (r *RedisClient) HGetAll(key string) (map[string]string, error)
- func (r *RedisClient) HSet(key string, values map[string]string) (int64, error)
- func (r *RedisClient) HSetNX(key, field string, value any) (bool, error)
- func (r *RedisClient) Keys(pattern string) ([]string, error)
- func (r *RedisClient) LPop(key string) (string, error)
- func (r *RedisClient) LPush(key string, value any) (int64, error)
- func (r *RedisClient) Publish(channel string, message any) (int64, error)
- func (r *RedisClient) SelectDbAction(index int, action PipAction) (map[int]any, error)
- func (r *RedisClient) Set(key string, value any, expiration time.Duration) error
- func (r *RedisClient) SetNX(key string, value any, expiration time.Duration) (bool, error)
- func (r *RedisClient) Subscribe(channel string) <-chan *redis.Message
- type RedisConfig
- type SubscribeData
- type Where
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeMysql ¶
func InitializeMysql(config dirver.LinkParams) *gorm.DB
InitializeMysql 初始化数据库连接
func InitializeRedisPool ¶
func InitializeRedisPool(config RedisConfig) *redis.Client
InitializeRedisPool 初始化redis连接池
Types ¶
type CommonModel ¶
type CommonModel struct {
Id int `gorm:"column:id" json:"id"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
}
CommonModel 数据库类型基类
type Database ¶
type Database struct {
Result any
// contains filtered or unexported fields
}
Database 基础模型
var DBHandler *Database
DBHandler 数据库操作句柄
func (*Database) DeleteByWhere ¶
DeleteByWhere 删除数据
func (*Database) ExecuteSql ¶
ExecuteSql 执行sql
func (*Database) GetByPage ¶
func (d *Database) GetByPage(pagination PaginationQuery, where any) PageData
GetByPage 分页查询数据
type ModelAction ¶
type PaginationQuery ¶
type PaginationQuery struct {
PageSize int
PageNum int
// OrderBy 小写的字段名称
OrderBy string
// Order 默认是'desc', 可选的: 'desc', 'asc'
Order string
}
PaginationQuery 分页查询
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
var RedisHandler *RedisClient
RedisHandler Redis操作句柄
func (*RedisClient) Delete ¶
func (r *RedisClient) Delete(key ...string) error
func (*RedisClient) HSetNX ¶
func (r *RedisClient) HSetNX(key, field string, value any) (bool, error)
func (*RedisClient) Publish ¶
func (r *RedisClient) Publish(channel string, message any) (int64, error)
Publish 发布
func (*RedisClient) SelectDbAction ¶
type RedisConfig ¶
type RedisConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Db int `yaml:"db"`
Password string `yaml:"password"`
MaxRetries int `yaml:"maxRetries"`
}
RedisConfig 配置
type SubscribeData ¶
Click to show internal directories.
Click to hide internal directories.