cxyskjscf
@GetMapping("/funcResourcePage")
public Response funcResourcePage(@Validated({ QueryGroup.class }) PtyAuthResourceQo authResourceQo) {
return Response.commonResponse(StatusEnum.SELECT_SUCCESS).setData(authService.funcResourcePage(authResourceQo));
}
@Override
public PageResult<PtyAppResourceVo> funcResourcePage(PtyAuthResourceQo authResourceQo) {
PtyAuthResource ptyAuthResource = new PtyAuthResource();
BeanUtils.copyProperties(authResourceQo, ptyAuthResource);
// 查询所有功能的资源
PageInfo<PtyAuthResource> pageInfo = PageHelper
.startPage(authResourceQo.getPageIndex(), authResourceQo.getPageSize())
.doSelectPageInfo(() -> authResourceDao.selectNotAuthResource(ptyAuthResource));
List<PtyAuthResource> all = pageInfo.getList();
// 查询已授权的
ptyAuthResource.setOpType("show");
PageInfo<PtyAuthResource> pageInfoAuth = PageHelper
.startPage(authResourceQo.getPageIndex(), authResourceQo.getPageSize())
.doSelectPageInfo(() -> authResourceDao.select(ptyAuthResource));
List<PtyAuthResource> authed = pageInfoAuth.getList();
List<PtyAppResourceVo> result = all.stream().map(resource -> {
PtyAppResourceVo vo = new PtyAppResourceVo();
BeanUtils.copyProperties(resource, vo);
resource.setPartyCode(authResourceQo.getPartyCode());
if (!authed.contains(resource)) {
vo.setOpType("hide");
}else{
vo.setOpType("show");
}
return vo;
}).collect(Collectors.toList());
return new PageResult<PtyAppResourceVo>().setTotal(pageInfo.getTotal()).setResult(result);
}
<select id="selectNotAuthResource" parameterType="com.boss.cxgovac.pauth.entity.PtyAuthResource" resultType="com.boss.cxgovac.pauth.entity.PtyAuthResource">
SELECT
RESOURCE_ID as resourceId,
APP_ID as appId,
FUNC_CODE as funcCode,
RESOURCE_CODE as resourceCode,
RESOURCE_NAME as resourceName
FROM afa_app_resource
WHERE FUNC_CODE = #{funcCode}
</select>
<select id="select" parameterType="com.boss.cxgovac.pauth.entity.PtyAuthResource"
resultType="com.boss.cxgovac.pauth.entity.PtyAuthResource">
SELECT
<include refid="allColumnAlias"/>
FROM afa_auth_resource
WHERE 1=1
<include refid="allColumnCond"/>
</select>