/** * Check condition node property exist. * * @author wangyi8 * @taskId * @param node the node * @param clz the clz * @param errMsg the err msg */ private void checkConditionNodePropertyExist(ConditionNode node, Class clz, String errMsg) { if (StringUtil.containBrace(node.getValue())) { if (clz == null || ArrayUtil.contains(Config.IGNORE_PARAMETER_TYPES, clz)) { return; } else { List<String> propertyNames = StringUtil.extractBrace(node.getValue()); for (String propertyName : propertyNames) { if (node.getConditionType().equals("in") && (propertyName.equals("item") || propertyName.startsWith("item."))) { // foreach 条件在foreach标签中判断,这里不判断 return; } try { ReflectHelper.haveGetMethod(propertyName, clz); } catch (MapperException e) { e.setDescription( errMsg + String.format(MessageConstant.EXPRESS_MSG, node.toString()) + SymbolConstant.SYMBOL_BLANK + e.getDescription()); e.printException(); } } } } }
/** * 忽略的属性验证 * * @author wangyi8 * @taskId * @param conditionNode 条件 * @param propertyModel 属性 */ private boolean ignoreProperty(ConditionNode conditionNode, PropertyModel propertyModel) { conditionNode.rebuild(); // in条件查询中,出现单独的#{item}不进行验证 if (conditionNode.getConditionType().equals(SqlConstant.IN) && propertyModel.getPropertyName().equals(MyBatisTagConstant.ITEM)) { return true; } return false; }