权限错误消息提醒添加注释,方便理解

dep_wangsr
RuoYi 6 years ago committed by Limy
parent 7f0ca33d8a
commit 6acb025d6b

@ -7,7 +7,7 @@ import com.ruoyi.common.config.Global;
import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException; import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
import com.ruoyi.common.exception.file.FileSizeLimitExceededException; import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.Md5Utils; import com.ruoyi.common.utils.security.Md5Utils;
/** /**
* *

@ -1,4 +1,4 @@
package com.ruoyi.common.utils; package com.ruoyi.common.utils.security;
import java.security.MessageDigest; import java.security.MessageDigest;
import org.slf4j.Logger; import org.slf4j.Logger;

@ -0,0 +1,77 @@
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
{
/**
*
*/
public static final String VIEW_PERMISSION = "no.view.permission";
/**
*
*/
public static final String CREATE_PERMISSION = "no.create.permission";
/**
*
*/
public static final String UPDATE_PERMISSION = "no.update.permission";
/**
*
*/
public static final String DELETE_PERMISSION = "no.delete.permission";
/**
*
*/
public static final String EXPORT_PERMISSION = "no.export.permission";
/**
*
*/
public static final String PERMISSION = "no.permission";
/**
*
*
* @param permissionsStr
* @return
*/
public static String getMsg(String permissionsStr)
{
String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
String msg = MessageUtils.message(PERMISSION, permission);
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
{
msg = MessageUtils.message(CREATE_PERMISSION, permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
{
msg = MessageUtils.message(UPDATE_PERMISSION, permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
{
msg = MessageUtils.message(DELETE_PERMISSION, permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
{
msg = MessageUtils.message(EXPORT_PERMISSION, permission);
}
else if (StringUtils.endsWithAny(permission,
new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
{
msg = MessageUtils.message(VIEW_PERMISSION, permission);
}
return msg;
}
}

@ -1,47 +0,0 @@
package com.ruoyi.framework.util;
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 permissionsStr
* @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.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
{
msg = MessageUtils.message("no.export.permission", permission);
}
else if (StringUtils.endsWithAny(permission,
new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
{
msg = MessageUtils.message("no.view.permission", permission);
}
return msg;
}
}

@ -12,7 +12,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.exception.DemoModeException; import com.ruoyi.common.exception.DemoModeException;
import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.util.PermissionUtils; import com.ruoyi.common.utils.security.PermissionUtils;
/** /**
* *

@ -11,8 +11,8 @@ import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.Md5Utils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.Md5Utils;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysRole; import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser; import com.ruoyi.system.domain.SysUser;

Loading…
Cancel
Save