org.jeecg.common.system.vo.SysPermissionDataRuleModel Java Examples
The following examples show how to use
org.jeecg.common.system.vo.SysPermissionDataRuleModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 获取请求对应的数据权限规则 * @return */ public static Map<String, SysPermissionDataRuleModel> getRuleMap() { Map<String, SysPermissionDataRuleModel> ruleMap = new HashMap<String, SysPermissionDataRuleModel>(); List<SysPermissionDataRuleModel> list =JeecgDataAutorUtils.loadDataSearchConditon(); if(list != null&&list.size()>0){ if(list.get(0)==null){ return ruleMap; } for (SysPermissionDataRuleModel rule : list) { String column = rule.getRuleColumn(); if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) { column = SQL_RULES_COLUMN+rule.getId(); } ruleMap.put(column, rule); } } return ruleMap; }
Example #2
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 6 votes |
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) { QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) { String[] values = dataRule.getRuleValue().split(","); Object[] objs = new Object[values.length]; for (int i = 0; i < values.length; i++) { objs[i] = NumberUtils.parseNumber(values[i], propertyType); } addEasyQuery(queryWrapper, name, rule, objs); }else { if (propertyType.equals(String.class)) { addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue())); }else if (propertyType.equals(Date.class)) { String dateStr =converRuleValue(dataRule.getRuleValue()); if(dateStr.length()==10){ addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.date_sdf.get())); }else{ addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.datetimeFormat.get())); } }else { addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType)); } } }
Example #3
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 根据权限相关配置 组装mp需要的权限 * @param queryWrapper * @param clazz * @return */ public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) { //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper); } } }
Example #4
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 根据权限相关配置 组装mp需要的权限 * @param searchObj * @param parameterMap * @return */ public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) { //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper); } } }
Example #5
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 6 votes |
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) { QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) { String[] values = dataRule.getRuleValue().split(","); Object[] objs = new Object[values.length]; for (int i = 0; i < values.length; i++) { objs[i] = NumberUtils.parseNumber(values[i], propertyType); } addEasyQuery(queryWrapper, name, rule, objs); }else { if (propertyType.equals(String.class)) { addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue())); }else if (propertyType.equals(Date.class)) { String dateStr =converRuleValue(dataRule.getRuleValue()); if(dateStr.length()==10){ addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.date_sdf.get())); }else{ addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.datetimeFormat.get())); } }else { addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType)); } } }
Example #6
Source File: QueryGenerator.java From teaching with Apache License 2.0 | 6 votes |
/** * 获取请求对应的数据权限规则 * @return */ public static Map<String, SysPermissionDataRuleModel> getRuleMap() { Map<String, SysPermissionDataRuleModel> ruleMap = new HashMap<String, SysPermissionDataRuleModel>(); List<SysPermissionDataRuleModel> list =JeecgDataAutorUtils.loadDataSearchConditon(); if(list != null&&list.size()>0){ if(list.get(0)==null){ return ruleMap; } for (SysPermissionDataRuleModel rule : list) { String column = rule.getRuleColumn(); if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) { column = SQL_RULES_COLUMN+rule.getId(); } ruleMap.put(column, rule); } } return ruleMap; }
Example #7
Source File: QueryGenerator.java From teaching with Apache License 2.0 | 6 votes |
private static void addRuleToQueryWrapper(SysPermissionDataRuleModel dataRule, String name, Class propertyType, QueryWrapper<?> queryWrapper) { QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); if(rule.equals(QueryRuleEnum.IN) && ! propertyType.equals(String.class)) { String[] values = dataRule.getRuleValue().split(","); Object[] objs = new Object[values.length]; for (int i = 0; i < values.length; i++) { objs[i] = NumberUtils.parseNumber(values[i], propertyType); } addEasyQuery(queryWrapper, name, rule, objs); }else { if (propertyType.equals(String.class)) { addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue())); } else { addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType)); } } }
Example #8
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 获取请求对应的数据权限规则 * @return */ public static Map<String, SysPermissionDataRuleModel> getRuleMap() { Map<String, SysPermissionDataRuleModel> ruleMap = new HashMap<String, SysPermissionDataRuleModel>(); List<SysPermissionDataRuleModel> list =JeecgDataAutorUtils.loadDataSearchConditon(); if(list != null&&list.size()>0){ if(list.get(0)==null){ return ruleMap; } for (SysPermissionDataRuleModel rule : list) { String column = rule.getRuleColumn(); if(QueryRuleEnum.SQL_RULES.getValue().equals(rule.getRuleConditions())) { column = SQL_RULES_COLUMN+rule.getId(); } ruleMap.put(column, rule); } } return ruleMap; }
Example #9
Source File: QueryGenerator.java From teaching with Apache License 2.0 | 6 votes |
/** * 根据权限相关配置 组装mp需要的权限 * @param searchObj * @param parameterMap * @return */ public static void installAuthMplus(QueryWrapper<?> queryWrapper,Class<?> clazz) { //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper); } } }
Example #10
Source File: QueryGenerator.java From teaching with Apache License 2.0 | 5 votes |
/** * 根据权限相关配置生成相关的SQL 语句 * @param searchObj * @param parameterMap * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static String installAuthJdbc(Class<?> clazz) { StringBuffer sb = new StringBuffer(); //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); String sql_and = " and "; for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ sb.append(sql_and+getSqlRuleValue(ruleMap.get(c).getRuleValue())); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { SysPermissionDataRuleModel dataRule = ruleMap.get(name); QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); Class propType = origDescriptors[i].getPropertyType(); boolean isString = propType.equals(String.class); Object value; if(isString) { value = converRuleValue(dataRule.getRuleValue()); }else { value = NumberUtils.parseNumber(dataRule.getRuleValue(),propType); } String filedSql = getSingleSqlByRule(rule, oConvertUtils.camelToUnderline(name), value,isString); sb.append(sql_and+filedSql); } } log.info("query auth sql is:"+sb.toString()); return sb.toString(); }
Example #11
Source File: JeecgDataAutorUtils.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 往链接请求里面,传入数据查询条件 * * @param request * @param dataRules */ public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) { @SuppressWarnings("unchecked") List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST if (list==null) { // 2.如果不存在,则new一个list list = new ArrayList<SysPermissionDataRuleModel>(); } for (SysPermissionDataRuleModel tsDataRule : dataRules) { list.add(tsDataRule); } request.setAttribute(MENU_DATA_AUTHOR_RULES, list); // 3.往list里面增量存指 }
Example #12
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 获取所有配置的权限 返回sql字符串 不受字段限制 配置什么就拿到什么 * @return */ public static String getAllConfigAuth() { StringBuffer sb = new StringBuffer(); //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); String sql_and = " and "; for (String c : ruleMap.keySet()) { SysPermissionDataRuleModel dataRule = ruleMap.get(c); String ruleValue = dataRule.getRuleValue(); if(oConvertUtils.isEmpty(ruleValue)){ continue; } if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ sb.append(sql_and+getSqlRuleValue(ruleValue)); }else{ boolean isString = false; ruleValue = ruleValue.trim(); if(ruleValue.startsWith("'") && ruleValue.endsWith("'")){ isString = true; ruleValue = ruleValue.substring(1,ruleValue.length()-1); } QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); String value = converRuleValue(ruleValue); String filedSql = getSingleSqlByRule(rule, c, value,isString); sb.append(sql_and+filedSql); } } log.info("query auth sql is = "+sb.toString()); return sb.toString(); }
Example #13
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 根据权限相关配置生成相关的SQL 语句 * @param searchObj * @param parameterMap * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static String installAuthJdbc(Class<?> clazz) { StringBuffer sb = new StringBuffer(); //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); String sql_and = " and "; for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ sb.append(sql_and+getSqlRuleValue(ruleMap.get(c).getRuleValue())); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { SysPermissionDataRuleModel dataRule = ruleMap.get(name); QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); Class propType = origDescriptors[i].getPropertyType(); boolean isString = propType.equals(String.class); Object value; if(isString) { value = converRuleValue(dataRule.getRuleValue()); }else { value = NumberUtils.parseNumber(dataRule.getRuleValue(),propType); } String filedSql = getSingleSqlByRule(rule, oConvertUtils.camelToUnderline(name), value,isString); sb.append(sql_and+filedSql); } } log.info("query auth sql is:"+sb.toString()); return sb.toString(); }
Example #14
Source File: JeecgDataAutorUtils.java From teaching with Apache License 2.0 | 5 votes |
/** * 往链接请求里面,传入数据查询条件 * * @param request * @param dataRules */ public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) { @SuppressWarnings("unchecked") List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST if (list==null) { // 2.如果不存在,则new一个list list = new ArrayList<SysPermissionDataRuleModel>(); } for (SysPermissionDataRuleModel tsDataRule : dataRules) { list.add(tsDataRule); } request.setAttribute(MENU_DATA_AUTHOR_RULES, list); // 3.往list里面增量存指 }
Example #15
Source File: PermissionDataAspect.java From jeecg-cloud with Apache License 2.0 | 5 votes |
private void authDataHandler(HttpServletRequest request, String component) { List<SysPermission> currentSyspermission = null; if(oConvertUtils.isNotEmpty(component)) { //1.通过注解属性pageComponent 获取菜单 currentSyspermission = sysUserRemoteApi.queryComponentPermission(component); }else { String requestMethod = request.getMethod(); String requestPath = request.getRequestURI().substring(request.getContextPath().length()); requestPath = filterUrl(requestPath); log.info("拦截请求 >> "+requestPath+";请求类型 >> "+requestMethod); currentSyspermission = sysUserRemoteApi.queryRequestPermission(requestMethod, requestPath); } //3.通过用户名+菜单ID 找到权限配置信息 放到request中去 if(currentSyspermission!=null && currentSyspermission.size()>0) { String username = JwtUtil.getUserNameByToken(request); List<SysPermissionDataRuleModel> dataRules = new ArrayList<SysPermissionDataRuleModel>(); for (SysPermission sysPermission : currentSyspermission) { // update-begin--Author:scott Date:20191119 for:数据权限规则编码不规范,项目存在相同包名和类名 #722 List<SysPermissionDataRule> temp = sysUserRemoteApi.queryUserDataRule(username, sysPermission.getId()); if(temp!=null && temp.size()>0) { //dataRules.addAll(temp); dataRules = oConvertUtils.entityListToModelList(temp,SysPermissionDataRuleModel.class); } // update-end--Author:scott Date:20191119 for:数据权限规则编码不规范,项目存在相同包名和类名 #722 } if(dataRules!=null && dataRules.size()>0) { JeecgDataAutorUtils.installDataSearchConditon(request, dataRules); SysUserCacheInfo userinfo = sysUserRemoteApi.getCacheUser(username); JeecgDataAutorUtils.installUserInfo(request, userinfo); } } }
Example #16
Source File: JeecgDataAutorUtils.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 往链接请求里面,传入数据查询条件 * * @param request * @param dataRules */ public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) { @SuppressWarnings("unchecked") List<SysPermissionDataRuleModel> list = (List<SysPermissionDataRuleModel>)loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST if (list==null) { // 2.如果不存在,则new一个list list = new ArrayList<SysPermissionDataRuleModel>(); } for (SysPermissionDataRuleModel tsDataRule : dataRules) { list.add(tsDataRule); } request.setAttribute(MENU_DATA_AUTHOR_RULES, list); // 3.往list里面增量存指 }
Example #17
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 获取所有配置的权限 返回sql字符串 不受字段限制 配置什么就拿到什么 * @return */ public static String getAllConfigAuth() { StringBuffer sb = new StringBuffer(); //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); String sql_and = " and "; for (String c : ruleMap.keySet()) { SysPermissionDataRuleModel dataRule = ruleMap.get(c); String ruleValue = dataRule.getRuleValue(); if(oConvertUtils.isEmpty(ruleValue)){ continue; } if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ sb.append(sql_and+getSqlRuleValue(ruleValue)); }else{ boolean isString = false; ruleValue = ruleValue.trim(); if(ruleValue.startsWith("'") && ruleValue.endsWith("'")){ isString = true; ruleValue = ruleValue.substring(1,ruleValue.length()-1); } QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); String value = converRuleValue(ruleValue); String filedSql = getSingleSqlByRule(rule, c, value,isString); sb.append(sql_and+filedSql); } } log.info("query auth sql is = "+sb.toString()); return sb.toString(); }
Example #18
Source File: QueryGenerator.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 根据权限相关配置生成相关的SQL 语句 * @param clazz * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static String installAuthJdbc(Class<?> clazz) { StringBuffer sb = new StringBuffer(); //权限查询 Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(clazz); String sql_and = " and "; for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ sb.append(sql_and+getSqlRuleValue(ruleMap.get(c).getRuleValue())); } } String name; for (int i = 0; i < origDescriptors.length; i++) { name = origDescriptors[i].getName(); if (judgedIsUselessField(name)) { continue; } if(ruleMap.containsKey(name)) { SysPermissionDataRuleModel dataRule = ruleMap.get(name); QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions()); Class propType = origDescriptors[i].getPropertyType(); boolean isString = propType.equals(String.class); Object value; if(isString) { value = converRuleValue(dataRule.getRuleValue()); }else { value = NumberUtils.parseNumber(dataRule.getRuleValue(),propType); } String filedSql = getSingleSqlByRule(rule, oConvertUtils.camelToUnderline(name), value,isString); sb.append(sql_and+filedSql); } } log.info("query auth sql is:"+sb.toString()); return sb.toString(); }
Example #19
Source File: JeecgDataAutorUtils.java From teaching with Apache License 2.0 | 4 votes |
/** * 获取请求对应的数据权限规则 * * @return */ @SuppressWarnings("unchecked") public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() { return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES); }
Example #20
Source File: QueryGenerator.java From teaching with Apache License 2.0 | 4 votes |
/** * 组装Mybatis Plus 查询条件 * <p>使用此方法 需要有如下几点注意: * <br>1.使用QueryWrapper 而非LambdaQueryWrapper; * <br>2.实例化QueryWrapper时不可将实体传入参数 * <br>错误示例:如QueryWrapper<JeecgDemo> queryWrapper = new QueryWrapper<JeecgDemo>(jeecgDemo); * <br>正确示例:QueryWrapper<JeecgDemo> queryWrapper = new QueryWrapper<JeecgDemo>(); * <br>3.也可以不使用这个方法直接调用 {@link #initQueryWrapper}直接获取实例 */ public static void installMplus(QueryWrapper<?> queryWrapper,Object searchObj,Map<String, String[]> parameterMap) { /* * 注意:权限查询由前端配置数据规则 当一个人有多个所属部门时候 可以在规则配置包含条件 orgCode 包含 #{sys_org_code} 但是不支持在自定义SQL中写orgCode in #{sys_org_code} 当一个人只有一个部门 就直接配置等于条件: orgCode 等于 #{sys_org_code} 或者配置自定义SQL: orgCode = '#{sys_org_code}' */ //区间条件组装 模糊查询 高级查询组装 简单排序 权限查询 PropertyDescriptor origDescriptors[] = PropertyUtils.getPropertyDescriptors(searchObj); Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap(); //权限规则自定义SQL表达式 for (String c : ruleMap.keySet()) { if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){ queryWrapper.and(i ->i.apply(getSqlRuleValue(ruleMap.get(c).getRuleValue()))); } } String name, type; for (int i = 0; i < origDescriptors.length; i++) { //aliasName = origDescriptors[i].getName(); mybatis 不存在实体属性 不用处理别名的情况 name = origDescriptors[i].getName(); type = origDescriptors[i].getPropertyType().toString(); try { if (judgedIsUselessField(name)|| !PropertyUtils.isReadable(searchObj, name)) { continue; } //数据权限查询 if(ruleMap.containsKey(name)) { addRuleToQueryWrapper(ruleMap.get(name), name, origDescriptors[i].getPropertyType(), queryWrapper); } // 添加 判断是否有区间值 String endValue = null,beginValue = null; if (parameterMap != null && parameterMap.containsKey(name + BEGIN)) { beginValue = parameterMap.get(name + BEGIN)[0].trim(); addQueryByRule(queryWrapper, name, type, beginValue, QueryRuleEnum.GE); } if (parameterMap != null && parameterMap.containsKey(name + END)) { endValue = parameterMap.get(name + END)[0].trim(); addQueryByRule(queryWrapper, name, type, endValue, QueryRuleEnum.LE); } //判断单值 参数带不同标识字符串 走不同的查询 //TODO 这种前后带逗号的支持分割后模糊查询需要否 使多选字段的查询生效 Object value = PropertyUtils.getSimpleProperty(searchObj, name); if (null != value && value.toString().startsWith(COMMA) && value.toString().endsWith(COMMA)) { String multiLikeval = value.toString().replace(",,", COMMA); String[] vals = multiLikeval.substring(1, multiLikeval.length()).split(COMMA); final String field = oConvertUtils.camelToUnderline(name); if(vals.length>1) { queryWrapper.and(j -> { j = j.like(field,vals[0]); for (int k=1;k<vals.length;k++) { j = j.or().like(field,vals[k]); } return j; }); }else { queryWrapper.and(j -> j.like(field,vals[0])); } }else { //根据参数值带什么关键字符串判断走什么类型的查询 QueryRuleEnum rule = convert2Rule(value); value = replaceValue(rule,value); // add -begin 添加判断为字符串时设为全模糊查询 //if( (rule==null || QueryRuleEnum.EQ.equals(rule)) && "class java.lang.String".equals(type)) { // 可以设置左右模糊或全模糊,因人而异 //rule = QueryRuleEnum.LIKE; //} // add -end 添加判断为字符串时设为全模糊查询 addEasyQuery(queryWrapper, name, rule, value); } } catch (Exception e) { log.error(e.getMessage(), e); } } // 排序逻辑 处理 doMultiFieldsOrder(queryWrapper, parameterMap); //高级查询 doSuperQuery(queryWrapper, parameterMap); }
Example #21
Source File: JeecgDataAutorUtils.java From jeecg-cloud with Apache License 2.0 | 4 votes |
/** * 获取请求对应的数据权限规则 * * @return */ @SuppressWarnings("unchecked") public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() { return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES); }
Example #22
Source File: JeecgDataAutorUtils.java From jeecg-boot with Apache License 2.0 | 4 votes |
/** * 获取请求对应的数据权限规则 * * @return */ @SuppressWarnings("unchecked") public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() { return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES); }