Commit 791c767a by RuoYi

一些优化细节

parent f6572861
......@@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 通用Map数据
* 通用数据库映射Map数据
*
* @author ruoyi
*/
......
......@@ -45,21 +45,21 @@ public class Constants
/**
* 当前记录起始索引
*/
public static String PAGENUM = "pageNum";
public static String PAGE_NUM = "pageNum";
/**
* 每页显示记录数
*/
public static String PAGESIZE = "pageSize";
public static String PAGE_SIZE = "pageSize";
/**
* 排序列
*/
public static String ORDERBYCOLUMN = "orderByColumn";
public static String ORDER_BY_COLUMN = "orderByColumn";
/**
* 排序的方向 "desc" 或者 "asc".
*/
public static String ISASC = "isAsc";
public static String IS_ASC = "isAsc";
}
package com.ruoyi.common.constant;
/**
* 权限通用常量
*
* @author ruoyi
*/
public class PermissionConstants
{
/** 新增权限 */
public static final String ADD_PERMISSION = "add";
/** 修改权限 */
public static final String EDIT_PERMISSION = "edit";
/** 删除权限 */
public static final String REMOVE_PERMISSION = "remove";
/** 显示权限 */
public static final String VIEW_PERMISSION = "view";
/** 查询权限 */
public static final String LIST_PERMISSION = "list";
}
......@@ -19,8 +19,7 @@ public class InvalidExtensionException extends FileUploadException
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
{
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : ["
+ Arrays.toString(allowedExtension) + "]");
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
this.allowedExtension = allowedExtension;
this.extension = extension;
this.filename = filename;
......
......@@ -30,7 +30,7 @@ public class AddressUtils
}
catch (Exception e)
{
log.error("根据IP获取所在位置----------错误消息:" + e.getMessage());
log.error("获取地理位置异常:", e);
}
return address;
}
......
......@@ -12,7 +12,7 @@ import com.ruoyi.common.support.StrFormatter;
*
* @author ruoyi
*/
public class StringUtils
public class StringUtils extends org.apache.commons.lang3.StringUtils
{
/** 空字符串 */
private static final String NULLSTR = "";
......
......@@ -304,7 +304,7 @@ public class ExcelUtil<T>
}
catch (Exception e)
{
log.error("导出Excel失败{}", e);
log.error("导出Excel失败{}", e.getMessage());
}
}
}
......@@ -319,7 +319,7 @@ public class ExcelUtil<T>
}
catch (Exception e)
{
log.error("关闭flush失败{}", e);
log.error("关闭flush失败{}", e.getMessage());
return AjaxResult.error("导出Excel失败,请联系网站管理员!");
}
}
......
package com.ruoyi.common.utils.security;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.common.constant.PermissionConstants;
import com.ruoyi.common.utils.MessageUtils;
/**
* permission 工具类
*
* @author ruoyi
*/
public class PermissionUtils
{
/**
* 权限错误消息提醒
*
* @param errorMsg 错误信息
* @return
*/
public static String getMsg(String permissionsStr)
{
String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
String msg = MessageUtils.message("no.view.permission", permission);
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
{
msg = MessageUtils.message("no.create.permission", permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
{
msg = MessageUtils.message("no.update.permission", permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
{
msg = MessageUtils.message("no.delete.permission", permission);
}
else if (StringUtils.endsWithAny(permission, new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
{
msg = MessageUtils.message("no.view.permission", permission);
}
return msg;
}
}
......@@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自定义注解
* 自定义导出Excel数据注解
*
* @author ruoyi
*/
......
......@@ -64,7 +64,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
}
catch (Exception e)
{
log.debug("Encountered session exception during logout. This can generally safely be ignored.", e);
log.error("Encountered session exception during logout. This can generally safely be ignored.", e);
}
return false;
}
......
......@@ -121,9 +121,7 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
{
if (log.isErrorEnabled())
{
log.error(
"Error starting the Spring Scheduler session validation job. Session validation may not occur.",
e);
log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e);
}
}
}
......
......@@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.ruoyi.common.exception.DemoModeException;
import com.ruoyi.common.utils.security.PermissionUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
/**
......@@ -27,7 +27,7 @@ public class DefaultExceptionHandler
public AjaxResult handleAuthorizationException(AuthorizationException e)
{
log.error(e.getMessage(), e);
return AjaxResult.error("您没有数据的权限,请联系管理员添加");
return AjaxResult.error(PermissionUtils.getMsg(e.getMessage()));
}
/**
......
......@@ -16,10 +16,10 @@ public class TableSupport
public static PageDomain getPageDomain()
{
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGENUM));
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGESIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDERBYCOLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.ISASC));
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
return pageDomain;
}
......
......@@ -54,7 +54,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("getCronTrigger 异常:", e);
}
return null;
}
......@@ -89,11 +89,11 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("createScheduleJob 异常:", e);
}
catch (TaskException e)
{
log.error(e.getMessage());
log.error("createScheduleJob 异常:", e);
}
}
......@@ -129,11 +129,11 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("SchedulerException 异常:", e);
}
catch (TaskException e)
{
log.error(e.getMessage());
log.error("SchedulerException 异常:", e);
}
}
......@@ -154,7 +154,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("run 异常:", e);
}
return rows;
}
......@@ -170,7 +170,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("pauseJob 异常:", e);
}
}
......@@ -185,7 +185,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("resumeJob 异常:", e);
}
}
......@@ -200,7 +200,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("deleteScheduleJob 异常:", e);
}
}
......
......@@ -149,7 +149,7 @@ public class ProfileController extends BaseController
}
catch (Exception e)
{
log.error("updateAvatar failed!", e);
log.error("修改头像失败!", e);
return error(e.getMessage());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment