| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.collaborativeApproval.dto.NoticeDTO; |
| | |
| | | import com.ruoyi.collaborativeApproval.service.NoticeService; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Override |
| | | public List<NoticeDTO> selectCount() { |
| | | List<Notice> notices = noticeMapper.selectList(Wrappers.lambdaQuery(Notice.class).groupBy(Notice::getType)); |
| | | List<NoticeDTO> result = new ArrayList<>(); |
| | | NoticeDTO notice = new NoticeDTO(); |
| | | notice.setType(1); |
| | | notice.setCount(noticeMapper.selectCount(new LambdaQueryWrapper<Notice>().eq(Notice::getType, 1))); |
| | | result.add(notice); |
| | | |
| | | NoticeDTO notice1 = new NoticeDTO(); |
| | | notice1.setType(2); |
| | | notice1.setCount(noticeMapper.selectCount(new LambdaQueryWrapper<Notice>().eq(Notice::getType, 2))); |
| | | result.add(notice1); |
| | | |
| | | for (Notice notice : notices) { |
| | | NoticeDTO notice1 = new NoticeDTO(); |
| | | BeanUtils.copyProperties(notice, notice1); |
| | | notice1.setCount(noticeMapper.selectCount(new LambdaQueryWrapper<Notice>().eq(Notice::getType, notice.getType()))); |
| | | result.add(notice1); |
| | | } |
| | | return result; |
| | | } |
| | | } |