@Override public int addReadNumsByOne(String id) throws ServiceException { // TODO Auto-generated method stub NoticeModel notice = noticeDAO.get(id); if (notice.getStatus() != 0) { notice.setReadNums(notice.getReadNums() + 1); noticeDAO.saveOrUpdate(notice); } return notice.getReadNums(); }
@SuppressWarnings("unchecked") @Override public Map<String, List<NoticeModel>> getTop5Notice() throws ServiceException { // TODO Auto-generated method stub Map<String, List<NoticeModel>> noticeMap = new LinkedHashMap<String, List<NoticeModel>>(); int countMax = 5; DetachedCriteria criteria = DetachedCriteria.forClass(DirectoryModel.class); String type = "news"; criteria.add(Restrictions.eq("type", type)); List<DirectoryModel> directoryList = directoryDAO.getListByCriteria(criteria); if (directoryList != null && directoryList.size() > 0) { for (DirectoryModel model : directoryList) { DetachedCriteria criteria2 = DetachedCriteria.forClass(NoticeModel.class); if (StringUtils.isNotEmpty(model.getName())) criteria2.add(Restrictions.eq("type", model.getName())); List<NoticeModel> list = noticeDAO.getListByCriteria(criteria2); List<NoticeModel> top5List = new ArrayList<NoticeModel>(); for (int i = 0; i < list.size() && i < countMax; i++) { top5List.add(list.get(i)); } noticeMap.put(model.getName(), top5List); } } return noticeMap; }
@Override public PaginationSupport<NoticeModel> getNoticesByConditions( String userId, String schoolId, String departmentId, String name, String status, String type, String emergence, String beginDate, String endDate, int index, int pageSize) throws ServiceException { // TODO Auto-generated method stub return noticeDAO.getNoticesByConditions( userId, schoolId, departmentId, name, status, type, emergence, beginDate, endDate, index, pageSize); }
@Override public void saveNotice(NoticeModel model, String attachmentIds) throws ServiceException { if (StringUtils.isEmpty(model.getId())) model.setPostTime(new Date()); if (model.getLastEditorId() != null) model.setLastEditTime(new Date()); noticeDAO.saveOrUpdate(model); if (StringUtils.isNotEmpty(attachmentIds)) { String[] ids = attachmentIds.split(";"); for (int i = 0; i < ids.length; i++) { AttachmentModel attachment = attachmentDAO.get(ids[i]); attachment.setBelongObject(NoticeModel.class.getSimpleName()); attachment.setBelongObjectId(model.getId()); attachmentDAO.saveOrUpdate(attachment); } } NoticeModel newModel = noticeDAO.get(model.getId()); noticeDAO.merge(newModel); }
@Override public boolean deleteNoticeById(String id) { // TODO Auto-generated method stub try { noticeDAO.remove(loadNoticeInfoById(id)); } catch (DAOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } return true; }
@SuppressWarnings("unchecked") @Override public List<NoticeModel> getNotices(String userId, String beginDate, String endDate, String type) throws ServiceException { // TODO Auto-generated method stub DetachedCriteria criteria = DetachedCriteria.forClass(NoticeModel.class); if (StringUtils.isNotEmpty(userId) && (!userId.equals("1"))) { criteria.add(Restrictions.like("teacherAttendIds", userId, MatchMode.ANYWHERE)); } if (StringUtils.isNotEmpty(beginDate)) criteria.add(Restrictions.sqlRestriction("postTime >= '" + beginDate + " 00:00:00'")); if (StringUtils.isNotEmpty(endDate)) criteria.add(Restrictions.sqlRestriction("postTime <= '" + endDate + " 23:59:59'")); if (StringUtils.isNotEmpty(type)) criteria.add(Restrictions.eq("type", type)); criteria.add(Restrictions.eq("status", NoticeModel.EStatus.Published.getValue())); criteria.addOrder(Order.desc("postTime")); return noticeDAO.getListByCriteria(criteria); }
@Override public NoticeModel get(String id) throws ServiceException { // TODO Auto-generated method stub return noticeDAO.get(id); }
@Override public NoticeModel loadNoticeInfoById(String id) { // TODO Auto-generated method stub return noticeDAO.get(id); }