ExampleEnhancedPlugin:增加基于Column的操作以及对应测试用例
This commit is contained in:
@@ -226,7 +226,8 @@ public class Test {
|
||||
* Criteria的快速返回example()方法。
|
||||
* Criteria链式调用增强,以前如果有按条件增加的查询语句会打乱链式查询构建,现在有了andIf(boolean ifAdd, CriteriaAdd add)方法可一直使用链式调用下去。
|
||||
* Example增强了setOrderByClause方法,新增orderBy(String orderByClause)方法直接返回example,增强链式调用,可以一路.下去了。
|
||||
* 继续增强orderBy(String orderByClause)方法,增加orderBy(String ... orderByClauses)方法,配合数据Model属性对应Column获取插件(ModelColumnPlugin)使用效果更佳。
|
||||
* 继续增强orderBy(String orderByClause)方法,增加orderBy(String ... orderByClauses)方法,配合数据Model属性对应Column获取插件(ModelColumnPlugin)使用效果更佳。
|
||||
* 增加基于column的操作,当配置了[数据Model属性对应Column获取插件(ModelColumnPlugin)](#8-数据model属性对应column获取插件)插件时,提供column之间的比对操作。
|
||||
插件:
|
||||
```xml
|
||||
<!-- Example Criteria 增强插件 -->
|
||||
@@ -300,6 +301,19 @@ public class Test {
|
||||
// 这个配合数据Model属性对应Column获取插件(ModelColumnPlugin)使用
|
||||
.orderBy(Tb.Column.field1.asc(), Tb.Column.field3.desc())
|
||||
);
|
||||
|
||||
// -----------------------------------column-----------------------------------
|
||||
this.tbMapper.selectByExample(
|
||||
new TbExample()
|
||||
.createCriteria()
|
||||
.andField1EqualToColumn(Tb.Column.field2) // where field1 = field2
|
||||
.andField1NotEqualToColumn(Tb.Column.field2) // where field1 <> field2
|
||||
.andField1GreaterThanColumn(Tb.Column.field2) // where field1 > field2
|
||||
.andField1GreaterThanOrEqualToColumn(Tb.Column.field2) // where field1 >= field2
|
||||
.andField1LessThanColumn(Tb.Column.field2) // where field1 < field2
|
||||
.andField1LessThanOrEqualToColumn(Tb.Column.field2) // where field1 <= field2
|
||||
.example()
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -80,10 +80,10 @@ public class ExampleEnhancedPlugin extends BasePlugin {
|
||||
* @param introspectedTable
|
||||
*/
|
||||
private void addColumnMethodToCriteria(TopLevelClass topLevelClass, InnerClass innerClass, IntrospectedTable introspectedTable) {
|
||||
// !!!!! Column import比较特殊引入的是外部类
|
||||
topLevelClass.addImportedType(introspectedTable.getRules().calculateAllFieldsClass());
|
||||
for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
|
||||
topLevelClass.addImportedType(introspectedColumn.getFullyQualifiedJavaType());
|
||||
// !!!!! Column import比较特殊引入的是外部类
|
||||
topLevelClass.addImportedType(introspectedTable.getRules().calculateAllFieldsClass());
|
||||
// EqualTo
|
||||
FormatTools.addMethodWithBestPosition(innerClass, this.generateSingleValueMethod(introspectedTable, introspectedColumn, "EqualTo", "="));
|
||||
// NotEqualTo
|
||||
|
||||
Reference in New Issue
Block a user