Search in sources :

Example 1 with IPage

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;
}
Also used : PermissionDTO(com.goodskill.web.dto.PermissionDTO) ResponseDTO(com.goodskill.web.dto.ResponseDTO) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 2 with IPage

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);
}
Also used : IPage(com.baomidou.mybatisplus.core.metadata.IPage) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with IPage

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;
    }
}
Also used : IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 4 with IPage

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;
}
Also used : JeecgEntityExcelView(org.jeecgframework.poi.excel.view.JeecgEntityExcelView) ModelAndView(org.springframework.web.servlet.ModelAndView) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) LoginUser(org.jeecg.common.system.vo.LoginUser) ExportParams(org.jeecgframework.poi.excel.entity.ExportParams)

Example 5 with IPage

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;
}
Also used : Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) LoginUser(org.jeecg.common.system.vo.LoginUser) Result(org.jeecg.common.api.vo.Result) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Aggregations

IPage (com.baomidou.mybatisplus.core.metadata.IPage)197 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)152 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)73 ApiOperation (io.swagger.annotations.ApiOperation)28 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)20 PageDTO (com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO)19 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 LoginUser (org.jeecg.common.system.vo.LoginUser)16 JSONObject (com.alibaba.fastjson.JSONObject)15 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)15 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)13 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)11 Result (org.jeecg.common.api.vo.Result)10 List (java.util.List)9 User (org.apache.dolphinscheduler.dao.entity.User)9 Field (java.lang.reflect.Field)8 Date (java.util.Date)8 Collectors (java.util.stream.Collectors)7 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)7