From cd91c6309625e2e2f93009de5cf37c4c91c324e5 Mon Sep 17 00:00:00 2001 From: what Date: Tue, 13 Jun 2023 18:01:36 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=B0=86=20ModelParam=20=E7=8B=AC?= =?UTF-8?q?=E7=AB=8B=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orm.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/orm.go b/orm.go index 82c074e..0b4d085 100644 --- a/orm.go +++ b/orm.go @@ -116,11 +116,9 @@ type Join interface { } type Model interface { Relation + ModelParam GetCode() string GetPrimaryKey() string - GetParam(k string) GlobalParams - GetParamWithPrefix(k string, prefix string) GlobalParams - GetGlobalParamsUser() User GetQueryFieldsStruct(extends ...reflect.StructField) any GetQueryFieldsSliceStruct(fields ...reflect.StructField) any GetAttribute() map[string]any @@ -148,6 +146,11 @@ type Model interface { // Exists() (bool, error) } +type ModelParam interface { + GetParam(k string) GlobalParams + GetGlobalParamsUser() User +} + type Condition interface { Type() ConditionType IsEmpty() bool @@ -170,12 +173,12 @@ type ConditionExpr interface { SetMatchPrefix(string) ConditionExpr AppendTo(Condition) - ToSql(m Model) db.Expression + ToSql(m ModelParam) db.Expression GetTokenName() string GetTokenType() ConditionTokenType - GetTokenValue(Model) any - GetTokenSqlValue(Model) string - IsIgnoreEmptyParma(Model) bool + GetTokenValue(ModelParam) any + GetTokenSqlValue(ModelParam) string + IsIgnoreEmptyParma(ModelParam) bool } type QueryField interface {