PermissionUtils.java
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.huaheng.common.utils.security;
import org.apache.commons.lang3.StringUtils;
import com.huaheng.common.constant.PermissionConstants;
import com.huaheng.common.utils.MessageUtils;
/**
* permission 工具类
*
* @author huaheng
*/
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;
}
}