rule

package
v0.0.0-...-e8513ac Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstantKey = "constant"
	DynamicKey  = "dynamic"
)

Variables

View Source
var (
	ConnectorMap = map[string]string{
		"and": "AND",
		"or":  "OR",
	}
	OperatorMap = map[string]string{
		"eq":     "=",
		"ne":     "!=",
		"lt":     "<",
		"le":     "<=",
		"gt":     ">",
		"ge":     ">=",
		"in":     "IN",
		"not-in": "NOT IN",
	}
)

Functions

func BuildSQL

func BuildSQL(ctx context.Context, rules []*DataRule) (ruleSQL string, ruleArgs []interface{}, err error)

Types

type DataRule

type DataRule struct {
	Name        string
	As          string // Databases table name(option)
	ValueFuncs  map[string]ValueFunc
	Expressions []*DataRuleExpression
	Args        map[string]interface{}
}

type DataRuleExpression

type DataRuleExpression struct {
	Connector string
	Field     string
	Operator  string
	ValueType string
	Value     string
}

type ValueFunc

type ValueFunc func(ctx context.Context,
	filed, k string, args map[string]interface{}) (valueArgs []interface{}, err error)

Jump to

Keyboard shortcuts

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