public class AutoSqlInjector extends Object implements ISqlInjector
SQL 自动注入器
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.apache.ibatis.builder.MapperBuilderAssistant |
builderAssistant |
protected org.apache.ibatis.session.Configuration |
configuration |
protected org.apache.ibatis.scripting.LanguageDriver |
languageDriver |
| 构造器和说明 |
|---|
AutoSqlInjector() |
| 限定符和类型 | 方法和说明 |
|---|---|
org.apache.ibatis.mapping.MappedStatement |
addDeleteMappedStatement(Class<?> mapperClass,
String id,
org.apache.ibatis.mapping.SqlSource sqlSource) |
org.apache.ibatis.mapping.MappedStatement |
addInsertMappedStatement(Class<?> mapperClass,
Class<?> modelClass,
String id,
org.apache.ibatis.mapping.SqlSource sqlSource,
org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator,
String keyProperty,
String keyColumn) |
org.apache.ibatis.mapping.MappedStatement |
addMappedStatement(Class<?> mapperClass,
String id,
org.apache.ibatis.mapping.SqlSource sqlSource,
org.apache.ibatis.mapping.SqlCommandType sqlCommandType,
Class<?> parameterClass,
String resultMap,
Class<?> resultType,
org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator,
String keyProperty,
String keyColumn) |
org.apache.ibatis.mapping.MappedStatement |
addSelectMappedStatement(Class<?> mapperClass,
String id,
org.apache.ibatis.mapping.SqlSource sqlSource,
Class<?> resultType,
TableInfo table) |
org.apache.ibatis.mapping.MappedStatement |
addUpdateMappedStatement(Class<?> mapperClass,
Class<?> modelClass,
String id,
org.apache.ibatis.mapping.SqlSource sqlSource) |
protected String |
convertIfTag(boolean ignored,
TableFieldInfo fieldInfo,
String prefix,
boolean close)
IF 条件转换方法
|
protected String |
convertIfTag(TableFieldInfo fieldInfo,
boolean close) |
protected String |
convertIfTag(TableFieldInfo fieldInfo,
String prefix,
boolean close) |
protected String |
convertIfTagIgnored(TableFieldInfo fieldInfo,
boolean close) |
protected Class<?> |
extractModelClass(Class<?> mapperClass)
避免扫描到BaseMapper
|
protected GlobalConfiguration |
getGlobalConfig()
全局配置
|
void |
inject(org.apache.ibatis.session.Configuration configuration,
org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
自定义方法,注入点(子类需重写该方法)
|
void |
inject(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass)
注入单点 crudSql
|
protected void |
injectDeleteByIdSql(boolean batch,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入删除 SQL 语句
|
protected void |
injectDeleteByMapSql(Class<?> mapperClass,
TableInfo table)
注入 map 条件删除 SQL 语句
|
protected void |
injectDeleteSql(Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入 entity 条件删除 SQL 语句
|
protected void |
injectInsertOneSql(boolean selective,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入插入 SQL 语句
|
protected void |
injectSelectByIdSql(boolean batch,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入查询 SQL 语句
|
protected void |
injectSelectByMapSql(Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入 map 查询 SQL 语句
|
protected void |
injectSelectCountSql(Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入EntityWrapper查询总记录数 SQL 语句
|
protected void |
injectSelectListSql(SqlMethod sqlMethod,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
|
protected void |
injectSelectMapsSql(SqlMethod sqlMethod,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
|
protected void |
injectSelectObjsSql(SqlMethod sqlMethod,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
|
protected void |
injectSelectOneSql(Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入实体查询一条记录 SQL 语句
|
protected void |
injectSql(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入SQL
|
void |
injectSqlRunner(org.apache.ibatis.session.Configuration configuration)
注入SqlRunner相关
|
protected void |
injectUpdateByIdSql(boolean selective,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入更新 SQL 语句
|
protected void |
injectUpdateSql(Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入批量更新 SQL 语句
|
void |
inspectInject(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass)
CRUD注入后给予标识 注入过后不再注入
|
protected String |
sqlSelectColumns(TableInfo table,
boolean entityWrapper)
SQL 查询所有表字段
|
protected String |
sqlSelectObjsColumns(TableInfo table)
SQL 设置selectObj sqlselect
|
protected String |
sqlSet(boolean selective,
TableInfo table,
String prefix)
SQL 更新 set 语句
|
protected String |
sqlWhere(TableInfo table)
SQL 查询条件
|
protected String |
sqlWhereByMap(TableInfo table)
SQL map 查询条件
|
protected String |
sqlWhereEntityWrapper(TableInfo table)
EntityWrapper方式获取select where
|
protected String |
sqlWordConvert(String convertStr)
获取需要转义的SQL字段
|
protected org.apache.ibatis.session.Configuration configuration
protected org.apache.ibatis.scripting.LanguageDriver languageDriver
protected org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant
public void inspectInject(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass)
inspectInject 在接口中 ISqlInjectorbuilderAssistant - mapperClass - public void inject(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass)
inject 在接口中 ISqlInjectorprotected void injectSql(org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入SQL
builderAssistant - mapperClass - modelClass - table - public void inject(org.apache.ibatis.session.Configuration configuration,
org.apache.ibatis.builder.MapperBuilderAssistant builderAssistant,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
protected Class<?> extractModelClass(Class<?> mapperClass)
mapperClass - protected void injectInsertOneSql(boolean selective,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入插入 SQL 语句
selective - 是否选择插入mapperClass - modelClass - table - protected void injectDeleteSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入 entity 条件删除 SQL 语句
mapperClass - modelClass - table - protected void injectDeleteByMapSql(Class<?> mapperClass, TableInfo table)
注入 map 条件删除 SQL 语句
mapperClass - table - protected void injectDeleteByIdSql(boolean batch,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入删除 SQL 语句
mapperClass - modelClass - table - protected void injectUpdateByIdSql(boolean selective,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入更新 SQL 语句
mapperClass - modelClass - table - protected void injectUpdateSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入批量更新 SQL 语句
mapperClass - modelClass - table - protected void injectSelectByIdSql(boolean batch,
Class<?> mapperClass,
Class<?> modelClass,
TableInfo table)
注入查询 SQL 语句
batch - 是否为批量插入mapperClass - modelClass - table - protected void injectSelectByMapSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入 map 查询 SQL 语句
mapperClass - modelClass - table - protected void injectSelectOneSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入实体查询一条记录 SQL 语句
mapperClass - modelClass - table - protected void injectSelectListSql(SqlMethod sqlMethod, Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
sqlMethod - mapperClass - modelClass - table - protected void injectSelectMapsSql(SqlMethod sqlMethod, Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
sqlMethod - mapperClass - modelClass - table - protected void injectSelectObjsSql(SqlMethod sqlMethod, Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入EntityWrapper方式查询记录列表 SQL 语句
sqlMethod - mapperClass - modelClass - table - protected void injectSelectCountSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table)
注入EntityWrapper查询总记录数 SQL 语句
mapperClass - modelClass - table - 表信息protected String sqlWhereEntityWrapper(TableInfo table)
EntityWrapper方式获取select where
table - 表信息protected String sqlSet(boolean selective, TableInfo table, String prefix)
SQL 更新 set 语句
selective - 是否选择判断table - 表信息prefix - 前缀protected String sqlSelectColumns(TableInfo table, boolean entityWrapper)
SQL 查询所有表字段
table - entityWrapper - 是否为包装类型查询protected String sqlSelectObjsColumns(TableInfo table)
SQL 设置selectObj sqlselect
table - 是否为包装类型查询protected String convertIfTag(boolean ignored, TableFieldInfo fieldInfo, String prefix, boolean close)
IF 条件转换方法
ignored - 允许忽略fieldInfo - 字段信息prefix - 条件前缀close - 是否闭合标签protected String convertIfTagIgnored(TableFieldInfo fieldInfo, boolean close)
protected String convertIfTag(TableFieldInfo fieldInfo, String prefix, boolean close)
protected String convertIfTag(TableFieldInfo fieldInfo, boolean close)
public org.apache.ibatis.mapping.MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, org.apache.ibatis.mapping.SqlSource sqlSource, Class<?> resultType, TableInfo table)
public org.apache.ibatis.mapping.MappedStatement addInsertMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, org.apache.ibatis.mapping.SqlSource sqlSource, org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator, String keyProperty, String keyColumn)
public org.apache.ibatis.mapping.MappedStatement addDeleteMappedStatement(Class<?> mapperClass, String id, org.apache.ibatis.mapping.SqlSource sqlSource)
public org.apache.ibatis.mapping.MappedStatement addUpdateMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, org.apache.ibatis.mapping.SqlSource sqlSource)
public org.apache.ibatis.mapping.MappedStatement addMappedStatement(Class<?> mapperClass, String id, org.apache.ibatis.mapping.SqlSource sqlSource, org.apache.ibatis.mapping.SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType, org.apache.ibatis.executor.keygen.KeyGenerator keyGenerator, String keyProperty, String keyColumn)
public void injectSqlRunner(org.apache.ibatis.session.Configuration configuration)
ISqlInjectorinjectSqlRunner 在接口中 ISqlInjectorSqlRunnerprotected GlobalConfiguration getGlobalConfig()
全局配置
Copyright © 2017. All rights reserved.