Skip to content

Commit

Permalink
chore:初始化代码规范化。
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmaxQm committed Dec 8, 2024
1 parent 19b174f commit 9d6f761
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions server/source/system/authorities_menus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(""), "创建 [菜单-权限] 关联失败, 未找到菜单表初始化数据")
}
Expand Down
4 changes: 1 addition & 3 deletions server/source/system/dictionary_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
3 changes: 1 addition & 2 deletions server/source/system/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "创建 [用户-权限] 关联失败, 未找到权限表初始化数据")
}
Expand Down

0 comments on commit 9d6f761

Please sign in to comment.