permission

This commit is contained in:
xzb 2022-10-18 10:29:05 +08:00
parent 013b58f6bd
commit b40ccfe775

View File

@ -10,6 +10,8 @@ import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.permission.*; import club.joylink.rtss.vo.permission.*;
import club.joylink.rtss.vo.permission.convertor.PermissionConvertor; import club.joylink.rtss.vo.permission.convertor.PermissionConvertor;
import club.joylink.rtss.vo.permission.convertor.SystemAbilityConvertor; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -186,29 +188,19 @@ public class AcPermissionService {
} }
} }
// //
PageVO<PermissionBasicRspVo> page = new PageVO<>(); final String orderBy = req.getOrderByType().with() + (req.getDesc() ? " desc" : "");
long sum = this.permissionDAO.countByExample(permissionExample); PageHelper.startPage(req.getPageNum(), req.getPageSize(), orderBy);
page.setTotal(sum); Page<Permission> sqlPage = (Page<Permission>) this.permissionDAO.selectByExample(permissionExample);
page.setPageNum(req.getPageNum()); PageHelper.clearPage();
page.setPageSize(req.getPageSize());
page.setList(new ArrayList<>());
if (sum > 0) {
// //
String orderBy = req.getOrderByType().with(); List<PermissionBasicRspVo> rtList = new ArrayList<>();
long startIndex = (req.getPageNum() - 1) * req.getPageSize(); if (!CollectionUtils.isEmpty(sqlPage.getResult())) {
rtList=sqlPage.getResult().stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList());
}
// //
if (req.getDesc()) { return PageVO.convert(sqlPage,rtList);
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<Permission> pContent = this.permissionDAO.selectByExample(permissionExample);
if (!CollectionUtils.isEmpty(pContent)) {
page.setList(pContent.stream().map(PermissionConvertor::convertPermissionBasicRspVoFrom).collect(Collectors.toList()));
}
}
return page;
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) { private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) {
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample(); PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();