BindQuery支持between绑定List
This commit is contained in:
parent
89e860c704
commit
8066b17c49
|
@ -230,6 +230,15 @@ public class QueryBuilder {
|
|||
wrapper.between(columnName, valueArray[0], valueArray[1]);
|
||||
}
|
||||
}
|
||||
else if(value instanceof List){
|
||||
List valueList = (List)value;
|
||||
if(valueList.size() == 1){
|
||||
wrapper.ge(columnName, valueList.get(0));
|
||||
}
|
||||
else if(valueList.size() >= 2){
|
||||
wrapper.between(columnName, valueList.get(0), valueList.get(1));
|
||||
}
|
||||
}
|
||||
// 支持逗号分隔的字符串
|
||||
else if(value instanceof String && ((String) value).contains(",")){
|
||||
Object[] valueArray = ((String) value).split(",");
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.diboot.core.binding.QueryBuilder;
|
||||
import com.diboot.core.config.BaseConfig;
|
||||
import com.diboot.core.entity.Dictionary;
|
||||
import com.diboot.core.service.impl.DictionaryServiceImpl;
|
||||
|
@ -289,4 +290,26 @@ public class BaseServiceTest {
|
|||
List<Dictionary> ids = dictionaryService.getEntityListLimit(queryWrapper, 5);
|
||||
Assert.assertTrue(ids.size() == 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPagination(){
|
||||
Dictionary dict = new Dictionary();
|
||||
dict.setParentId(1L);
|
||||
dict.setType("GENDER");
|
||||
dict.setEditable(true);
|
||||
|
||||
QueryWrapper<Dictionary> queryWrapper = QueryBuilder.toQueryWrapper(dict);
|
||||
|
||||
// 查询当前页的数据
|
||||
Pagination pagination = new Pagination();
|
||||
pagination.setPageSize(1);
|
||||
|
||||
List<DictionaryVO> voList = dictionaryService.getViewObjectList(queryWrapper, pagination, DictionaryVO.class);
|
||||
Assert.assertTrue(voList.size() == 1);
|
||||
Assert.assertTrue(pagination.getTotalPage() >= 2);
|
||||
|
||||
pagination.setPageIndex(2);
|
||||
voList = dictionaryService.getViewObjectList(queryWrapper, pagination, DictionaryVO.class);
|
||||
Assert.assertTrue(voList.size() == 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue