| | |
| | | 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> |
| | |
| | | @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; |
| | | } |
| | | } |