mirror of
https://github.com/yangzongzhuan/RuoYi-Cloud.git
synced 2025-09-02 10:48:41 +00:00
优化异常信息
This commit is contained in:
@@ -24,7 +24,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.GenConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.text.CharsetKit;
|
||||
import com.ruoyi.common.core.utils.SecurityUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
@@ -180,7 +180,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CustomException("导入失败:" + e.getMessage());
|
||||
throw new ServiceException("导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new CustomException("渲染模板失败,表名:" + table.getTableName());
|
||||
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||
if (StringUtils.isEmpty(dbTableColumns))
|
||||
{
|
||||
throw new CustomException("同步数据失败,原表结构不存在");
|
||||
throw new ServiceException("同步数据失败,原表结构不存在");
|
||||
}
|
||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||
|
||||
@@ -383,25 +383,25 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
|
||||
{
|
||||
throw new CustomException("树编码字段不能为空");
|
||||
throw new ServiceException("树编码字段不能为空");
|
||||
}
|
||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
|
||||
{
|
||||
throw new CustomException("树父编码字段不能为空");
|
||||
throw new ServiceException("树父编码字段不能为空");
|
||||
}
|
||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
|
||||
{
|
||||
throw new CustomException("树名称字段不能为空");
|
||||
throw new ServiceException("树名称字段不能为空");
|
||||
}
|
||||
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
|
||||
{
|
||||
if (StringUtils.isEmpty(genTable.getSubTableName()))
|
||||
{
|
||||
throw new CustomException("关联子表的表名不能为空");
|
||||
throw new ServiceException("关联子表的表名不能为空");
|
||||
}
|
||||
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
|
||||
{
|
||||
throw new CustomException("子表关联的外键名不能为空");
|
||||
throw new ServiceException("子表关联的外键名不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.service.RedisService;
|
||||
@@ -137,7 +137,7 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
SysConfig config = selectConfigById(configId);
|
||||
if (StringUtils.equals(UserConstants.YES, config.getConfigType()))
|
||||
{
|
||||
throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
||||
throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
|
||||
}
|
||||
configMapper.deleteConfigById(configId);
|
||||
redisService.deleteObject(getCacheKey(config.getConfigKey()));
|
||||
|
@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||
@@ -184,7 +184,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||
// 如果父节点不为正常状态,则不允许新增子节点
|
||||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
|
||||
{
|
||||
throw new CustomException("部门停用,不允许新增");
|
||||
throw new ServiceException("部门停用,不允许新增");
|
||||
}
|
||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||
return deptMapper.insertDept(dept);
|
||||
|
@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.security.utils.DictUtils;
|
||||
import com.ruoyi.system.api.domain.SysDictData;
|
||||
@@ -122,7 +122,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
|
||||
{
|
||||
throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
dictTypeMapper.deleteDictTypeById(dictId);
|
||||
DictUtils.removeDictCache(dictType.getDictType());
|
||||
|
@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.mapper.SysPostMapper;
|
||||
@@ -149,7 +149,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||
SysPost post = selectPostById(postId);
|
||||
if (countUserPostById(postId) > 0)
|
||||
{
|
||||
throw new CustomException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return postMapper.deletePostByIds(postIds);
|
||||
|
@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||
@@ -183,7 +183,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
{
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
|
||||
{
|
||||
throw new CustomException("不允许操作超级管理员角色");
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
SysRole role = selectRoleById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0)
|
||||
{
|
||||
throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
// 删除角色与菜单关联
|
||||
|
@@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.CustomException;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.SecurityUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.datascope.annotation.DataScope;
|
||||
@@ -223,7 +223,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
{
|
||||
throw new CustomException("不允许操作超级管理员用户");
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
throw new CustomException("导入用户数据不能为空!");
|
||||
throw new ServiceException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
@@ -530,7 +530,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
if (failureNum > 0)
|
||||
{
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new CustomException(failureMsg.toString());
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user