mitao
5 天以前 0b7e2752b6f1e87084b837043291c890cca780a8
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/OaNotificationServiceImpl.java
@@ -62,4 +62,36 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public PageInfo<NotificationVO> pageListUser(NotificationListQuery query) {
        List<TDept> tDepts = deptMapper.selectList(null);
        Map<Integer, String> deptMap = tDepts.stream().collect(Collectors.toMap(TDept::getId, TDept::getDeptName));
        if (StringUtils.hasLength(query.getDeptName())){
            List<Integer> deptIds = deptMapper.selectList(new LambdaQueryWrapper<TDept>().like(TDept::getDeptName, query.getDeptName()))
                    .stream().map(TDept::getId).collect(Collectors.toList());
            if (deptIds.isEmpty()){
                return new PageInfo<>();
            }
            query.setDeptIds(deptIds);
        }
        PageInfo<NotificationVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<NotificationVO> list = this.baseMapper.pageListUser(query,pageInfo);
        for (NotificationVO notificationVO : list) {
            StringBuilder deptName = new StringBuilder();
            if (notificationVO.getType()){
                for (String deptId : notificationVO.getDeptIds().split(",")) {
                    String orDefault = deptMap.getOrDefault(Integer.parseInt(deptId), "");
                    deptName.append(orDefault).append(",");
                }
                notificationVO.setDeptName(deptName.substring(0,deptName.length()-1));
            }else{
                notificationVO.setDeptName("全部人员");
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}