修改bug

master
wangwei 2 years ago
parent 30eda1c060
commit 91e4a9021e

@ -133,7 +133,10 @@ public class SysRoleController extends BaseController {
@DeleteMapping("/{roleIds}")
public BaseResponse remove(@PathVariable Long[] roleIds) {
int i = roleService.deleteRoleByIds(roleIds);
return ResultVOUtils.success("修改成功!");
if(i>0){
return ResultVOUtils.success("修改成功!");
}
return ResultVOUtils.error(500,"已绑定用户,不能删除!");
}
/**

@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.constant.Constant;
import com.glxp.api.dao.auth.SysRoleMapper;
import com.glxp.api.dao.auth.SysRoleMenuMapper;
@ -318,18 +320,27 @@ public class SysRoleServiceImpl implements ISysRoleService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteRoleByIds(Long[] roleIds) {
int i=0;
for (Long roleId : roleIds) {
checkRoleAllowed(new SysRole(roleId));
checkRoleDataScope(roleId);
SysRole role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0) {
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
i++;
// throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
List<Long> ids = Arrays.asList(roleIds);
// 删除角色与菜单关联
roleMenuMapper.deleteByList(ids);
return sysRoleMapper.deleteBatchIds(ids);
if(i>0){
return 0;
}else{
List<Long> ids = Arrays.asList(roleIds);
// 删除角色与菜单关联
roleMenuMapper.deleteByList(ids);
sysRoleMapper.deleteBatchIds(ids);
return sysRoleMapper.deleteBatchIds(ids);
}
}
/**

Loading…
Cancel
Save