一些优化细节

dep_wangsr
RuoYi 6 years ago committed by Limy
parent e1c223e092
commit e49376dfc6

@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* Map
* Map
*
* @author ruoyi
*/
@ -39,7 +39,7 @@ public class CommonMap
javaTypeMap.put("text", "String");
javaTypeMap.put("mediumtext", "String");
javaTypeMap.put("longtext", "String");
javaTypeMap.put("time", "Date");
javaTypeMap.put("time", "Date");
javaTypeMap.put("date", "Date");
javaTypeMap.put("datetime", "Date");
javaTypeMap.put("timestamp", "Date");

@ -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";
}

@ -0,0 +1,24 @@
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失败请联系网站管理员");
}
}

@ -0,0 +1,42 @@
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());
}
}

Loading…
Cancel
Save