From f79e122b40f819e31807b291e004d24e9bd9b54c Mon Sep 17 00:00:00 2001 From: what Date: Thu, 9 May 2024 10:44:33 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E9=87=8D=E5=91=BD=E5=90=8D=20Conditio?= =?UTF-8?q?nTokenValue=20=3D>=20TokenValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- condition.go | 4 ++-- condition_expr.go | 10 +++++----- engine/engine_case.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/condition.go b/condition.go index 051dcd1..bd86021 100644 --- a/condition.go +++ b/condition.go @@ -93,7 +93,7 @@ func (this Condition) IsAlwaysRight() bool { } // 生成 SQL 语句 -func (this Condition) ToSql(m ConditionTokenValue) db.Expression { +func (this Condition) ToSql(m TokenValue) db.Expression { conditions := []string{} // 表达式 for _, item := range this.exprs { @@ -157,7 +157,7 @@ func (this *Condition) SetMatchPrefix(prefix string) *Condition { return this } -func (this Condition) GetFieldsValue(m ConditionTokenValue, isWithResource bool) (result map[string]any) { +func (this Condition) GetFieldsValue(m TokenValue, isWithResource bool) (result map[string]any) { if this.IsEmpty() { return } diff --git a/condition_expr.go b/condition_expr.go index 8c27154..7013dac 100644 --- a/condition_expr.go +++ b/condition_expr.go @@ -41,7 +41,7 @@ const ( type ExprOption func(option *ConditionExpr) -type ConditionTokenValue interface { +type TokenValue interface { GetParam(k string) req.GlobalParams GetGlobalParamsUser() req.User } @@ -80,7 +80,7 @@ func (this *ConditionExpr) AppendTo(c *Condition) { this.parent = c } -func (this ConditionExpr) ToSql(m ConditionTokenValue) db.Expression { +func (this ConditionExpr) ToSql(m TokenValue) db.Expression { first := "`" + this.fieldResource + "`.`" + this.field + "`" if strings.Contains(this.field, "->") { @@ -151,7 +151,7 @@ func (this ConditionExpr) GetTokenType() ConditionTokenType { return this.tokenType } -func (this *ConditionExpr) GetTokenSqlValue(m ConditionTokenValue) string { +func (this *ConditionExpr) GetTokenSqlValue(m TokenValue) string { if this.GetTokenType() == SQL { return this.token } @@ -188,7 +188,7 @@ func (this *ConditionExpr) GetTokenSqlValue(m ConditionTokenValue) string { } } -func (this ConditionExpr) GetTokenValue(m ConditionTokenValue) any { +func (this ConditionExpr) GetTokenValue(m TokenValue) any { switch this.GetTokenType() { case PARAM: if this.matchPrefix != "" { @@ -216,7 +216,7 @@ func (this ConditionExpr) GetTokenValue(m ConditionTokenValue) any { return nil } -func (this ConditionExpr) IsIgnoreEmptyParma(m ConditionTokenValue) bool { +func (this ConditionExpr) IsIgnoreEmptyParma(m TokenValue) bool { if !this.ignoreEmptyParma { return false } diff --git a/engine/engine_case.go b/engine/engine_case.go index dafb49a..5bb29e4 100644 --- a/engine/engine_case.go +++ b/engine/engine_case.go @@ -11,7 +11,7 @@ type EngineCase[T any] struct { cb func(data T, g req.GlobalParams) error } -func (this EngineCase[T]) ToSql(param condition.ConditionTokenValue) db.Expression { +func (this EngineCase[T]) ToSql(param condition.TokenValue) db.Expression { if this.predicate == nil || this.predicate.IsEmpty() { return db.Raw("NULL") }