[feat] 避免数据权限过滤中出现重复的数据

This commit is contained in:
what 2023-12-25 15:22:49 +08:00
parent 104d5e82a9
commit e1fc968fb2

View File

@ -230,7 +230,7 @@ func (this Resource) WithRolesCondition(b *db.Builder, t string, u contracts.Use
items := do.MustInvoke[GetResRoles](this.container)(this.GetUuid(), u.Roles()...)
subTables := lo.Reduce(items, func(carry string, item ResRole, _ int) string {
db := this.GetDBBuilder().Table(string(this.GetTable()), this.GetCode()).Select(db.Raw("`" + this.GetCode() + "`.*"))
db := this.GetDBBuilder().Table(string(this.GetTable()), this.GetCode()).Select(db.Raw("distinct `" + this.GetCode() + "`.*"))
joins := lo.Filter(GetResRelations(item.Uuid), func(item ResRelation, _ int) bool {
return item.Type == "inner" || item.Type == "left" || item.Type == "right"