From 6d3b2267b9ca77448e5f64834ea1eadeff3f690d Mon Sep 17 00:00:00 2001 From: what Date: Thu, 9 May 2024 14:24:41 +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 | 5 +++-- orm.go | 2 +- support/list.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/resource.go b/base/resource.go index 7cf9944..40593c0 100644 --- a/base/resource.go +++ b/base/resource.go @@ -10,6 +10,7 @@ import ( "github.com/samber/do" "github.com/samber/lo" + "git.fsdpf.net/go/condition" "git.fsdpf.net/go/contracts" "git.fsdpf.net/go/db" "git.fsdpf.net/go/req" @@ -247,12 +248,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(GetOrmConditions(joins[i].Uuid, "关联扩展条件")) + join.SetCondition(GetOrmConditions(joins[i].Uuid, condition.Describe("关联扩展条件"))) join.Inject(db, NewOrmModel(rResource, rResource.GetCode(), rResource.GetName())) } - conditions := GetOrmConditions(item.Uuid, "关联扩展条件") + conditions := GetOrmConditions(item.Uuid, condition.Describe("关联扩展条件")) if len(joins) == 0 && conditions.IsEmpty() { // 无权限, 直接跳过这个 unoin 语句 diff --git a/orm.go b/orm.go index 8ede30a..d43cd9c 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 GetOrmConditions func(categoryUuid string, describe string) *condition.Condition +type GetOrmConditions func(categoryUuid string, opts ...condition.Option) *condition.Condition diff --git a/support/list.go b/support/list.go index 03e145f..28ad605 100644 --- a/support/list.go +++ b/support/list.go @@ -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 := GetOrmConditions(o.Uuid, "operation access condition "+uuid); c.IsNotEmpty() { + if c := GetOrmConditions(o.Uuid, condition.Describe("operation access condition "+uuid)); c.IsNotEmpty() { cond.SetCondition(c) }