feat: 完成多模块功能迭代与优化
本次提交包含多模块功能更新: 1. 权限系统重构:移除硬编码admin放行逻辑,新增精细化权限控制,完善权限树形结构与用户/角色保护 2. 新增物料导入导出接口,补充台账查询条件 3. 优化列表查询排序逻辑,新增区域编码大小写不敏感搜索 4. 修复帮助抽屉重复弹出问题,补充页面权限控制 5. 新增弱密码提示逻辑,优化MES/WMS用户/角色管理权限 6. 调整路由结构,新增权限校验脚本与前端权限树重构 7. 补充数据库字段与依赖包更新
This commit is contained in:
@@ -355,6 +355,15 @@ func (s *Service) CreateUser(ctx context.Context, req UserReq) error {
|
||||
}
|
||||
|
||||
func (s *Service) UpdateUser(ctx context.Context, req UserReq) error {
|
||||
// 内置管理员账号(SUPER_ADMIN)不允许通过管理接口修改(含禁用/改角色/改密码等)
|
||||
if usr, e := s.ctx.EntClient.User.Get(ctx, req.Id); e == nil {
|
||||
if usr.Username == "admin" {
|
||||
return errors.New("系统内置管理员账号不允许修改")
|
||||
}
|
||||
if rl, e2 := s.ctx.EntClient.Role.Get(ctx, usr.RoleId); e2 == nil && rl.Code == "SUPER_ADMIN" {
|
||||
return errors.New("系统内置管理员账号不允许修改")
|
||||
}
|
||||
}
|
||||
u := s.ctx.EntClient.User.UpdateOneID(req.Id).SetRoleId(req.RoleId).SetName(req.Name).
|
||||
SetCanLoginWorkstation(req.CanLoginWorkstation)
|
||||
if req.Password != "" {
|
||||
@@ -413,8 +422,16 @@ func (s *Service) UserStations(ctx context.Context, userId int) []int {
|
||||
}
|
||||
|
||||
func (s *Service) DeleteUser(ctx context.Context, id int) error {
|
||||
if id == 1 {
|
||||
return errors.New("不能删除超级管理员")
|
||||
usr, err := s.ctx.EntClient.User.Get(ctx, id)
|
||||
if err != nil {
|
||||
return errors.New("用户不存在")
|
||||
}
|
||||
// 内置管理员账号(SUPER_ADMIN)不允许删除
|
||||
if usr.Username == "admin" {
|
||||
return errors.New("系统内置管理员账号不允许删除")
|
||||
}
|
||||
if rl, e2 := s.ctx.EntClient.Role.Get(ctx, usr.RoleId); e2 == nil && rl.Code == "SUPER_ADMIN" {
|
||||
return errors.New("系统内置管理员账号不允许删除")
|
||||
}
|
||||
return s.ctx.EntClient.User.DeleteOneID(id).Exec(ctx)
|
||||
}
|
||||
@@ -465,6 +482,10 @@ func (s *Service) CreateRole(ctx context.Context, req RoleReq) error {
|
||||
}
|
||||
|
||||
func (s *Service) UpdateRole(ctx context.Context, req RoleReq) error {
|
||||
// 内置管理员角色(SUPER_ADMIN)不允许修改其权限(admin 拥有所有权限,且不可被缩减)
|
||||
if rl, e := s.ctx.EntClient.Role.Get(ctx, req.Id); e == nil && rl.Code == "SUPER_ADMIN" {
|
||||
return errors.New("内置管理员角色不允许修改其权限")
|
||||
}
|
||||
return s.ctx.EntClient.Role.UpdateOneID(req.Id).
|
||||
SetName(req.Name).SetCode(req.Code).SetRemark(req.Remark).
|
||||
SetPermissionCodes(req.PermissionCodes).Exec(ctx)
|
||||
|
||||
Reference in New Issue
Block a user