Module bus.pager

Class ConditionHandler

java.lang.Object
org.miaixz.bus.mapper.handler.AbstractSqlHandler
org.miaixz.bus.pager.handler.SqlParserHandler
org.miaixz.bus.pager.handler.ConditionHandler
All Implemented Interfaces:
org.miaixz.bus.core.Handler, org.miaixz.bus.mapper.handler.MapperHandler
Direct Known Subclasses:
PermissionsHandler, TenantHandler

public abstract class ConditionHandler extends SqlParserHandler implements org.miaixz.bus.mapper.handler.MapperHandler
条件:多表条件处理基类,提供处理 SELECT、UPDATE、DELETE 语句并根据表元数据追加条件的方法。
Since:
Java 17+
Author:
Kimi Liu
  • Field Summary

    Fields inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler

    DEFAULT_REFLECTOR_FACTORY, DELEGATE_BOUNDSQL, DELEGATE_BOUNDSQL_SQL, DELEGATE_MAPPEDSTATEMENT, MAPPEDSTATEMENT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected net.sf.jsqlparser.expression.Expression
    andExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment)
    处理 DELETE 和 UPDATE 语句的 WHERE 条件。
    protected net.sf.jsqlparser.expression.Expression
    appendExpression(net.sf.jsqlparser.expression.Expression expression, net.sf.jsqlparser.expression.Expression injectExpression)
    追加条件表达式,默认追加到后面,可通过 appendMode 配置追加位置。
    protected net.sf.jsqlparser.expression.Expression
    builderExpression(net.sf.jsqlparser.expression.Expression expression, List<net.sf.jsqlparser.schema.Table> tables, String segment)
    构建并处理条件表达式。
    abstract net.sf.jsqlparser.expression.Expression
    buildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String segment)
    构建数据库表的查询条件。
    protected void
    processFunction(net.sf.jsqlparser.expression.Function function, String whereSegment)
    处理函数,支持 select fun(args..)
    protected void
    processOtherFromItem(net.sf.jsqlparser.statement.select.FromItem fromItem, String whereSegment)
    处理其他 FROM 项(如子查询)。
    protected void
    processPlainSelect(net.sf.jsqlparser.statement.select.PlainSelect plainSelect, String whereSegment)
    处理 PlainSelect 语句,包含 SELECT 项、FROM 项和 JOIN。
    protected void
    processSelectBody(net.sf.jsqlparser.statement.select.Select selectBody, String whereSegment)
    处理 SELECT 语句体,应用指定的条件片段。
    protected void
    processSelectItem(net.sf.jsqlparser.statement.select.SelectItem selectItem, String whereSegment)
    处理 SELECT 项中的子查询或函数。
    protected void
    processWhereSubSelect(net.sf.jsqlparser.expression.Expression where, String whereSegment)
    处理 WHERE 条件中的子查询,支持 IN、=、>、<、>=、<=、<>、EXISTS、NOT EXISTS 前提:子查询需放在括号中,且通常位于比较操作符右侧。

    Methods inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler

    getMappedStatement, getMappedStatement, getMetaObject, getSqlParserInfo, mapperBoundSql, mapperStatementHandler, realTarget, setAdditionalParameter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.miaixz.bus.core.Handler

    after, before, setProperties

    Methods inherited from interface org.miaixz.bus.mapper.handler.MapperHandler

    getBoundSql, isQuery, isUpdate, prepare, query, update
  • Constructor Details

    • ConditionHandler

      public ConditionHandler()
  • Method Details

    • processSelectBody

      protected void processSelectBody(net.sf.jsqlparser.statement.select.Select selectBody, String whereSegment)
      处理 SELECT 语句体,应用指定的条件片段。
      Parameters:
      selectBody - SELECT 语句体
      whereSegment - Mapper 全路径,用于条件应用
    • andExpression

      protected net.sf.jsqlparser.expression.Expression andExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment)
      处理 DELETE 和 UPDATE 语句的 WHERE 条件。
      Parameters:
      table - 表对象
      where - 当前 WHERE 条件
      whereSegment - Mapper 全路径
      Returns:
      追加后的 WHERE 表达式
    • processPlainSelect

      protected void processPlainSelect(net.sf.jsqlparser.statement.select.PlainSelect plainSelect, String whereSegment)
      处理 PlainSelect 语句,包含 SELECT 项、FROM 项和 JOIN。
      Parameters:
      plainSelect - PlainSelect 对象
      whereSegment - Mapper 全路径
    • processWhereSubSelect

      protected void processWhereSubSelect(net.sf.jsqlparser.expression.Expression where, String whereSegment)
      处理 WHERE 条件中的子查询,支持 IN、=、>、<、>=、<=、<>、EXISTS、NOT EXISTS 前提:子查询需放在括号中,且通常位于比较操作符右侧。
      Parameters:
      where - WHERE 条件
      whereSegment - Mapper 全路径
    • processSelectItem

      protected void processSelectItem(net.sf.jsqlparser.statement.select.SelectItem selectItem, String whereSegment)
      处理 SELECT 项中的子查询或函数。
      Parameters:
      selectItem - SELECT 项
      whereSegment - Mapper 全路径
    • processFunction

      protected void processFunction(net.sf.jsqlparser.expression.Function function, String whereSegment)
      处理函数,支持 select fun(args..) 和嵌套函数 select fun1(fun2(args..),args..)。
      Parameters:
      function - 函数表达式
      whereSegment - Mapper 全路径
    • processOtherFromItem

      protected void processOtherFromItem(net.sf.jsqlparser.statement.select.FromItem fromItem, String whereSegment)
      处理其他 FROM 项(如子查询)。
      Parameters:
      fromItem - FROM 子句中的项
      whereSegment - Mapper 全路径
    • builderExpression

      protected net.sf.jsqlparser.expression.Expression builderExpression(net.sf.jsqlparser.expression.Expression expression, List<net.sf.jsqlparser.schema.Table> tables, String segment)
      构建并处理条件表达式。
      Parameters:
      expression - 当前条件表达式
      tables - 表列表
      segment - Mapper 全路径
      Returns:
      构建后的条件表达式
    • appendExpression

      protected net.sf.jsqlparser.expression.Expression appendExpression(net.sf.jsqlparser.expression.Expression expression, net.sf.jsqlparser.expression.Expression injectExpression)
      追加条件表达式,默认追加到后面,可通过 appendMode 配置追加位置。
      Parameters:
      expression - 原 SQL 条件表达式
      injectExpression - 注入的条件表达式
      Returns:
      追加后的完整表达式(WHERE 或 ON 条件)
    • buildTableExpression

      public abstract net.sf.jsqlparser.expression.Expression buildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String segment)
      构建数据库表的查询条件。
      Parameters:
      table - 表对象
      where - 当前 WHERE 条件
      segment - Mapper 全路径
      Returns:
      新增的查询条件(不会覆盖原有 WHERE 条件,仅追加),为 null 则不加入新条件