use of com.baomidou.mybatisplus.core.metadata.IPage in project goodsKill by techa03.
the class AdminController method permissionTree.
@RequestMapping(value = "/permissionTree", method = GET, produces = { "application/json;charset=UTF-8" })
@ResponseBody
public ResponseDTO permissionTree(@RequestParam(name = "page", required = false, defaultValue = "0") int offset, @RequestParam(name = "limit", required = false, defaultValue = "10") int limit) {
Page<Permission> page = new Page<>(offset, limit);
IPage<Permission> pageInfo = permissionService.page(page);
List<Permission> permissions = pageInfo.getRecords();
List<PermissionDTO> permissionDTOList = new ArrayList<>();
for (Permission permission : permissions) {
PermissionDTO permissionDto = new PermissionDTO();
permissionDto.setId(permission.getPermissionId().toString());
if (permission.getParentPermissionId() != null) {
permissionDto.setPId(permission.getParentPermissionId().toString());
}
permissionDto.setName(permission.getPermissionName());
permissionDTOList.add(permissionDto);
}
ResponseDTO<PermissionDTO> responseDto = new ResponseDTO<>();
responseDto.setData(permissionDTOList.toArray(new PermissionDTO[permissionDTOList.size()]));
responseDto.setCount((int) pageInfo.getTotal());
return responseDto;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project goodsKill by techa03.
the class MultiDatasourceTransactionTest method testPage.
@Test
public void testPage() {
IPage page = successKilledService.page(new Page<>(1, 100));
assertTrue(page.getSize() > 0);
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project diboot by dibo-software.
the class BaseServiceImpl method getMapList.
@Override
public List<Map<String, Object>> getMapList(Wrapper queryWrapper, Pagination pagination) {
if (pagination != null) {
IPage page = convertToIPage(queryWrapper, pagination);
IPage<Map<String, Object>> resultPage = super.pageMaps(page, queryWrapper);
// 如果重新执行了count进行查询,则更新pagination中的总数
if (page.searchCount()) {
pagination.setTotalCount(page.getTotal());
}
return resultPage.getRecords();
} else {
List<Map<String, Object>> list = super.listMaps(queryWrapper);
if (list == null) {
list = Collections.emptyList();
} else if (list.size() > BaseConfig.getBatchSize()) {
log.warn("单次查询记录数量过大,请及时检查优化。返回结果数={}", list.size());
}
return list;
}
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project jeecg-boot by jeecgboot.
the class JeecgController method exportXlsSheet.
/**
* 根据每页sheet数量导出多sheet
*
* @param request
* @param object 实体类
* @param clazz 实体类class
* @param title 标题
* @param exportFields 导出字段自定义
* @param pageNum 每个sheet的数据条数
* @param request
*/
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title, String exportFields, Integer pageNum) {
// Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 计算分页sheet数据
double total = service.count();
int count = (int) Math.ceil(total / pageNum);
// Step.3 多sheet处理
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
for (int i = 1; i <= count; i++) {
Page<T> page = new Page<T>(i, pageNum);
IPage<T> pageList = service.page(page, queryWrapper);
List<T> records = pageList.getRecords();
List<T> exportList = null;
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = records.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
} else {
exportList = records;
}
Map<String, Object> map = new HashMap<String, Object>();
ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title + i, upLoadPath);
exportParams.setType(ExcelType.XSSF);
// map.put("title",exportParams);//表格Title
// 表格Title
map.put(NormalExcelConstants.PARAMS, exportParams);
// 表格对应实体
map.put(NormalExcelConstants.CLASS, clazz);
// 数据集合
map.put(NormalExcelConstants.DATA_LIST, exportList);
listMap.add(map);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
// 此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.MAP_LIST, listMap);
return mv;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project jeecg-boot by jeecgboot.
the class SysUserController method departUserList.
/**
* 部门用户列表
*/
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
public Result<IPage<SysUser>> departUserList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
String depId = req.getParameter("depId");
String username = req.getParameter("username");
// 根据部门ID查询,当前和下级所有的部门IDS
List<String> subDepids = new ArrayList<>();
// 部门id为空时,查询我的部门下所有用户
if (oConvertUtils.isEmpty(depId)) {
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
int userIdentity = user.getUserIdentity() != null ? user.getUserIdentity() : CommonConstant.USER_IDENTITY_1;
if (oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2) {
subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
}
} else {
subDepids = sysDepartService.getSubDepIdsByDepId(depId);
}
if (subDepids != null && subDepids.size() > 0) {
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page, subDepids, username);
// 批量查询用户的所属部门
// step.1 先拿到全部的 useids
// step.2 通过 useids,一次性查询用户的所属部门名字
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
if (userIds != null && userIds.size() > 0) {
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
pageList.getRecords().forEach(item -> {
// 批量查询用户的所属部门
item.setOrgCode(useDepNames.get(item.getId()));
});
}
result.setSuccess(true);
result.setResult(pageList);
} else {
result.setSuccess(true);
result.setResult(null);
}
return result;
}
Aggregations