package com.goafanti.admin.service.impl; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.goafanti.admin.bo.NoticeBo; import com.goafanti.admin.service.NoticeService; import com.goafanti.common.constant.AFTConstants; import com.goafanti.common.dao.NoticeMapper; import com.goafanti.common.model.Notice; import com.goafanti.core.mybatis.BaseMybatisDao; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; @Service public class NoticeServiceImpl extends BaseMybatisDao implements NoticeService { @Autowired private NoticeMapper noticeMapper; @SuppressWarnings("unchecked") @Override public Pagination updateListUnreadNoticeByAid(Integer pageNo, Integer pageSize, String aid) { Map params = new HashMap<>(); if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) { params.put("aid", aid); } if (pageNo == null || pageNo < 0) { pageNo = 1; } if (pageSize == null || pageSize < 0) { pageSize = 10; } Pagination notice = (Pagination) findPage("findUnreadNoticeListByPage", "findUnreadNoticeCount", params, pageNo, pageSize); if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && null != notice.getList() && notice.getList().size()>0) { List list = (List) notice.getList(); List dl = new ArrayList(); for (Notice n : list) { dl.add(n.getId()); } noticeMapper.batchUpdateUnreaded(dl); } return notice; } @SuppressWarnings("unchecked") @Override public Pagination ListReadedNoticeByAid(Integer pageNo, Integer pageSize, String aid) { Map params = new HashMap<>(); if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) { params.put("aid", aid); } if (pageNo == null || pageNo < 0) { pageNo = 1; } if (pageSize == null || pageSize < 0) { pageSize = 10; } return (Pagination) findPage("findReadedNoticeListByPage", "findReadedNoticeCount", params, pageNo, pageSize); } @Override public int findUnreadNoticeCount() { String aid = null; if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) { aid = TokenManager.getAdminId(); } return noticeMapper.selectUnreadedCount(aid); } }