manager

package
v0.0.0-...-1ae172a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFoundReturnNil

func NotFoundReturnNil(o *Options)

Types

type CommonManager

type CommonManager struct {
	Client *redis.Client
	DB     *gorm.DB

	ModelKey string

	context.Context
	// contains filtered or unexported fields
}

func NewCommonManager

func NewCommonManager(redisClient *redis.Client, db *gorm.DB, key string, watch bool) *CommonManager

func (*CommonManager) AddSets

func (cm *CommonManager) AddSets(name string) error

func (*CommonManager) Delete

func (cm *CommonManager) Delete(key string) error

func (*CommonManager) Get

func (cm *CommonManager) Get(key string, keyObj interface{}) error

func (*CommonManager) List

func (cm *CommonManager) List(filters map[string]interface{}) ([]map[string]string, error)

func (*CommonManager) PrimaryKey

func (cm *CommonManager) PrimaryKey(key string) string

func (*CommonManager) Save

func (cm *CommonManager) Save(key string, keyObj interface{}, expire time.Duration, sets bool) error

func (*CommonManager) SetsKey

func (cm *CommonManager) SetsKey() string

func (*CommonManager) Update

func (cm *CommonManager) Update(key string, keyObj interface{}, expire time.Duration, sets bool) error

type OptionFunc

type OptionFunc func(o *Options)

type Options

type Options struct {
	// Get未找到数据时,返回nil
	NotFoundReturnNil bool
}

func GetOptions

func GetOptions(opfs []OptionFunc) *Options

type Pagination

type Pagination struct {
	PageSize int64 `json:"page_size"`
	PageNo   int64 `json:"page_no"`
	Pages    int64 `json:"pages"`
	Records  int64 `json:"records"`
	Offset   int64 `json:"-"`
	Limit    int64 `json:"-"`
}

func NewPagination

func NewPagination(pageSize int64, pageNo int64, records int64) *Pagination

NewPagination 创建分页对象

func NewPaginationFromDb

func NewPaginationFromDb(tx *gorm.DB, modelType schema.Tabler, modelList interface{}, cond PaginationCondition) (*Pagination, error)

NewPaginationFromDb 通过查询数据库创建分页对象

type PaginationCondition

type PaginationCondition struct {
	PageSize int64  `form:"page_size,default=20"` // page_size=0表示不分页
	PageNo   int64  `form:"page_no,default=1"`
	OrderBy  string `form:"order_by"` // order_by=field表示升序,order_by=-field表示降序
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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