From 9d6f761f1b26a917eff9296a8332a5c304096bf5 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Sun, 8 Dec 2024 21:10:28 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/source/system/authorities_menus.go | 3 +-- server/source/system/dictionary_detail.go | 4 +--- server/source/system/user.go | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/server/source/system/authorities_menus.go b/server/source/system/authorities_menus.go index 01fc801096..e6799bc33e 100644 --- a/server/source/system/authorities_menus.go +++ b/server/source/system/authorities_menus.go @@ -40,8 +40,7 @@ func (i *initMenuAuthority) InitializeData(ctx context.Context) (next context.Co if !ok { return ctx, errors.Wrap(system.ErrMissingDependentContext, "创建 [菜单-权限] 关联失败, 未找到权限表初始化数据") } - initMen := &initMenu{} - menus, ok := ctx.Value(initMen.InitializerName()).([]sysModel.SysBaseMenu) + menus, ok := ctx.Value(new(initMenu).InitializerName()).([]sysModel.SysBaseMenu) if !ok { return next, errors.Wrap(errors.New(""), "创建 [菜单-权限] 关联失败, 未找到菜单表初始化数据") } diff --git a/server/source/system/dictionary_detail.go b/server/source/system/dictionary_detail.go index 7f47939665..938cbc23ec 100644 --- a/server/source/system/dictionary_detail.go +++ b/server/source/system/dictionary_detail.go @@ -43,9 +43,7 @@ func (i *initDictDetail) InitializeData(ctx context.Context) (context.Context, e if !ok { return ctx, system.ErrMissingDBContext } - dictKey := (&initDict{}).InitializerName() - dicts, ok := ctx.Value(dictKey).([]sysModel.SysDictionary) - //dicts, ok := ctx.Value(initDict{}.InitializerName()).([]sysModel.SysDictionary) + dicts, ok := ctx.Value(new(initDict).InitializerName()).([]sysModel.SysDictionary) if !ok { return ctx, errors.Wrap(system.ErrMissingDependentContext, fmt.Sprintf("未找到 %s 表初始化数据", sysModel.SysDictionary{}.TableName())) diff --git a/server/source/system/user.go b/server/source/system/user.go index e54093b4ed..eb9ddfc473 100644 --- a/server/source/system/user.go +++ b/server/source/system/user.go @@ -79,8 +79,7 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er return ctx, errors.Wrap(err, sysModel.SysUser{}.TableName()+"表数据初始化失败!") } next = context.WithValue(ctx, i.InitializerName(), entities) - initAuth := &initAuthority{} - authorityEntities, ok := ctx.Value(initAuth.InitializerName()).([]sysModel.SysAuthority) + authorityEntities, ok := ctx.Value(new(initAuthority).InitializerName()).([]sysModel.SysAuthority) if !ok { return next, errors.Wrap(system.ErrMissingDependentContext, "创建 [用户-权限] 关联失败, 未找到权限表初始化数据") }