use of org.sagacity.sqltoy.model.PaginationModel in project sagacity-sqltoy by chenrenfei.
the class SeniorQueryServiceTest method testFindFastPage.
/**
* 快速分页、缓存翻译、分页优化查询演示
*
* @throws Exception
*/
@Test
public void testFindFastPage() throws Exception {
// 先执行一次查询加载缓存,方便真实反映缓存翻译的效果
PaginationModel result0 = seniorQueryService.findStaffInfo(new PaginationModel(), new String[] { "staffName" }, new Object[] { "张" }, StaffInfoVO.class);
DebugUtil.beginTime("start");
PaginationModel result = seniorQueryService.findStaffInfo(new PaginationModel(), new String[] { "staffName" }, new Object[] { "陈" }, StaffInfoVO.class);
DebugUtil.endTime("start");
DebugUtil.beginTime("start1");
PaginationModel result1 = seniorQueryService.findStaffInfo(new PaginationModel(), new String[] { "staffName" }, new Object[] { "陈" }, StaffInfoVO.class);
DebugUtil.endTime("start1");
}
use of org.sagacity.sqltoy.model.PaginationModel in project sagacity-sqltoy by chenrenfei.
the class SeniorQueryServiceTest method testFindPage.
/**
* 分页查询演示
*
* @throws Exception
*/
@Test
public void testFindPage() throws Exception {
sqlToyCRUDService.truncate(StaffInfoVO.class);
List<StaffInfoVO> staffVOs = new ArrayList<StaffInfoVO>();
String[] postType = { "1", "2", "3", "4" };
String[] sexType = { "F", "M", "X" };
String staffNames = "赵钱孙李周吴郑王冯陈楮卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄";
String names = "俞倩倪倰偀偲妆佳亿仪寒宜女奴妶好妃姗姝姹姿婵姑姜姣嫂嫦嫱姬娇娟嫣婕婧娴婉姐姞姯姲姳娘娜妹妍妙妹娆娉娥媚媱嫔婷玟环珆珊珠玲珴瑛琼瑶瑾瑞珍琦玫琪琳环琬瑗琰薇珂芬芳芯花茜荭荷莲莉莹菊芝萍燕苹荣草蕊芮蓝莎菀菁苑芸芊茗荔菲蓉英蓓蕾";
int end = 100;
for (int i = 0; i < end; i++) {
StaffInfoVO staffVO = new StaffInfoVO();
staffVO.setStaffId(Integer.toString(i + 1));
staffVO.setStaffCode("S" + StringUtil.addLeftZero2Len(Integer.toString(i + 1), 4));
int index = CommonUtils.getRandomNum(1, staffNames.length() - 1);
int nameIndex = CommonUtils.getRandomNum(1, names.length() - 1);
staffVO.setStaffName(staffNames.substring(index - 1, index) + names.substring(nameIndex - 1, nameIndex) + i);
staffVO.setBirthday(DateUtil.getNowTime());
staffVO.setOperator("admin");
staffVO.setOperateDate(DateUtil.getNowTime());
staffVO.setOrganId(Integer.toString(CommonUtils.getRandomNum(2, 10)));
staffVO.setPost(postType[CommonUtils.getRandomNum(postType.length)]);
// 按照千人比例取性别(千分之五为不确定性别)
staffVO.setSexType(sexType[CommonUtils.getProbabilityIndex(new int[] { 493, 498, 5 })]);
staffVO.setStatus("1");
staffVOs.add(staffVO);
if (((i + 1) % 100) == 0 || i == end - 1) {
sqlToyCRUDService.saveOrUpdateAll(staffVOs);
staffVOs.clear();
}
}
PaginationModel result = seniorQueryService.findStaffInfo(new PaginationModel(), new String[] { "staffName" }, new Object[] { "张" }, StaffInfoVO.class);
System.err.println(result.getRecordCount());
}
use of org.sagacity.sqltoy.model.PaginationModel in project sagacity-sqltoy by chenrenfei.
the class SeniorQueryServiceTest method testFindSharding.
/**
* 分库分表sharding
*
* @throws Exception
*/
@Test
public void testFindSharding() throws Exception {
List<ShardingRealVO> realVOs = new ArrayList<ShardingRealVO>();
for (int i = 0; i < 100; i++) {
ShardingRealVO realVO = new ShardingRealVO();
realVO.setId(new BigDecimal(i));
realVO.setComments("real" + i);
realVO.setStaffId("S" + CommonUtils.getRandomNum(100));
realVO.setPostType("POST_MASTER");
realVO.setCreateTime(DateUtil.addDay(new Date(), -CommonUtils.getRandomNum(15)));
realVOs.add(realVO);
}
sqlToyCRUDService.saveOrUpdateAll(realVOs);
List<ShardingHisVO> hisVOs = new ArrayList<ShardingHisVO>();
for (int i = 101; i < 500; i++) {
ShardingHisVO hisVO = new ShardingHisVO();
hisVO.setId(new BigDecimal(i));
hisVO.setComments("real" + i);
hisVO.setStaffId("S" + CommonUtils.getRandomNum(100));
hisVO.setPostType("POST_MASTER");
hisVO.setCreateTime(DateUtil.addDay(new Date(), -CommonUtils.getRandomNum(15, 100)));
hisVOs.add(hisVO);
}
sqlToyCRUDService.saveOrUpdateAll(hisVOs);
PaginationModel pageModel = new PaginationModel();
// 14天前,则查询历史表
// Date beginTime = DateUtil.addDay(new Date(), -30);
// Date endTime = DateUtil.addDay(new Date(), -14);
// 14天以内,则查询实时表
Date beginTime = DateUtil.addDay(new Date(), -13);
Date endTime = DateUtil.addDay(new Date(), -1);
PaginationModel results = seniorQueryService.findSharding(pageModel, new String[] { "beginTime", "endTime" }, new Object[] { beginTime, endTime }, ShardingRealVO.class);
for (ShardingRealVO sharding : (List<ShardingRealVO>) results.getRows()) {
System.out.println("staffId=" + sharding.getStaffId() + ",createTime=" + sharding.getCreateTime() + ";comments=" + sharding.getComments());
}
}
use of org.sagacity.sqltoy.model.PaginationModel in project sagacity-sqltoy by chenrenfei.
the class LinkDaoTest method findPage.
@Test
public void findPage() throws Exception {
StaffInfoVO staffInfoVO = new StaffInfoVO();
staffInfoVO.setStaffName("李");
PaginationModel pageModel = staffInfoDao.findPage(new PaginationModel(), staffInfoVO);
System.err.println(pageModel.getRecordCount());
}
use of org.sagacity.sqltoy.model.PaginationModel in project sagacity-sqltoy by chenrenfei.
the class LinkDaoTest method findESBySqlPage.
@Test
public void findESBySqlPage() throws Exception {
GoodsParam goodsParam = new GoodsParam();
goodsParam.setGoodsCateId("1515376757743370152561");
List<String> goodsCateIds = new ArrayList<>();
goodsCateIds.add("1515376757743370152561");
PaginationModel paginationModel = new PaginationModel();
goodsParam.setPage(paginationModel);
goodsParam.setGoodsCateIds(goodsCateIds);
goodsParam.setKeyword("资源");
PaginationModel pageModel = new PaginationModel();
PaginationModel pageGoods = staffInfoDao.findESPageBySql(pageModel, goodsParam);
List<Goods> goodsResults = pageGoods.getRows();
System.out.println(JSON.toJSONString(goodsResults));
}
Aggregations