master
chen 2 years ago
parent fbfbbea7c1
commit 01f5d044b2
  1. 7
      src/main/java/com/huoran/iasf/controller/RoleController.java
  2. 4
      src/main/java/com/huoran/iasf/controller/UserController.java
  3. 2
      src/main/java/com/huoran/iasf/entity/SysDept.java
  4. 2
      src/main/java/com/huoran/iasf/service/RoleService.java
  5. 7
      src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java
  6. 27
      src/main/java/com/huoran/iasf/service/impl/RoleServiceImpl.java

@ -13,6 +13,7 @@ import com.huoran.iasf.service.RoleService;
import com.huoran.iasf.vo.req.RolePermissionOperationReqVO; import com.huoran.iasf.vo.req.RolePermissionOperationReqVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -65,12 +66,12 @@ public class RoleController {
return R.success(); return R.success();
} }
@DeleteMapping("/role/{id}") @DeleteMapping("/role/deleted")
@ApiOperation(value = "删除角色接口") @ApiOperation(value = "删除角色接口")
@LogAnnotation(title = "角色管理", action = "删除角色") @LogAnnotation(title = "角色管理", action = "删除角色")
@RequiresPermissions("sys:role:deleted") @RequiresPermissions("sys:role:deleted")
public R deleted(@PathVariable("id") Integer id) { public R deleted(@RequestBody @ApiParam(value = "id集合") List<Integer> ids) {
roleService.deletedRole(id); roleService.deletedRole(ids);
return R.success(); return R.success();
} }

@ -162,8 +162,8 @@ public class UserController {
if (StringUtils.isEmpty(vo.getOldPwd()) || StringUtils.isEmpty(vo.getNewPwd())) { if (StringUtils.isEmpty(vo.getOldPwd()) || StringUtils.isEmpty(vo.getNewPwd())) {
return R.fail("旧密码与新密码不能为空"); return R.fail("旧密码与新密码不能为空");
} }
Integer userId = httpSessionService.getCurrentUserId(); // Integer userId = httpSessionService.getCurrentUserId();
vo.setId(userId); // vo.setId(userId);
userService.updatePwd(vo); userService.updatePwd(vo);
return R.success(); return R.success();
} }

@ -31,7 +31,7 @@ public class SysDept implements Serializable {
@ApiModelProperty(value = "部门名称") @ApiModelProperty(value = "部门名称")
private String name; private String name;
@NotBlank(message = "父级不能为空") // @NotBlank(message = "父级不能为空")
@ApiModelProperty(value = "父级id") @ApiModelProperty(value = "父级id")
private Integer pid; private Integer pid;

@ -33,7 +33,7 @@ public interface RoleService extends IService<SysRole> {
* *
* @param id id * @param id id
*/ */
void deletedRole(Integer id); void deletedRole(List<Integer> ids);
/** /**
* 根据userId获取绑定的角色 * 根据userId获取绑定的角色

@ -48,7 +48,10 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
String relationCode; String relationCode;
String deptCode = this.getNewDeptCode(); String deptCode = this.getNewDeptCode();
SysDept parent = sysDeptMapper.selectById(vo.getPid()); SysDept parent = sysDeptMapper.selectById(vo.getPid());
if ("0".equals(vo.getPid())) { if (vo.getPid()==null){
vo.setPid(0);
}
if (vo.getPid()==0) {
relationCode = deptCode; relationCode = deptCode;
} else if (null == parent) { } else if (null == parent) {
throw new BusinessException(BaseResponseCode.DATA_ERROR); throw new BusinessException(BaseResponseCode.DATA_ERROR);
@ -160,7 +163,7 @@ public class DeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impleme
private List<DeptRespNodeVO> getTree(List<SysDept> all) { private List<DeptRespNodeVO> getTree(List<SysDept> all) {
List<DeptRespNodeVO> list = new ArrayList<>(); List<DeptRespNodeVO> list = new ArrayList<>();
for (SysDept sysDept : all) { for (SysDept sysDept : all) {
if ("0".equals(sysDept.getPid())) { if (sysDept.getPid()==0) {
DeptRespNodeVO deptTree = new DeptRespNodeVO(); DeptRespNodeVO deptTree = new DeptRespNodeVO();
BeanUtils.copyProperties(sysDept, deptTree); BeanUtils.copyProperties(sysDept, deptTree);
deptTree.setName(sysDept.getName()); deptTree.setName(sysDept.getName());

@ -104,18 +104,21 @@ public class RoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impleme
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public void deletedRole(Integer id) { public void deletedRole(List<Integer> ids) {
//获取关联userId
List<Integer> userIds = userRoleService.getUserIdsByRoleId(id); for (Integer id : ids) {
//删除角色 //获取关联userId
sysRoleMapper.deleteById(id); List<Integer> userIds = userRoleService.getUserIdsByRoleId(id);
//删除角色权限关联 //删除角色
rolePermissionService.remove(Wrappers.<SysRolePermission>lambdaQuery().eq(SysRolePermission::getRoleId, id)); sysRoleMapper.deleteById(id);
//删除角色用户关联 //删除角色权限关联
userRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getRoleId, id)); rolePermissionService.remove(Wrappers.<SysRolePermission>lambdaQuery().eq(SysRolePermission::getRoleId, id));
if (!CollectionUtils.isEmpty(userIds)) { //删除角色用户关联
// 刷新权限 userRoleService.remove(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getRoleId, id));
userIds.parallelStream().forEach(httpSessionService::refreshUerId); if (!CollectionUtils.isEmpty(userIds)) {
// 刷新权限
userIds.parallelStream().forEach(httpSessionService::refreshUerId);
}
} }
} }

Loading…
Cancel
Save