Documentation ¶
Index ¶
- func GetPageList[T any](page *PageRequest, model *gorm.DB, list *response.PageList[T]) (err error)
- func Paginate(p *PageRequest) func(db *gorm.DB) *gorm.DB
- type PageRequest
- type Util
- func (u *Util[T]) CreateMany(model *[]T) error
- func (u *Util[T]) CreateOne(model *T) error
- func (u *Util[T]) DeleteMany(model *[]T) error
- func (u *Util[T]) DeleteOne(model *T) error
- func (u *Util[T]) GetAll() ([]T, error)
- func (u *Util[T]) GetDB() *gorm.DB
- func (u *Util[T]) GetList(request *PageRequest) (*response.PageList[T], error)
- func (u *Util[T]) GetListWithData(request *PageRequest, data interface{}) (*response.PageList[T], error)
- func (u *Util[T]) GetOne(model *T) error
- func (u *Util[T]) SetDB(fn func(db *gorm.DB) *gorm.DB)
- func (u *Util[T]) UpdateMany(model *[]T) error
- func (u *Util[T]) UpdateOne(model *T) error
- func (u *Util[T]) UpdateOneColumn(model *T, column ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPageList ¶
GetPageList 分页公共方法
Types ¶
type PageRequest ¶
type PageRequest struct { Page int // 页码 PageSize int // 每页数量 Total int64 // total 总数 Where map[string]interface{} // 条件and 自行拼接 OrWhere map[string]interface{} // 条件or 自行拼接 // contains filtered or unexported fields }
PageRequest 分页请求的参数
func (*PageRequest) DescSort ¶
func (p *PageRequest) DescSort(field string)
DescSort 倒序排序 多个排序字段使用空格隔开
type Util ¶ added in v0.1.5
type Util[T interface{}] struct { DB *gorm.DB Model *T PageRequestParams *PageRequest }
func (*Util[T]) CreateMany ¶ added in v0.1.5
CreateMany 创建多条记录
func (*Util[T]) DeleteMany ¶ added in v0.1.5
DeleteMany 删除多条记录
func (*Util[T]) GetList ¶ added in v0.1.5
func (u *Util[T]) GetList(request *PageRequest) (*response.PageList[T], error)
GetList 获取多条记录
func (*Util[T]) GetListWithData ¶ added in v0.1.8
func (u *Util[T]) GetListWithData(request *PageRequest, data interface{}) (*response.PageList[T], error)
GetListWithData 获取多条记录 使用传入的data进行返回赋值 , 第二个参数需要传入指针
func (*Util[T]) UpdateMany ¶ added in v0.1.5
UpdateMany 更新多条记录
func (*Util[T]) UpdateOneColumn ¶ added in v0.1.7
UpdateOneColumn 根据字段名更新单列
Click to show internal directories.
Click to hide internal directories.