[feat] 命名规范 GetOrmConditionByRes => GetOrmConditions

This commit is contained in:
what 2024-05-09 14:16:48 +08:00
parent ebd32a8731
commit 591bbabf6c
3 changed files with 6 additions and 6 deletions

View File

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

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 GetOrmConditionByRes func(categoryUuid string, describe string) *condition.Condition
type GetOrmConditions func(categoryUuid string, describe string) *condition.Condition

View File

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