优化多租户的方案

This commit is contained in:
Yavolte 2025-07-23 17:11:52 +08:00
parent 9bbda7bfe3
commit 016ae8a014
5 changed files with 9 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"git.nobla.cn/golang/aeus-admin/internal/logic"
"git.nobla.cn/golang/aeus-admin/utils"
"git.nobla.cn/golang/aeus/pkg/cache"
"git.nobla.cn/golang/rest"
"git.nobla.cn/golang/rest/types"
@ -20,7 +21,7 @@ type Formatter struct {
}
func (f *Formatter) FormatUser(ctx context.Context, value, model any, scm *types.Schema) any {
if values, err := f.user.GetLabels(ctx); err == nil {
if values, err := f.user.GetLabels(ctx, utils.GetDomainFromContext(ctx)); err == nil {
for _, row := range values {
if row.Value == value {
return fmt.Sprintf("%s(%s)", row.Label, row.Value)
@ -31,7 +32,7 @@ func (f *Formatter) FormatUser(ctx context.Context, value, model any, scm *types
}
func (f *Formatter) FormatDepartment(ctx context.Context, value, model any, scm *types.Schema) any {
if values, err := f.department.GetLabels(ctx); err == nil {
if values, err := f.department.GetLabels(ctx, utils.GetDomainFromContext(ctx)); err == nil {
for _, row := range values {
if row.Value == value {
return row.Label
@ -42,7 +43,7 @@ func (f *Formatter) FormatDepartment(ctx context.Context, value, model any, scm
}
func (f *Formatter) FormatRole(ctx context.Context, value, model any, scm *types.Schema) any {
if values, err := f.role.GetLabels(ctx); err == nil {
if values, err := f.role.GetLabels(ctx, utils.GetDomainFromContext(ctx)); err == nil {
for _, row := range values {
if row.Value == value {
return row.Label
@ -53,7 +54,7 @@ func (f *Formatter) FormatRole(ctx context.Context, value, model any, scm *types
}
func (f *Formatter) FormatMenu(ctx context.Context, value, model any, scm *types.Schema) any {
if values, err := f.menu.GetLabels(ctx); err == nil {
if values, err := f.menu.GetLabels(ctx, utils.GetDomainFromContext(ctx)); err == nil {
for _, row := range values {
if row.Value == value {
return row.Label

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto
// date: 2025-07-23 17:06:59
// date: 2025-07-23 17:11:27
package pb

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: organize.proto
// date: 2025-07-23 17:06:59
// date: 2025-07-23 17:11:27
package pb

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-07-23 17:06:59
// date: 2025-07-23 17:11:27
package pb

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-aeus. DO NOT EDIT.
// source: system.proto
// date: 2025-07-23 17:06:59
// date: 2025-07-23 17:11:27
package pb