Class JsqlparserSqlProcessor49

java.lang.Object
org.jeecgframework.minidao.sqlparser.impl.JsqlparserSqlProcessor49
All Implemented Interfaces:
AbstractSqlProcessor

public class JsqlparserSqlProcessor49 extends Object implements AbstractSqlProcessor
jsqlparser解析SQL
Author:
zhang
  • Field Details

  • Constructor Details

    • JsqlparserSqlProcessor49

      public JsqlparserSqlProcessor49()
  • Method Details

    • getSqlServerPageSql

      public String getSqlServerPageSql(String sql, MiniDaoPage miniDaoPage)
      Description copied from interface: AbstractSqlProcessor
      获取SqlServer分页SQL
      Specified by:
      getSqlServerPageSql in interface AbstractSqlProcessor
      Returns:
    • getCountSql

      public String getCountSql(String sql)
      Description copied from interface: AbstractSqlProcessor
      获取SQL查询记录数SQL
      Specified by:
      getCountSql in interface AbstractSqlProcessor
      Returns:
    • removeOrderBy

      public String removeOrderBy(String sql)
      去除排序SQL片段
      Specified by:
      removeOrderBy in interface AbstractSqlProcessor
      Parameters:
      sql -
      Returns:
    • parseSqlFields

      public List<Map<String,Object>> parseSqlFields(String parsedSql)
      解析SQL查询字段
      Specified by:
      parseSqlFields in interface AbstractSqlProcessor
      Parameters:
      parsedSql - 待解析的 SQL
      Returns:
      解析后的字段列表
    • addOrderBy

      public String addOrderBy(String sql, String field, boolean isAsc)
      在SQL的最外层增加或修改ORDER BY子句
      Specified by:
      addOrderBy in interface AbstractSqlProcessor
      Parameters:
      sql - 原始SQL
      field - 新的ORDER BY字段
      isAsc - 是否正序
      Returns:
    • addWhereCondition

      public String addWhereCondition(String sql, String condition)
      为SQL语句增加查询条件(直接使用条件语句) for [issues/8336]支持SqlServer数据使用sql排序,新方案。
      Specified by:
      addWhereCondition in interface AbstractSqlProcessor
      Parameters:
      sql - 原始SQL
      condition - 查询条件(不含where关键字)
      Returns:
      添加查询条件后的SQL
    • addWhereCondition

      public String addWhereCondition(String sql, String field, Object value, String operator)
      为SQL语句增加查询条件(使用字段、值和操作符) for [issues/8336]支持SqlServer数据使用sql排序,新方案。
      Specified by:
      addWhereCondition in interface AbstractSqlProcessor
      Parameters:
      sql - 原始SQL
      field - 字段名
      value - 字段值
      operator - 比较操作符(如:=, >, <, !=, like等)
      Returns:
      添加查询条件后的SQL
    • parseAllSelectTable

      public Map<String,SelectSqlInfo> parseAllSelectTable(String selectSql) throws net.sf.jsqlparser.JSQLParserException
      Description copied from interface: AbstractSqlProcessor
      解析 查询(select)sql的信息, 此方法会展开所有子查询到一个map里, key只存真实的表名,如果查询的没有真实的表名,则会被忽略。 value只存真实的字段名,如果查询的没有真实的字段名,则会被忽略。

      例如:SELECT a.*,d.age,(SELECT count(1) FROM sys_depart) AS count FROM (SELECT username AS foo, realname FROM sys_user) a, demo d 解析后的结果为:{sys_user=[username, realname], demo=[age], sys_depart=[]}

      Specified by:
      parseAllSelectTable in interface AbstractSqlProcessor
      Parameters:
      selectSql - 待解析的SQL
      Throws:
      net.sf.jsqlparser.JSQLParserException
    • parseSelectSqlInfo

      public SelectSqlInfo parseSelectSqlInfo(String selectSql) throws net.sf.jsqlparser.JSQLParserException
      Description copied from interface: AbstractSqlProcessor
      解析 查询(select)sql的信息,子查询嵌套
      Specified by:
      parseSelectSqlInfo in interface AbstractSqlProcessor
      Parameters:
      selectSql - 待解析的SQL
      Throws:
      net.sf.jsqlparser.JSQLParserException
    • getQueryTableInfo

      public List<QueryTable> getQueryTableInfo(String sql)
      Description copied from interface: AbstractSqlProcessor
      根据 sql语句 获取表和字段信息
      Specified by:
      getQueryTableInfo in interface AbstractSqlProcessor
      Parameters:
      sql - sql语句
    • parseSelectAliasMap

      public Map<String,String> parseSelectAliasMap(String sql)
      Description copied from interface: AbstractSqlProcessor
      解析 SQL 查询,将 SELECT 字段映射到 (alias或列名) -> (完整字段表达式) 的 Map 中。 for [QQYUN-13476]online 报表SqlServer兼容改造完
      Specified by:
      parseSelectAliasMap in interface AbstractSqlProcessor
      Parameters:
      sql - 要解析的 SQL 查询语句
      Returns:
      字段映射:key 为别名(若有)或列名(无表名前缀),value 为对应的完整表达式字符串