From 591bbabf6cb9fba5bc14f183d3cb698fc1a03660 Mon Sep 17 00:00:00 2001 From: what Date: Thu, 9 May 2024 14:16:48 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= =?UTF-8?q?=20GetOrmConditionByRes=20=3D>=20GetOrmConditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/resource.go | 6 +++--- orm.go | 2 +- support/list.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base/resource.go b/base/resource.go index 684b826..7cf9944 100644 --- a/base/resource.go +++ b/base/resource.go @@ -224,7 +224,7 @@ func (this Resource) WithRolesCondition(b *db.Builder, t string, u req.User) err GetResRelationResource := do.MustInvoke[GetResRelationResource](this.container) GetResRelations := do.MustInvoke[GetResRelations](this.container) GetResource := do.MustInvoke[contracts.GetResource](this.container) - GetOrmConditionByRes := do.MustInvoke[contracts.GetOrmConditionByRes](this.container) + GetOrmConditions := do.MustInvoke[contracts.GetOrmConditions](this.container) items := do.MustInvoke[GetResRoles](this.container)(this.GetUuid(), u.Roles()...) @@ -247,12 +247,12 @@ func (this Resource) WithRolesCondition(b *db.Builder, t string, u req.User) err join := NewOrmJoin(contracts.RelationType(joins[i].Type), oResource, joins[i].Code, joins[i].RelationResource, joins[i].RelationField, joins[i].RelationForeignKey) // 关联扩展条件 - join.SetCondition(GetOrmConditionByRes(joins[i].Uuid, "关联扩展条件")) + join.SetCondition(GetOrmConditions(joins[i].Uuid, "关联扩展条件")) join.Inject(db, NewOrmModel(rResource, rResource.GetCode(), rResource.GetName())) } - conditions := GetOrmConditionByRes(item.Uuid, "关联扩展条件") + conditions := GetOrmConditions(item.Uuid, "关联扩展条件") if len(joins) == 0 && conditions.IsEmpty() { // 无权限, 直接跳过这个 unoin 语句 diff --git a/orm.go b/orm.go index 92662cc..8ede30a 100644 --- a/orm.go +++ b/orm.go @@ -139,4 +139,4 @@ type NewOrmModel func(res req.Resource, code, name string) Model type NewOrm func(res req.Resource, tx *db.Transaction) Orm -type GetOrmConditionByRes func(categoryUuid string, describe string) *condition.Condition +type GetOrmConditions func(categoryUuid string, describe string) *condition.Condition diff --git a/support/list.go b/support/list.go index 56736e9..03e145f 100644 --- a/support/list.go +++ b/support/list.go @@ -43,7 +43,7 @@ type OperationAccess struct { } func (o Operation) ToDBColumn(model contracts.Model, container *do.Injector) (column db.Expression, field reflect.StructField) { - GetOrmConditionByRes := do.MustInvoke[contracts.GetOrmConditionByRes](container) + GetOrmConditions := do.MustInvoke[contracts.GetOrmConditions](container) uuid := strings.ReplaceAll(o.Uuid, "-", "_") @@ -52,7 +52,7 @@ func (o Operation) ToDBColumn(model contracts.Model, container *do.Injector) (co cond := lo.Ternary(o.AccessCondition != nil, o.AccessCondition, condition.New(condition.Describe("operation access condition "+uuid))) - if c := GetOrmConditionByRes(o.Uuid, "operation access condition "+uuid); c.IsNotEmpty() { + if c := GetOrmConditions(o.Uuid, "operation access condition "+uuid); c.IsNotEmpty() { cond.SetCondition(c) }