goja-core/src/main/java/goja/core/db/Dao.java
public static Pair<String, List<Object>> dynamicSql(String sqlId, Map<String, Object> param) {
        String sqlTemplete = SqlKit.sql(sqlId);

        if (null == sqlTemplete || sqlTemplete.isEmpty()) {
            logger.error("sql语句不存在：sql id是" + sqlId);
            return null;
        }

        if (param == null) {
            param = Maps.newHashMap();
        }

        String sql = Freemarkers.render(sqlTemplete, param);

        List<Object> params = Lists.newArrayList();

        Set<String> keySet = param.keySet();
        for (String key : keySet) {
            if (param.get(key) == null) {
                break;
            }

            Object paramValue = param.get(key);

            final String placeChar = StringPool.HASH + key + StringPool.HASH;
            if (StringUtils.containsIgnoreCase(sql, placeChar)) {
                sql = StringUtils.replace(sql, placeChar, StringPool.QUESTION_MARK);
                params.add(paramValue);
            }
        }
        return Pair.of(sql.replaceAll("[\\s]{2,}", " "), params);
    }
public static Pair<String, List<Object>> dynamicSql(String sqlId, Map<String, Object> param) {
        String sqlTemplete = SqlKit.sql(sqlId);

        if (null == sqlTemplete || sqlTemplete.isEmpty()) {
            logger.error("sql语句不存在：sql id是" + sqlId);
            return null;
        }

        if (param == null) {
            param = Maps.newHashMap();
        }

        String sql = Freemarkers.render(sqlTemplete, param);

        List<Object> params = Lists.newArrayList();

        Set<String> keySet = param.keySet();
        for (String key : keySet) {
            if (param.get(key) == null) {
                break;
            }

            Object paramValue = param.get(key);

            final String placeChar = StringPool.HASH + key + StringPool.HASH;
            if (StringUtils.containsIgnoreCase(sql, placeChar)) {
                sql = StringUtils.replace(sql, placeChar, StringPool.QUESTION_MARK);
                params.add(paramValue);
            }
        }
        return Pair.of(sql.replaceAll("[\\s]{2,}", " "), params);
    }
获取SQL，动态SQL

@param sqlId xml文件中的sql id
@param param xml sql中的变量map
@return 返回处理对象, key为 sql, value为参数