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, "创建 [用户-权限] 关联失败, 未找到权限表初始化数据") }