diff --git a/src/main/java/com/huoran/iasf/controller/RoleController.java b/src/main/java/com/huoran/iasf/controller/RoleController.java index 069de97..94c37a3 100644 --- a/src/main/java/com/huoran/iasf/controller/RoleController.java +++ b/src/main/java/com/huoran/iasf/controller/RoleController.java @@ -13,6 +13,7 @@ import com.huoran.iasf.service.RoleService; import com.huoran.iasf.vo.req.RolePermissionOperationReqVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -65,12 +66,12 @@ public class RoleController { return R.success(); } - @DeleteMapping("/role/{id}") + @DeleteMapping("/role/deleted") @ApiOperation(value = "删除角色接口") @LogAnnotation(title = "角色管理", action = "删除角色") @RequiresPermissions("sys:role:deleted") - public R deleted(@PathVariable("id") Integer id) { - roleService.deletedRole(id); + public R deleted(@RequestBody @ApiParam(value = "id集合") List ids) { + roleService.deletedRole(ids); return R.success(); } diff --git a/src/main/java/com/huoran/iasf/controller/UserController.java b/src/main/java/com/huoran/iasf/controller/UserController.java index c294a85..da03ce9 100644 --- a/src/main/java/com/huoran/iasf/controller/UserController.java +++ b/src/main/java/com/huoran/iasf/controller/UserController.java @@ -162,8 +162,8 @@ public class UserController { if (StringUtils.isEmpty(vo.getOldPwd()) || StringUtils.isEmpty(vo.getNewPwd())) { return R.fail("旧密码与新密码不能为空"); } - Integer userId = httpSessionService.getCurrentUserId(); - vo.setId(userId); + // Integer userId = httpSessionService.getCurrentUserId(); + // vo.setId(userId); userService.updatePwd(vo); return R.success(); } diff --git a/src/main/java/com/huoran/iasf/entity/SysDept.java b/src/main/java/com/huoran/iasf/entity/SysDept.java index a1d6cd7..b83727b 100644 --- a/src/main/java/com/huoran/iasf/entity/SysDept.java +++ b/src/main/java/com/huoran/iasf/entity/SysDept.java @@ -31,7 +31,7 @@ public class SysDept implements Serializable { @ApiModelProperty(value = "部门名称") private String name; - @NotBlank(message = "父级不能为空") + // @NotBlank(message = "父级不能为空") @ApiModelProperty(value = "父级id") private Integer pid; diff --git a/src/main/java/com/huoran/iasf/service/RoleService.java b/src/main/java/com/huoran/iasf/service/RoleService.java index f9478cc..7558497 100644 --- a/src/main/java/com/huoran/iasf/service/RoleService.java +++ b/src/main/java/com/huoran/iasf/service/RoleService.java @@ -33,7 +33,7 @@ public interface RoleService extends IService { * * @param id id */ - void deletedRole(Integer id); + void deletedRole(List ids); /** * 根据userId获取绑定的角色 diff --git a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java index c7b4cb4..6276c8d 100644 --- a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java @@ -48,7 +48,10 @@ public class DeptServiceImpl extends ServiceImpl impleme String relationCode; String deptCode = this.getNewDeptCode(); SysDept parent = sysDeptMapper.selectById(vo.getPid()); - if ("0".equals(vo.getPid())) { + if (vo.getPid()==null){ + vo.setPid(0); + } + if (vo.getPid()==0) { relationCode = deptCode; } else if (null == parent) { throw new BusinessException(BaseResponseCode.DATA_ERROR); @@ -160,7 +163,7 @@ public class DeptServiceImpl extends ServiceImpl impleme private List getTree(List all) { List list = new ArrayList<>(); for (SysDept sysDept : all) { - if ("0".equals(sysDept.getPid())) { + if (sysDept.getPid()==0) { DeptRespNodeVO deptTree = new DeptRespNodeVO(); BeanUtils.copyProperties(sysDept, deptTree); deptTree.setName(sysDept.getName()); diff --git a/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java index c383740..ded14d3 100644 --- a/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java @@ -104,18 +104,21 @@ public class RoleServiceImpl extends ServiceImpl impleme @Transactional(rollbackFor = Exception.class) @Override - public void deletedRole(Integer id) { - //获取关联userId - List userIds = userRoleService.getUserIdsByRoleId(id); - //删除角色 - sysRoleMapper.deleteById(id); - //删除角色权限关联 - rolePermissionService.remove(Wrappers.lambdaQuery().eq(SysRolePermission::getRoleId, id)); - //删除角色用户关联 - userRoleService.remove(Wrappers.lambdaQuery().eq(SysUserRole::getRoleId, id)); - if (!CollectionUtils.isEmpty(userIds)) { - // 刷新权限 - userIds.parallelStream().forEach(httpSessionService::refreshUerId); + public void deletedRole(List ids) { + + for (Integer id : ids) { + //获取关联userId + List userIds = userRoleService.getUserIdsByRoleId(id); + //删除角色 + sysRoleMapper.deleteById(id); + //删除角色权限关联 + rolePermissionService.remove(Wrappers.lambdaQuery().eq(SysRolePermission::getRoleId, id)); + //删除角色用户关联 + userRoleService.remove(Wrappers.lambdaQuery().eq(SysUserRole::getRoleId, id)); + if (!CollectionUtils.isEmpty(userIds)) { + // 刷新权限 + userIds.parallelStream().forEach(httpSessionService::refreshUerId); + } } }