NoticeServiceImpl.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package com.goafanti.admin.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.stereotype.Service;
  8. import com.goafanti.admin.bo.NoticeBo;
  9. import com.goafanti.admin.service.NoticeService;
  10. import com.goafanti.common.dao.NoticeMapper;
  11. import com.goafanti.common.enums.NoticeTypes;
  12. import com.goafanti.core.mybatis.BaseMybatisDao;
  13. import com.goafanti.core.mybatis.page.Pagination;
  14. import com.goafanti.core.shiro.token.TokenManager;
  15. @Service
  16. public class NoticeServiceImpl extends BaseMybatisDao<NoticeMapper> implements NoticeService {
  17. @Autowired
  18. private NoticeMapper noticeMapper;
  19. @Override
  20. public List<Map<String, Object>> updateListUnreadNoticeByAid() {
  21. List<Map<String, Object>> list = new ArrayList<>();
  22. List<NoticeBo> nl = noticeMapper.findUnreadNoticeListByPage(TokenManager.getAdminId());
  23. List<String> dl = new ArrayList<String>();
  24. for (int i = NoticeTypes.getCount(); i >= 0; i--) {
  25. Map<String, Object> map = new HashMap<String, Object>();
  26. List<NoticeBo> cffk = new ArrayList<NoticeBo>();
  27. for (NoticeBo n : nl) {
  28. // 0专利提醒
  29. if (n.getType() == i) {
  30. cffk.add(n);
  31. } else if (n.getType() == i) {
  32. cffk.add(n);
  33. } else if (n.getType() == i) {
  34. cffk.add(n);
  35. } else if (n.getType() == i) {
  36. cffk.add(n);
  37. } else if (n.getType() == i) {
  38. cffk.add(n);
  39. } else if (n.getType() == i) {
  40. cffk.add(n);
  41. } else if (n.getType() == i) {
  42. cffk.add(n);
  43. }
  44. }
  45. map.put("name", NoticeTypes.getValueByCode(i));
  46. map.put("id", i);
  47. map.put("list", cffk);
  48. list.add(map);
  49. }
  50. if (!nl.isEmpty()) {
  51. for (NoticeBo n : nl) {
  52. // 添加已读
  53. dl.add(n.getId());
  54. }
  55. noticeMapper.batchUpdateUnreaded(dl);
  56. }
  57. return list;
  58. }
  59. @SuppressWarnings("unchecked")
  60. @Override
  61. public Pagination<NoticeBo> ListReadedNoticeByAid(Integer type, Integer pageNo, Integer pageSize) {
  62. Map<String, Object> params = new HashMap<>();
  63. params.put("aid", TokenManager.getAdminId());
  64. params.put("type", type==null?0:type);
  65. return (Pagination<NoticeBo>) findPage("findReadedNoticeListByPage", "findReadedNoticeCount", params, pageNo,
  66. pageSize);
  67. }
  68. @Override
  69. public int findUnreadNoticeCount() {
  70. return noticeMapper.selectUnreadedCount(TokenManager.getAdminId());
  71. }
  72. }