无关风月
19 小时以前 7e8773c06d9391c94b7a0111b63d17cf5bdb6d8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.ruoyi.system.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.TDept;
import com.ruoyi.system.mapper.OaNotificationMapper;
import com.ruoyi.system.mapper.TDeptMapper;
import com.ruoyi.system.model.OaNotification;
import com.ruoyi.system.query.NotificationListQuery;
import com.ruoyi.system.service.OaNotificationService;
import com.ruoyi.system.vo.system.NotificationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 通知表 服务实现类
 * </p>
 *
 * @author WuGuanFengYue
 * @since 2025-09-15
 */
@Service
public class OaNotificationServiceImpl extends ServiceImpl<OaNotificationMapper, OaNotification> implements OaNotificationService {
 
    @Autowired
    private TDeptMapper deptMapper;
    @Override
    public PageInfo<NotificationVO> pageList(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.pageList(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 null;
    }
}