|
@@ -5,6 +5,7 @@ import com.abi.task.common.utils.IStringUtil;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
+import org.checkerframework.checker.units.qual.K;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
@@ -14,81 +15,78 @@ import java.lang.reflect.Field;
|
|
|
*/
|
|
|
@Data
|
|
|
@Slf4j
|
|
|
-public class TableStoreReq {
|
|
|
+public class TableStoreReq<T extends TableStoreEntity> {
|
|
|
|
|
|
/**
|
|
|
* 表名
|
|
|
*/
|
|
|
- String tableName;
|
|
|
+ private String tableName;
|
|
|
|
|
|
/**
|
|
|
* 索引名
|
|
|
*/
|
|
|
- String indexName;
|
|
|
+ private String indexName;
|
|
|
|
|
|
/**
|
|
|
* 匹配的字段名
|
|
|
*/
|
|
|
- String fieldName;
|
|
|
+ private String fieldName;
|
|
|
|
|
|
/**
|
|
|
* 匹配的字段值
|
|
|
*/
|
|
|
- Object fieldValue;
|
|
|
+ private Object fieldValue;
|
|
|
|
|
|
/**
|
|
|
* 大于xxx
|
|
|
*/
|
|
|
- Object greaterThan;
|
|
|
+ private Object greaterThan;
|
|
|
|
|
|
/**
|
|
|
* 小于xxx
|
|
|
*/
|
|
|
- Object lessThan;
|
|
|
+ private Object lessThan;
|
|
|
|
|
|
/**
|
|
|
* 每页条数
|
|
|
*/
|
|
|
- Integer pageCount = 10;
|
|
|
+ private Integer pageCount = 10;
|
|
|
|
|
|
/**
|
|
|
* 第几页
|
|
|
*/
|
|
|
- Integer pageNo = 1;
|
|
|
+ private Integer pageNo = 1;
|
|
|
|
|
|
/**
|
|
|
* 需要返回总数量
|
|
|
*/
|
|
|
- Boolean getTotalCount = false;
|
|
|
+ private Boolean getTotalCount = false;
|
|
|
|
|
|
/**
|
|
|
* 是否逆序
|
|
|
*/
|
|
|
- Boolean sortByFieldDesc = false;
|
|
|
+ private Boolean sortByFieldDesc = false;
|
|
|
|
|
|
/**
|
|
|
* 印射对象类
|
|
|
*/
|
|
|
- Class clz;
|
|
|
+ private Class clz;
|
|
|
|
|
|
/**
|
|
|
- * 无参构造函数
|
|
|
+ * 静态创建函数
|
|
|
*/
|
|
|
- public TableStoreReq(){}
|
|
|
+ public static <T extends TableStoreEntity> TableStoreReq<T> build(Class<T> clzParam, String fieldName){
|
|
|
+ TableStoreReq<T> req = new TableStoreReq<T>();
|
|
|
|
|
|
- /**
|
|
|
- * 构造函数
|
|
|
- */
|
|
|
- public <T extends TableStoreEntity> TableStoreReq(Class<T> clz, String fieldName){
|
|
|
Field field = null;
|
|
|
try{
|
|
|
- field = clz.getDeclaredField(fieldName);
|
|
|
+ field = clzParam.getDeclaredField(fieldName);
|
|
|
}catch (Exception e){
|
|
|
log.info("找不到字段",e);
|
|
|
}
|
|
|
|
|
|
//表名
|
|
|
- TableStore tableStore = clz.getAnnotation(TableStore.class);
|
|
|
+ TableStore tableStore = clzParam.getAnnotation(TableStore.class);
|
|
|
String tableName = tableStore.tableName();
|
|
|
//索引
|
|
|
TableStoreIndex tableStoreIndex = field.getAnnotation(TableStoreIndex.class);
|
|
@@ -96,10 +94,12 @@ public class TableStoreReq {
|
|
|
//字段名转下划线
|
|
|
fieldName = IStringUtil.camelToUnderline(fieldName);
|
|
|
|
|
|
- this.tableName = tableName;
|
|
|
- this.indexName = indexName;
|
|
|
- this.fieldName = fieldName;
|
|
|
- this.clz = clz;
|
|
|
+ req.tableName = tableName;
|
|
|
+ req.indexName = indexName;
|
|
|
+ req.fieldName = fieldName;
|
|
|
+ req.clz = clzParam;
|
|
|
+
|
|
|
+ return req;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -108,10 +108,12 @@ public class TableStoreReq {
|
|
|
* @param indexName 索引名
|
|
|
* @param fieldName 匹配的字段名
|
|
|
*/
|
|
|
- public TableStoreReq(String tableName,String indexName,String fieldName){
|
|
|
- this.tableName = tableName;
|
|
|
- this.indexName = indexName;
|
|
|
- this.fieldName = fieldName;
|
|
|
+ public static <T extends TableStoreEntity> TableStoreReq<T> build(String tableName,String indexName,String fieldName){
|
|
|
+ TableStoreReq<T> req = new TableStoreReq<T>();
|
|
|
+ req.tableName = tableName;
|
|
|
+ req.indexName = indexName;
|
|
|
+ req.fieldName = fieldName;
|
|
|
+ return req;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -120,7 +122,7 @@ public class TableStoreReq {
|
|
|
* @param lessThan
|
|
|
* @return
|
|
|
*/
|
|
|
- public TableStoreReq range(Object greaterThan,Object lessThan){
|
|
|
+ public TableStoreReq<T> range(Object greaterThan,Object lessThan){
|
|
|
this.setGreaterThan(greaterThan);
|
|
|
this.setLessThan(lessThan);
|
|
|
return this;
|
|
@@ -131,12 +133,12 @@ public class TableStoreReq {
|
|
|
* @param fieldValue
|
|
|
* @return
|
|
|
*/
|
|
|
- public TableStoreReq equal(Object fieldValue){
|
|
|
+ public TableStoreReq<T> equal(Object fieldValue){
|
|
|
this.setFieldValue(fieldValue);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public TableStoreReq page(Integer pageNo,Integer pageCount){
|
|
|
+ public TableStoreReq<T> page(Integer pageNo,Integer pageCount){
|
|
|
this.pageNo = pageNo;
|
|
|
this.pageCount = pageCount;
|
|
|
return this;
|
|
@@ -146,7 +148,7 @@ public class TableStoreReq {
|
|
|
* 是否逆序
|
|
|
* @return
|
|
|
*/
|
|
|
- public TableStoreReq isDesc(){
|
|
|
+ public TableStoreReq<T> isDesc(){
|
|
|
this.setSortByFieldDesc(true);
|
|
|
return this;
|
|
|
}
|
|
@@ -155,7 +157,7 @@ public class TableStoreReq {
|
|
|
* 是否需要总数
|
|
|
* @return
|
|
|
*/
|
|
|
- public TableStoreReq isNeedTotalCount(){
|
|
|
+ public TableStoreReq<T> isNeedTotalCount(){
|
|
|
this.setGetTotalCount(true);
|
|
|
return this;
|
|
|
}
|