[feat] 命名规范 GetOrmConditionByRes => GetOrmConditions

This commit is contained in:
what 2024-05-09 14:24:41 +08:00
parent 591bbabf6c
commit 6d3b2267b9
3 changed files with 5 additions and 4 deletions

View File

@ -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 语句

2
orm.go
View File

@ -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

View File

@ -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)
}