base

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildArray added in v0.0.3

func BuildArray[T any](data []T) []interface{}

构建interface数组

func Page added in v0.0.3

func Page[R any, T any](ctx context.Context, db *gorm.DB, t *T, query SearchCriteria) (data []*R, total int64, err error)

封装分页列表查询操作

Types

type Entity

type Entity struct {
	ID        uuid.UUID      `gorm:"type:uuid;default:gen_random_uuid();comment:主键"`
	CreatedAt time.Time      `gorm:"comment:创建时间"`
	UpdatedAt time.Time      `gorm:"comment:更新时间"`
	DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间"`
}

type FuzzyField added in v0.0.3

type FuzzyField struct {
	Name  string      `json:"name"`  //查询字段名称
	Value interface{} `json:"value"` //查询字段值
}

type GTEField added in v0.0.3

type GTEField struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type GTField added in v0.0.3

type GTField struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type JSONField added in v0.0.3

type JSONField struct {
	TermFields  []JSONTermField
	FuzzyFields []JSONFuzzyField
	LTEFields   []JSONLTEField
	LTFields    []JSONLTField
	GTEFields   []JSONGTEField
	GTFields    []JSONGTField
	ArrayFields []TermField
}

type JSONFuzzyField added in v0.0.3

type JSONFuzzyField struct {
	Field string      `json:"field"` //json字段名
	Name  string      `json:"name"`  //查询字段名称
	Value interface{} `json:"value"` //查询字段值
}

type JSONGTEField added in v0.0.3

type JSONGTEField struct {
	Field string  `json:"field"` //json字段名
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type JSONGTField added in v0.0.3

type JSONGTField struct {
	Field string  `json:"field"` //json字段名
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type JSONLTEField added in v0.0.3

type JSONLTEField struct {
	Field string  `json:"field"` //json字段名
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type JSONLTField added in v0.0.3

type JSONLTField struct {
	Field string  `json:"field"` //json字段名
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type JSONTermField added in v0.0.3

type JSONTermField struct {
	Field string        `json:"field"` //json字段名
	Name  string        `json:"name"`  //查询字段名称
	Value []interface{} `json:"value"` //查询字段值
}

type LTEField added in v0.0.3

type LTEField struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type LTField added in v0.0.3

type LTField struct {
	Name  string  `json:"name"`
	Value float64 `json:"value"`
}

type OrFuzzyField added in v0.0.3

type OrFuzzyField struct {
	Names []string    `json:"names"` //查询字段名称
	Value interface{} `json:"value"` //查询字段值
}

type PageQuery added in v0.0.3

type PageQuery struct {
	Page  int `form:"page"`  //页数
	Limit int `form:"limit"` //每页个数
}

func (*PageQuery) InjectDefault added in v0.0.3

func (pq *PageQuery) InjectDefault()

func (*PageQuery) Offset added in v0.0.3

func (pq *PageQuery) Offset() int

type RawSearchCriteria added in v0.0.3

type RawSearchCriteria struct {
	SelectSql string
	CountSql  string
	Where     []string
	OrderSql  string
	Values    []interface{}
	PageQuery
}

RawSearchCriteria 原生查询

type SearchCriteria added in v0.0.3

type SearchCriteria struct {
	PageQuery
	Columns string
	Table   string
	SearchField
	Joins       []string
	Order       string
	Group       string
	OrFuzzys    []OrFuzzyField
	NoPageQuery bool
}

SearchCriteria 搜索条件

func NewJoinSearchCriteria added in v0.0.3

func NewJoinSearchCriteria(columns, table string, joins []string) *SearchCriteria

func NewJoinSearchCriteriaOfPageQuery added in v0.0.3

func NewJoinSearchCriteriaOfPageQuery(query PageQuery, columns, table string, joins []string) *SearchCriteria

func NewSearchCriteriaOfPageQuery added in v0.0.3

func NewSearchCriteriaOfPageQuery(query PageQuery) *SearchCriteria

func (*SearchCriteria) BuildDB added in v0.0.3

func (sc *SearchCriteria) BuildDB(db *gorm.DB) *gorm.DB

func (*SearchCriteria) WithKeyword added in v0.0.3

func (sc *SearchCriteria) WithKeyword(names []string, keyword string) *SearchCriteria

关键词查询

type SearchField added in v0.0.3

type SearchField struct {
	TermFields  []TermField
	FuzzyFields []FuzzyField
	LTEFields   []LTEField
	LTFields    []LTField
	GTEFields   []GTEField
	GTFields    []GTField
	JSONField   JSONField
}

type TermField added in v0.0.3

type TermField struct {
	Name  string        `json:"name"`  //查询字段名称
	Value []interface{} `json:"value"` //查询字段值
}

Jump to

Keyboard shortcuts

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