升级SpringBoot到最新版本2.1.1
This commit is contained in:
@ -91,4 +91,11 @@ public interface SysDeptMapper
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<String> selectRoleDeptTree(Long roleId);
|
||||
|
||||
/**
|
||||
* 修改所在部门的父级部门状态
|
||||
*
|
||||
* @param dept 部门
|
||||
*/
|
||||
public void updateDeptStatus(SysDept dept);
|
||||
}
|
||||
|
@ -29,12 +29,14 @@ public interface SysLogininforMapper
|
||||
* 批量删除系统登录日志
|
||||
*
|
||||
* @param ids 需要删除的数据
|
||||
* @return
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteLogininforByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int cleanLogininfor();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysDept;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
@ -162,6 +163,11 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
public int insertDept(SysDept dept)
|
||||
{
|
||||
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
||||
// 如果父节点不为"正常"状态,则不允许新增子节点
|
||||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
|
||||
{
|
||||
throw new BusinessException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
@ -178,11 +184,30 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
||||
if (StringUtils.isNotNull(info))
|
||||
{
|
||||
String ancestors = info.getAncestors() + "," + dept.getParentId();
|
||||
String ancestors = info.getAncestors() + "," + info.getDeptId();
|
||||
dept.setAncestors(ancestors);
|
||||
updateDeptChildren(dept.getDeptId(), ancestors);
|
||||
}
|
||||
return deptMapper.updateDept(dept);
|
||||
int result = deptMapper.updateDept(dept);
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
|
||||
{
|
||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
updateParentDeptStatus(dept);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改该部门的父级部门状态
|
||||
*
|
||||
* @param dept 当前部门
|
||||
*/
|
||||
private void updateParentDeptStatus(SysDept dept)
|
||||
{
|
||||
String updateBy = dept.getUpdateBy();
|
||||
dept = deptMapper.selectDeptById(dept.getDeptId());
|
||||
dept.setUpdateBy(updateBy);
|
||||
deptMapper.updateDeptStatus(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
@ -79,7 +80,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictTypeByIds(String ids) throws Exception
|
||||
public int deleteDictTypeByIds(String ids) throws BusinessException
|
||||
{
|
||||
Long[] dictIds = Convert.toLongArray(ids);
|
||||
for (Long dictId : dictIds)
|
||||
@ -87,7 +88,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
|
||||
{
|
||||
throw new Exception(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
throw new BusinessException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
@ -92,7 +93,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(String ids) throws Exception
|
||||
public int deletePostByIds(String ids) throws BusinessException
|
||||
{
|
||||
Long[] postIds = Convert.toLongArray(ids);
|
||||
for (Long postId : postIds)
|
||||
@ -100,7 +101,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||
SysPost post = selectPostById(postId);
|
||||
if (countUserPostById(postId) > 0)
|
||||
{
|
||||
throw new Exception(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
throw new BusinessException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return postMapper.deletePostByIds(postIds);
|
||||
|
@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
@ -141,7 +142,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int deleteRoleByIds(String ids) throws Exception
|
||||
public int deleteRoleByIds(String ids) throws BusinessException
|
||||
{
|
||||
Long[] roleIds = Convert.toLongArray(ids);
|
||||
for (Long roleId : roleIds)
|
||||
@ -149,7 +150,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
SysRole role = selectRoleById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0)
|
||||
{
|
||||
throw new Exception(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
return roleMapper.deleteRoleByIds(roleIds);
|
||||
|
@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
@ -128,14 +129,14 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserByIds(String ids) throws Exception
|
||||
public int deleteUserByIds(String ids) throws BusinessException
|
||||
{
|
||||
Long[] userIds = Convert.toLongArray(ids);
|
||||
for (Long userId : userIds)
|
||||
{
|
||||
if (SysUser.isAdmin(userId))
|
||||
{
|
||||
throw new Exception("不允许删除超级管理员用户");
|
||||
throw new BusinessException("不允许删除超级管理员用户");
|
||||
}
|
||||
}
|
||||
return userMapper.deleteUserByIds(userIds);
|
||||
|
Reference in New Issue
Block a user