[feat] 重命名 ConditionTokenType => TokenType

This commit is contained in:
what 2024-05-09 10:47:51 +08:00
parent dd56166a13
commit 9694d90332
3 changed files with 11 additions and 11 deletions

View File

@ -189,7 +189,7 @@ func (this Condition) GetFieldsValue(m TokenValue, isWithResource bool) (result
* @param contracts.ConditionTokenType types * @param contracts.ConditionTokenType types
* @return map[string][string] // 如: {"TestA.field_a": "param"} * @return map[string][string] // 如: {"TestA.field_a": "param"}
*/ */
func (this Condition) GetFields(operator ConditionOperator, types ...ConditionTokenType) map[string]string { func (this Condition) GetFields(operator ConditionOperator, types ...TokenType) map[string]string {
result := make(map[string]string) result := make(map[string]string)
if this.IsEmpty() { if this.IsEmpty() {

View File

@ -12,14 +12,14 @@ import (
"github.com/spf13/cast" "github.com/spf13/cast"
) )
type TokenType string
type ConditionOperator string type ConditionOperator string
type ConditionTokenType string
const ( const (
SQL ConditionTokenType = "sql" SQL TokenType = "sql"
FUNC ConditionTokenType = "func" FUNC TokenType = "func"
PARAM ConditionTokenType = "param" PARAM TokenType = "param"
STRING ConditionTokenType = "string" STRING TokenType = "string"
) )
const ( const (
@ -54,7 +54,7 @@ type ConditionExpr struct {
fieldSqlFunc string fieldSqlFunc string
fieldSqlFuncParam string fieldSqlFuncParam string
ignoreEmptyParma bool ignoreEmptyParma bool
tokenType ConditionTokenType tokenType TokenType
token string token string
matchPrefix string // 匹配前缀 matchPrefix string // 匹配前缀
} }
@ -147,7 +147,7 @@ func (this ConditionExpr) GetTokenName() string {
return this.token return this.token
} }
func (this ConditionExpr) GetTokenType() ConditionTokenType { func (this ConditionExpr) GetTokenType() TokenType {
return this.tokenType return this.tokenType
} }
@ -247,7 +247,7 @@ func Operator(v ConditionOperator) ExprOption {
} }
} }
func Token(token string, tType ConditionTokenType) ExprOption { func Token(token string, tType TokenType) ExprOption {
return func(option *ConditionExpr) { return func(option *ConditionExpr) {
option.token = token option.token = token
option.tokenType = tType option.tokenType = tType

View File

@ -15,7 +15,7 @@ type Condition interface {
SetExpr(ConditionExpr) Condition SetExpr(ConditionExpr) Condition
SetCondition(Condition) Condition SetCondition(Condition) Condition
SetMatchPrefix(string) Condition SetMatchPrefix(string) Condition
GetFields(operator condition.ConditionOperator, types ...condition.ConditionTokenType) map[string]string GetFields(operator condition.ConditionOperator, types ...condition.TokenType) map[string]string
GetFieldsValue(m condition.TokenValue, isWithResource bool) map[string]any GetFieldsValue(m condition.TokenValue, isWithResource bool) map[string]any
} }
@ -29,7 +29,7 @@ type ConditionExpr interface {
AppendTo(Condition) AppendTo(Condition)
ToSql(m condition.TokenValue) db.Expression ToSql(m condition.TokenValue) db.Expression
GetTokenName() string GetTokenName() string
GetTokenType() condition.ConditionTokenType GetTokenType() condition.TokenType
GetTokenValue(condition.TokenValue) any GetTokenValue(condition.TokenValue) any
GetTokenSqlValue(condition.TokenValue) string GetTokenSqlValue(condition.TokenValue) string
IsIgnoreEmptyParma(condition.TokenValue) bool IsIgnoreEmptyParma(condition.TokenValue) bool