db

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Accurate       = "accurate" // 精确匹配
	Fuzzy          = "fuzzy"    // 模糊匹配
	Not            = "not"      // 不匹配
	Bwt            = "between"  // 位于两者之间(含)
	In             = "in"       // 在某个范围内
	NotIn          = "notin"    // 不在某个范围内
	Larger         = "larger"   // 大于
	LargerOrEqual  = "le"       // 大于或等于
	Smaller        = "smaller"  // 小于
	SmallerOrEqual = "se"       // 小于或等于
)

Variables

This section is empty.

Functions

func BuildCondition

func BuildCondition(scons []SqlCondition, fcons []FieldCondition) (string, []interface{}, error)

BuildCondition 根据condition生成where条件

func GetString

func GetString(key string) (string, error)

redis GetString 方法 去掉数据为空判断

func HGet

func HGet(key string, field string) (string, error)

redis HGet 方法 集成redis HGet 方法

func HGetAll

func HGetAll(key string) (map[string]string, error)

redis HGETALL 方法 集成redis HGETALL 方法

func HSet

func HSet(key string, field string, value string) error

redis HSet 方法 集成redis hset方法

func SetNx

func SetNx(key string, value string) (bool, error)

redis setnx方法 实现数据加锁

func TTL

func TTL(key string) (int, error)

redis TTL 获取剩余过期时间

Types

type FieldCondition

type FieldCondition struct {
	TableName string `json:"table_name"`
	Field     string `json:"field"`
	Value     string `json:"value"`
	MatchType string `json:"match_type"`
}

FieldCondition 字段条件

type PageCondition

type PageCondition struct {
	Conditions []FieldCondition `json:"conditions"`
	PageNo     int              `json:"page_no"`
	PageSize   int              `json:"page_size"`
}

PageCondition 基于Field查询专用的结构体

type SearchModelResult

type SearchModelResult struct {
	TotalCount int64       `json:"total_count"`
	Items      interface{} `json:"items"`
}

SearchModelResult 查询返回结果类

func PagerModel

func PagerModel(tableName string, scons []SqlCondition, fcons []FieldCondition,
	pageSize int64, pageIndex int64, orderBy string, traceID string) (SearchModelResult, error)

PagerModel 表分页查询的方法

type SearchResult

type SearchResult struct {
	TotalCount int64                    `json:"total_count"`
	Items      []map[string]interface{} `json:"items"`
}

SearchResult 查询返回结果类

func Pager

func Pager(tableName string, scons []SqlCondition, fcons []FieldCondition,
	pageSize int64, pageIndex int64, orderBy string, traceID string) (SearchResult, error)

Pager 表分页查询的方法

type SqlCondition

type SqlCondition struct {
	Sql    string   `json:"sql"`
	Values []string `json:"values"` // SQL条件对应的value集合
}

SqlCondition Sql条件

Jump to

Keyboard shortcuts

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