diff --git a/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java b/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java index 4a1d43749..74d6d358b 100644 --- a/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java +++ b/src/main/java/club/joylink/rtss/services/permission/AcPermissionService.java @@ -10,6 +10,8 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.permission.*; import club.joylink.rtss.vo.permission.convertor.PermissionConvertor; import club.joylink.rtss.vo.permission.convertor.SystemAbilityConvertor; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -186,29 +188,19 @@ public class AcPermissionService { } } // - PageVO page = new PageVO<>(); - long sum = this.permissionDAO.countByExample(permissionExample); - page.setTotal(sum); - page.setPageNum(req.getPageNum()); - page.setPageSize(req.getPageSize()); - page.setList(new ArrayList<>()); - if (sum > 0) { - // - String orderBy = req.getOrderByType().with(); - long startIndex = (req.getPageNum() - 1) * req.getPageSize(); - // - if (req.getDesc()) { - permissionExample.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize())); - } else { - permissionExample.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize())); - } - List pContent = this.permissionDAO.selectByExample(permissionExample); - if (!CollectionUtils.isEmpty(pContent)) { - page.setList(pContent.stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList())); - } + final String orderBy = req.getOrderByType().with() + (req.getDesc() ? " desc" : ""); + PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy); + Page sqlPage = (Page) this.permissionDAO.selectByExample(permissionExample); + PageHelper.clearPage(); + // + List rtList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(sqlPage.getResult())) { + rtList=sqlPage.getResult().stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList()); } - return page; + // + return PageVO.convert(sqlPage,rtList); } + /////////////////////////////////////////////////////////////////////////////////////////////////////// private List findAbilitiesByPermissionId(Long permissionId) { PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();