criteria

package
v0.0.0-...-8cdccc7 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClauseConstants = ClauseConstantsEnum{
	Regexp:    "regexp",
	Contains:  "like",
	Equals:    "=",
	NotEquals: "<>",
	Lt:        "<",
	Lte:       "<=",
	Gt:        ">",
	Gte:       ">=",
	In:        "in",
}

Functions

func BuildSpecification

func BuildSpecification(db *gorm.DB, name string, criteria interface{}) (tx *gorm.DB)

*

  • @Description: 创建条件从句
  • @param db
  • @param name
  • @param criteria
  • @return tx

func CreateCommonOperationDb

func CreateCommonOperationDb(db *gorm.DB, operation *CommonDbOperation) *gorm.DB

*

  • @Description: 封装其他操作
  • @param db
  • @param operation
  • @return *gorm.DB

func GinQuery2Criteria

func GinQuery2Criteria(queryParams map[string][]string, criteria interface{}) error

*

  • @Description: gin queryParams 转换为 criteria
  • @param m
  • @param sType

func Map2Struct

func Map2Struct(dst, src interface{}) (err error)

*

  • @Description: map转struct简易封装(适用于value为string类型)
  • @param dst 自定义criteria
  • @param src map
  • @return err

Types

type BoolFilter

type BoolFilter struct {
	Equals *bool
}

type ClauseConstantsEnum

type ClauseConstantsEnum struct {
	Regexp    string
	Contains  string
	Equals    string
	NotEquals string
	Lt        string
	Lte       string
	Gt        string
	Gte       string
	In        string
}

*

  • @Description: 创建整数从句
  • @param tx db操作
  • @param name 查询参数名
  • @param criteria 查询条件

type CommonDbOperation

type CommonDbOperation struct {
	Selects  []string               //查询字段
	Preloads map[string]interface{} //预加载字段
	Orders   []string               //排序
	Groups   []string               //分组
	Havings  map[string]interface{} //分组筛选
	Limit    *int                   //限制大小
}

type FloatFilter

type FloatFilter struct {
	Equals    *float64
	NotEquals *float64
	Lte       *float64
	Lt        *float64
	Gt        *float64
	Gte       *float64
	In        *string
}

type IntFilter

type IntFilter struct {
	Equals    *int64
	NotEquals *int64
	Lte       *int64
	Lt        *int64
	Gt        *int64
	Gte       *int64
	In        *string
}

type StringFilter

type StringFilter struct {
	Regexp    *string
	Contains  *string
	Equals    *string
	NotEquals *string
	In        *string
}

type TimeFilter

type TimeFilter struct {
	Lte *string
	Lt  *string
	Gt  *string
	Gte *string
}

Jump to

Keyboard shortcuts

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