【fix sonar】JeroDataAutorUtils文件
This commit is contained in:
+17
-13
@@ -14,28 +14,32 @@ import java.util.List;
|
|||||||
* @Description: 数据权限查询规则容器工具类
|
* @Description: 数据权限查询规则容器工具类
|
||||||
* @Author: 张代浩
|
* @Author: 张代浩
|
||||||
* @Date: 2012-12-15 下午11:27:39
|
* @Date: 2012-12-15 下午11:27:39
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JeroDataAutorUtils {
|
public class JeroDataAutorUtils {
|
||||||
|
|
||||||
|
private JeroDataAutorUtils(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static final String MENU_DATA_AUTHOR_RULES = "MENU_DATA_AUTHOR_RULES";
|
public static final String MENU_DATA_AUTHOR_RULES = "MENU_DATA_AUTHOR_RULES";
|
||||||
|
|
||||||
public static final String MENU_DATA_AUTHOR_RULE_SQL = "MENU_DATA_AUTHOR_RULE_SQL";
|
public static final String MENU_DATA_AUTHOR_RULE_SQL = "MENU_DATA_AUTHOR_RULE_SQL";
|
||||||
|
|
||||||
public static final String SYS_USER_INFO = "SYS_USER_INFO";
|
public static final String SYS_USER_INFO = "SYS_USER_INFO";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 往链接请求里面,传入数据查询条件
|
* 往链接请求里面,传入数据查询条件
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param dataRules
|
* @param dataRules
|
||||||
*/
|
*/
|
||||||
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
|
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST
|
List<SysPermissionDataRuleModel> list = loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST
|
||||||
if (list==null) {
|
if (list==null) {
|
||||||
// 2.如果不存在,则new一个list
|
// 2.如果不存在,则new一个list
|
||||||
list = new ArrayList<SysPermissionDataRuleModel>();
|
list = new ArrayList<>();
|
||||||
}
|
}
|
||||||
for (SysPermissionDataRuleModel tsDataRule : dataRules) {
|
for (SysPermissionDataRuleModel tsDataRule : dataRules) {
|
||||||
list.add(tsDataRule);
|
list.add(tsDataRule);
|
||||||
@@ -45,18 +49,18 @@ public class JeroDataAutorUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取请求对应的数据权限规则
|
* 获取请求对应的数据权限规则
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() {
|
public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() {
|
||||||
return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
|
return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取请求对应的数据权限SQL
|
* 获取请求对应的数据权限SQL
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static synchronized String loadDataSearchConditonSQLString() {
|
public static synchronized String loadDataSearchConditonSQLString() {
|
||||||
@@ -65,12 +69,12 @@ public class JeroDataAutorUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 往链接请求里面,传入数据查询条件
|
* 往链接请求里面,传入数据查询条件
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param sql
|
* @param sql
|
||||||
*/
|
*/
|
||||||
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
|
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
|
||||||
String ruleSql = (String)loadDataSearchConditonSQLString();
|
String ruleSql = loadDataSearchConditonSQLString();
|
||||||
if (!StringUtils.hasText(ruleSql)) {
|
if (!StringUtils.hasText(ruleSql)) {
|
||||||
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL,sql);
|
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL,sql);
|
||||||
}
|
}
|
||||||
@@ -99,6 +103,6 @@ public class JeroDataAutorUtils {
|
|||||||
*/
|
*/
|
||||||
public static synchronized SysUserCacheInfo loadUserInfo() {
|
public static synchronized SysUserCacheInfo loadUserInfo() {
|
||||||
return (SysUserCacheInfo) SpringContextUtils.getHttpServletRequest().getAttribute(SYS_USER_INFO);
|
return (SysUserCacheInfo) SpringContextUtils.getHttpServletRequest().getAttribute(SYS_USER_INFO);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user