NoticeServiceImpl.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.constant.AFTConstants;
  11. import com.goafanti.common.dao.NoticeMapper;
  12. import com.goafanti.common.model.Notice;
  13. import com.goafanti.core.mybatis.BaseMybatisDao;
  14. import com.goafanti.core.mybatis.page.Pagination;
  15. import com.goafanti.core.shiro.token.TokenManager;
  16. @Service
  17. public class NoticeServiceImpl extends BaseMybatisDao<NoticeMapper> implements NoticeService {
  18. @Autowired
  19. private NoticeMapper noticeMapper;
  20. @SuppressWarnings("unchecked")
  21. @Override
  22. public Pagination<NoticeBo> updateListUnreadNoticeByAid(Integer pageNo, Integer pageSize, String aid) {
  23. Map<String, Object> params = new HashMap<>();
  24. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  25. params.put("aid", aid);
  26. }
  27. if (pageNo == null || pageNo < 0) {
  28. pageNo = 1;
  29. }
  30. if (pageSize == null || pageSize < 0) {
  31. pageSize = 10;
  32. }
  33. Pagination<NoticeBo> notice = (Pagination<NoticeBo>) findPage("findUnreadNoticeListByPage", "findUnreadNoticeCount",
  34. params, pageNo, pageSize);
  35. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && null != notice.getList() && notice.getList().size()>0) {
  36. List<Notice> list = (List<Notice>) notice.getList();
  37. List<String> dl = new ArrayList<String>();
  38. for (Notice n : list) {
  39. dl.add(n.getId());
  40. }
  41. noticeMapper.batchUpdateUnreaded(dl);
  42. }
  43. return notice;
  44. }
  45. @SuppressWarnings("unchecked")
  46. @Override
  47. public Pagination<NoticeBo> ListReadedNoticeByAid(Integer pageNo, Integer pageSize, String aid) {
  48. Map<String, Object> params = new HashMap<>();
  49. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  50. params.put("aid", aid);
  51. }
  52. if (pageNo == null || pageNo < 0) {
  53. pageNo = 1;
  54. }
  55. if (pageSize == null || pageSize < 0) {
  56. pageSize = 10;
  57. }
  58. return (Pagination<NoticeBo>) findPage("findReadedNoticeListByPage", "findReadedNoticeCount", params, pageNo,
  59. pageSize);
  60. }
  61. @Override
  62. public int findUnreadNoticeCount() {
  63. String aid = null;
  64. if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  65. aid = TokenManager.getAdminId();
  66. }
  67. return noticeMapper.selectUnreadedCount(aid);
  68. }
  69. }