|
@ -48,25 +48,30 @@ public class RoleServiceImpl implements RoleService { |
|
|
if (roleVo.getRoleName() == null || roleVo.getRoleName().isEmpty()) { |
|
|
if (roleVo.getRoleName() == null || roleVo.getRoleName().isEmpty()) { |
|
|
return Result.error("角色名为空"); |
|
|
return Result.error("角色名为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
// 新增校验:角色名长度需在 2 - 20 之间 |
|
|
|
|
|
if (roleVo.getRoleName().length() < 2 || roleVo.getRoleName().length() > 20) { |
|
|
|
|
|
return Result.error("角色名长度需在2-20个字符之间"); |
|
|
|
|
|
} |
|
|
if (roleMapper.selectByRoleName(roleVo.getRoleName()) != null) { |
|
|
if (roleMapper.selectByRoleName(roleVo.getRoleName()) != null) { |
|
|
return Result.error("角色名重复"); |
|
|
return Result.error("角色名重复"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (roleVo.getPriority() == null) { |
|
|
if (roleVo.getPriority() == null) { |
|
|
return Result.error("优先级为空"); |
|
|
return Result.error("优先级为空"); |
|
|
} |
|
|
} |
|
|
if (roleVo.getPriority()<=0||roleVo.getPriority()>999) { |
|
|
|
|
|
|
|
|
if (roleVo.getPriority() <= 0 || roleVo.getPriority() > 999) { |
|
|
return Result.error("优先级不在1-999"); |
|
|
return Result.error("优先级不在1-999"); |
|
|
} |
|
|
} |
|
|
if (roleVo.getMenuIds() == null || roleVo.getMenuIds().isEmpty()) { |
|
|
if (roleVo.getMenuIds() == null || roleVo.getMenuIds().isEmpty()) { |
|
|
return Result.error("权限为空"); |
|
|
return Result.error("权限为空"); |
|
|
} |
|
|
} |
|
|
if(roleVo.getMarket() == null|| roleVo.getMarket().isEmpty()){ |
|
|
|
|
|
|
|
|
if (roleVo.getMarket() == null || roleVo.getMarket().isEmpty()) { |
|
|
return Result.error("所属市场为空"); |
|
|
return Result.error("所属市场为空"); |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
if(roleVo.getFatherId() != 2) { |
|
|
|
|
|
for(Integer menuId : roleVo.getMenuIds()){ |
|
|
|
|
|
if(menuId == 9){ |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (roleVo.getFatherId() != 2) { |
|
|
|
|
|
for (Integer menuId : roleVo.getMenuIds()) { |
|
|
|
|
|
if (menuId == 9) { |
|
|
return Result.error("上级角色非管理员用户不能赋予权限管理"); |
|
|
return Result.error("上级角色非管理员用户不能赋予权限管理"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -96,10 +101,10 @@ public class RoleServiceImpl implements RoleService { |
|
|
if (roleVo.getId() == null) { |
|
|
if (roleVo.getId() == null) { |
|
|
return Result.error("角色id为空"); |
|
|
return Result.error("角色id为空"); |
|
|
} |
|
|
} |
|
|
if(roleVo.getId() == 2){ |
|
|
|
|
|
|
|
|
if (roleVo.getId() == 2) { |
|
|
return Result.error("管理员不允许删除"); |
|
|
return Result.error("管理员不允许删除"); |
|
|
} |
|
|
} |
|
|
if(roleVo.getId() == 1){ |
|
|
|
|
|
|
|
|
if (roleVo.getId() == 1) { |
|
|
return Result.error("无用户不允许删除"); |
|
|
return Result.error("无用户不允许删除"); |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|