diff --git a/base/res_condition.go b/base/res_condition.go index 191714f..4b351d6 100644 --- a/base/res_condition.go +++ b/base/res_condition.go @@ -1,7 +1,5 @@ package base -import "git.fsdpf.net/go/contracts" - type ResCondition struct { Id int `db:"id"` Pid int `db:"pid"` @@ -38,5 +36,3 @@ type ResWhereExpr struct { } type GetResConditions func(categoryUuid string) []ResCondition - -type GetOrmConditionByRes func(categoryUuid string, describe string) contracts.Condition diff --git a/base/resource.go b/base/resource.go index ee4e8ea..f942cad 100644 --- a/base/resource.go +++ b/base/resource.go @@ -11,7 +11,6 @@ import ( "github.com/samber/lo" "git.fsdpf.net/go/contracts" - "git.fsdpf.net/go/contracts/helper" "git.fsdpf.net/go/contracts/support" "git.fsdpf.net/go/db" ) @@ -218,14 +217,14 @@ func (this Resource) WithRolesCondition(b *db.Builder, t string, u contracts.Use isFullRight := false isFullNot := false - NewOrm := do.MustInvoke[helper.NewOrm](this.container) - NewOrmModel := do.MustInvoke[helper.NewOrmModel](this.container) - NewOrmJoin := do.MustInvoke[helper.NewOrmJoin](this.container) + NewOrm := do.MustInvoke[contracts.NewOrm](this.container) + NewOrmModel := do.MustInvoke[contracts.NewOrmModel](this.container) + NewOrmJoin := do.MustInvoke[contracts.NewOrmJoin](this.container) GetResRelationResource := do.MustInvoke[GetResRelationResource](this.container) GetResRelations := do.MustInvoke[GetResRelations](this.container) GetResource := do.MustInvoke[contracts.GetResource](this.container) - GetOrmConditionByRes := do.MustInvoke[GetOrmConditionByRes](this.container) + GetOrmConditionByRes := do.MustInvoke[contracts.GetOrmConditionByRes](this.container) items := do.MustInvoke[GetResRoles](this.container)(this.GetUuid(), u.Roles()...) diff --git a/helper/orm.go b/helper/orm.go deleted file mode 100644 index 17a0524..0000000 --- a/helper/orm.go +++ /dev/null @@ -1,32 +0,0 @@ -package helper - -import ( - "git.fsdpf.net/go/contracts" - "git.fsdpf.net/go/db" -) - -// @title 创建关联模型 -// @param t 关联类型 -// @param m 关联模型 -// @param rResource 链接父模型 -// @param rField 连接父模型字段, 如 xx_id -// @param rForeignKey 关联外键, 如 id -type NewOrmRelation func(t contracts.RelationType, m contracts.Model, rResource, rField, rForeignKey string) contracts.Model - -type NewOrmJoin func(t contracts.RelationType, res contracts.Resource, alias, rResource, rField, rForeignKey string) contracts.Join - -type NewOrmCondition func(typ contracts.ConditionType, describe string) contracts.Condition - -type NewOrmConditionExpr func(rResource, rField, token string, operator contracts.ConditionOperator, tType contracts.ConditionTokenType, ignoreEmptyParma bool) contracts.ConditionExpr - -type NewOrmConditionFuncExpr func(rResource, rField, token string, operator contracts.ConditionOperator, tType contracts.ConditionTokenType, ignoreEmptyParma bool, fn, fnParam string) contracts.ConditionExpr - -type NewOrmQueryWithRecursive func(pField, cField string, root any, isWithoutCondition bool, depth int) contracts.QueryWithRecursive - -type NewOrmOrderBy func(sql string, direction contracts.OrderByDirection) contracts.OrderBy - -type NewOrmGroupBy func(sql string) contracts.GroupBy - -type NewOrmModel func(res contracts.Resource, code, name string) contracts.Model - -type NewOrm func(res contracts.Resource, tx *db.Transaction) contracts.Orm diff --git a/orm.go b/orm.go index f10a682..6ccc217 100644 --- a/orm.go +++ b/orm.go @@ -184,3 +184,31 @@ type QueryWithRecursive interface { ToQueryBuilder(*db.Builder, Model) (*db.Builder, any) ToTreeData(any) any } + +// @title 创建关联模型 +// @param t 关联类型 +// @param m 关联模型 +// @param rResource 链接父模型 +// @param rField 连接父模型字段, 如 xx_id +// @param rForeignKey 关联外键, 如 id +type NewOrmRelation func(t RelationType, m Model, rResource, rField, rForeignKey string) Model + +type NewOrmJoin func(t RelationType, res Resource, alias, rResource, rField, rForeignKey string) Join + +type NewOrmCondition func(typ ConditionType, describe string) Condition + +type NewOrmConditionExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool) ConditionExpr + +type NewOrmConditionFuncExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool, fn, fnParam string) ConditionExpr + +type NewOrmQueryWithRecursive func(pField, cField string, root any, isWithoutCondition bool, depth int) QueryWithRecursive + +type NewOrmOrderBy func(sql string, direction OrderByDirection) OrderBy + +type NewOrmGroupBy func(sql string) GroupBy + +type NewOrmModel func(res Resource, code, name string) Model + +type NewOrm func(res Resource, tx *db.Transaction) Orm + +type GetOrmConditionByRes func(categoryUuid string, describe string) Condition