condition/contracts/contracts.go
2024-05-08 22:58:27 +08:00

46 lines
1.1 KiB
Go

package contracts
import (
"git.fsdpf.net/go/db"
"git.fsdpf.net/go/req"
)
type ConditionType string
type ConditionOperator string
type ConditionTokenType string
type Condition interface {
Type() ConditionType
IsEmpty() bool
IsNotEmpty() bool
IsAlwaysRight() bool
ToSql(ConditionTokenValue) db.Expression
AppendTo(Condition)
SetExpr(ConditionExpr) Condition
SetCondition(Condition) Condition
SetMatchPrefix(string) Condition
GetFields(operator ConditionOperator, types ...ConditionTokenType) map[string]string
GetFieldsValue(m ConditionTokenValue, isWithResource bool) map[string]any
}
type ConditionExpr interface {
GetField() string
GetFieldResource() string
GetOperator() ConditionOperator
SetMatchPrefix(string) ConditionExpr
AppendTo(Condition)
ToSql(m ConditionTokenValue) db.Expression
GetTokenName() string
GetTokenType() ConditionTokenType
GetTokenValue(ConditionTokenValue) any
GetTokenSqlValue(ConditionTokenValue) string
IsIgnoreEmptyParma(ConditionTokenValue) bool
}
type ConditionTokenValue interface {
GetParam(k string) req.GlobalParams
GetGlobalParamsUser() req.User
}