java.lang.Object
org.miaixz.bus.mapper.handler.AbstractSqlHandler
org.miaixz.bus.pager.handler.SqlParserHandler
org.miaixz.bus.pager.handler.ConditionHandler
org.miaixz.bus.pager.handler.PermissionHandler
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Handler,org.miaixz.bus.mapper.handler.MapperHandler
public class PermissionHandler
extends ConditionHandler
implements org.miaixz.bus.mapper.handler.MapperHandler
Data permission handler for processing data permission controls in SQL statements. This handler dynamically adds
permission conditions to SQL queries.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
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 -
Method Summary
Modifier and TypeMethodDescriptionnet.sf.jsqlparser.expression.ExpressionbuildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Builds a table-level permission expression.Retrieves the data permission provider.protected net.sf.jsqlparser.expression.ExpressiongetUpdateOrDeleteExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Retrieves the permission expression for an UPDATE or DELETE statement.voidprepare(org.apache.ibatis.executor.statement.StatementHandler statementHandler) Pre-processes SQL statements, dynamically adding permission conditions to UPDATE and DELETE statements.protected voidprocessDelete(net.sf.jsqlparser.statement.delete.Delete delete, int index, String sql, Object obj) Processes a DELETE statement, adding permission conditions.protected voidprocessSelect(net.sf.jsqlparser.statement.select.Select select, int index, String sql, Object obj) Processes a SELECT statement, adding permission conditions.protected voidprocessUpdate(net.sf.jsqlparser.statement.update.Update update, int index, String sql, Object obj) Processes an UPDATE statement, adding permission conditions.voidquery(Object result, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Handles query processing, dynamically adding permission conditions to SELECT statements.voidsetProvider(PermissionProvider provider) Sets the data permission provider.Methods inherited from class org.miaixz.bus.pager.handler.ConditionHandler
andExpression, appendExpression, builderExpression, processFunction, processOtherFromItem, processPlainSelect, processSelectBody, processSelectItem, processWhereSubSelectMethods inherited from class org.miaixz.bus.pager.handler.SqlParserHandler
parse, parserMulti, parserSingle, parseStatements, processInsert, processParser, validateSqlMethods inherited from class org.miaixz.bus.mapper.handler.AbstractSqlHandler
getMappedStatement, getMappedStatement, getMetaObject, getSqlParserInfo, mapperBoundSql, mapperStatementHandler, realTarget, setAdditionalParameterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.core.Handler
after, before, setPropertiesMethods inherited from interface org.miaixz.bus.mapper.handler.MapperHandler
getBoundSql, isQuery, isUpdate, update
-
Constructor Details
-
PermissionHandler
public PermissionHandler()
-
-
Method Details
-
prepare
public void prepare(org.apache.ibatis.executor.statement.StatementHandler statementHandler) Pre-processes SQL statements, dynamically adding permission conditions to UPDATE and DELETE statements.- Specified by:
preparein interfaceorg.miaixz.bus.mapper.handler.MapperHandler- Parameters:
statementHandler- the MyBatis StatementHandler
-
query
public void query(Object result, org.apache.ibatis.executor.Executor executor, org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameter, org.apache.ibatis.session.RowBounds rowBounds, org.apache.ibatis.session.ResultHandler resultHandler, org.apache.ibatis.mapping.BoundSql boundSql) Handles query processing, dynamically adding permission conditions to SELECT statements.- Specified by:
queryin interfaceorg.miaixz.bus.mapper.handler.MapperHandler- Parameters:
result- the query resultexecutor- the MyBatis executormappedStatement- the MappedStatementparameter- the query parametersrowBounds- the pagination parametersresultHandler- the result handlerboundSql- the bound SQL
-
processUpdate
protected void processUpdate(net.sf.jsqlparser.statement.update.Update update, int index, String sql, Object obj) Processes an UPDATE statement, adding permission conditions.- Overrides:
processUpdatein classSqlParserHandler- Parameters:
update- the UPDATE statement objectindex- the SQL indexsql- the original SQLobj- additional parameters (usually the mapping ID)
-
processDelete
protected void processDelete(net.sf.jsqlparser.statement.delete.Delete delete, int index, String sql, Object obj) Processes a DELETE statement, adding permission conditions.- Overrides:
processDeletein classSqlParserHandler- Parameters:
delete- the DELETE statement objectindex- the SQL indexsql- the original SQLobj- additional parameters (usually the mapping ID)
-
processSelect
protected void processSelect(net.sf.jsqlparser.statement.select.Select select, int index, String sql, Object obj) Processes a SELECT statement, adding permission conditions.- Overrides:
processSelectin classSqlParserHandler- Parameters:
select- the SELECT statement objectindex- the SQL indexsql- the original SQLobj- additional parameters (usually the mapping ID)
-
buildTableExpression
public net.sf.jsqlparser.expression.Expression buildTableExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Builds a table-level permission expression.- Specified by:
buildTableExpressionin classConditionHandler- Parameters:
table- the table objectwhere- the original WHERE conditionwhereSegment- the permission condition segment- Returns:
- the combined permission expression
-
getProvider
Retrieves the data permission provider.- Returns:
- the data permission provider
-
setProvider
Sets the data permission provider.- Parameters:
provider- the data permission provider
-
getUpdateOrDeleteExpression
protected net.sf.jsqlparser.expression.Expression getUpdateOrDeleteExpression(net.sf.jsqlparser.schema.Table table, net.sf.jsqlparser.expression.Expression where, String whereSegment) Retrieves the permission expression for an UPDATE or DELETE statement.- Parameters:
table- the table objectwhere- the original WHERE conditionwhereSegment- the permission condition segment- Returns:
- the combined permission expression
-