diff --git a/condition.go b/condition.go index bd86021..59cdaf3 100644 --- a/condition.go +++ b/condition.go @@ -189,7 +189,7 @@ func (this Condition) GetFieldsValue(m TokenValue, isWithResource bool) (result * @param contracts.ConditionTokenType types * @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) if this.IsEmpty() { diff --git a/condition_expr.go b/condition_expr.go index 7013dac..17f4827 100644 --- a/condition_expr.go +++ b/condition_expr.go @@ -12,14 +12,14 @@ import ( "github.com/spf13/cast" ) +type TokenType string type ConditionOperator string -type ConditionTokenType string const ( - SQL ConditionTokenType = "sql" - FUNC ConditionTokenType = "func" - PARAM ConditionTokenType = "param" - STRING ConditionTokenType = "string" + SQL TokenType = "sql" + FUNC TokenType = "func" + PARAM TokenType = "param" + STRING TokenType = "string" ) const ( @@ -54,7 +54,7 @@ type ConditionExpr struct { fieldSqlFunc string fieldSqlFuncParam string ignoreEmptyParma bool - tokenType ConditionTokenType + tokenType TokenType token string matchPrefix string // 匹配前缀 } @@ -147,7 +147,7 @@ func (this ConditionExpr) GetTokenName() string { return this.token } -func (this ConditionExpr) GetTokenType() ConditionTokenType { +func (this ConditionExpr) GetTokenType() 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) { option.token = token option.tokenType = tType diff --git a/contracts/contracts.go b/contracts/contracts.go index 00c5115..4ce9de4 100644 --- a/contracts/contracts.go +++ b/contracts/contracts.go @@ -15,7 +15,7 @@ type Condition interface { SetExpr(ConditionExpr) Condition SetCondition(Condition) 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 } @@ -29,7 +29,7 @@ type ConditionExpr interface { AppendTo(Condition) ToSql(m condition.TokenValue) db.Expression GetTokenName() string - GetTokenType() condition.ConditionTokenType + GetTokenType() condition.TokenType GetTokenValue(condition.TokenValue) any GetTokenSqlValue(condition.TokenValue) string IsIgnoreEmptyParma(condition.TokenValue) bool