Пример #1
0
    /*
     * 创建事件 业务部分写在pullEvent()方法中,这个方法会被定时调用。
     */
    @Override
    protected Event pullEvent() {
      Event event = Event.createDataEvent("/notify/message");

      int count = SessionManager.getInstance().getSessionCount();
      if (count >= 1) {
        Session[] sessions = SessionManager.getInstance().getSessions();
        String userId = sessions[0].getEvent().getField("user_id");

        WebApplicationContext context = SpringContextHolder.getContext();
        NotifyMessageService notifyService =
            (NotifyMessageService) context.getBean("notifyService");

        NotifyMessage entity = new NotifyMessage();
        entity.setIs_query(false);
        entity.setIs_read(false);
        entity.setReceiver_id(Integer.parseInt(userId));
        Map<Integer, List<NotifyMessage>> map = notifyService.modifyAndQueryMapList(entity);
        try {
          String data = buildText(map);
          event.setField("data", data);
        } catch (Exception ex) {
          LogHelper.getLogger().error("构建事务通知信息时出错", ex);
        }

        // 在线用户
        event.setField("userCount", OnlineUser.getInstance().gainUserCount());
      }

      return event;
    }
Пример #2
0
 /**
  * @Description 标记已读
  *
  * @param id
  * @return JsonResult
  */
 @RequestMapping("/read")
 public @ResponseBody JsonResult read(Integer id) {
   NotifyMessage entity = new NotifyMessage();
   entity.setId(id);
   entity.setIs_read(true);
   return notifyMessageService.modify(entity);
 }
Пример #3
0
 /**
  * @Description 获取列表数据
  *
  * @param model
  * @author davidwan
  */
 @RequestMapping("/homelist")
 public @ResponseBody Map<Integer, List<NotifyMessage>> homeList(
     Boolean is_init, HttpServletRequest request) {
   NotifyMessage entity = new NotifyMessage();
   entity.setIs_read(false);
   entity.setIs_query(!is_init);
   entity.setReceiver_id(getCurrentUserId());
   Map<Integer, List<NotifyMessage>> map = notifyMessageService.modifyAndQueryMapList(entity);
   return map;
 }
Пример #4
0
 /**
  * @Description 标记当前用户所有未读提醒为已读
  *
  * @param entity
  * @return JsonResult
  */
 @RequestMapping("/readall")
 public @ResponseBody JsonResult readAll(NotifyMessage entity) {
   entity.getMap().put("receiver_id", getCurrentUserId());
   entity.setIs_read(true);
   return notifyMessageService.modify(entity);
 }