Example #1
0
 /**
  * 短信邮件发送 查询用户列表集合
  *
  * @param user
  * @param page
  * @return
  */
 @RequestMapping("/user/select_userlist/{type}")
 public ModelAndView selectUserList(
     @ModelAttribute User user,
     @ModelAttribute("page") PageEntity page,
     @PathVariable("type") int type) {
   ModelAndView modelandView = new ModelAndView();
   // 设置返回页面
   modelandView.setViewName(toSelectUserList);
   try {
     if (type == 3) {
       page.setPageSize(5);
     }
     // 设置分页 ,默认每页10
     this.setPage(page);
     // 查询学员列表
     List<User> list = userService.getUserListAndCourse(user, this.getPage());
     // 把参数放到modelAndView中
     modelandView.addObject("list", list);
     modelandView.addObject("page", this.getPage());
     modelandView.addObject("type", type); // 1 短信  2邮箱  3系统消息
   } catch (Exception e) {
     logger.error("AdminUserController.userList", e);
   }
   return modelandView;
 }
Example #2
0
  /**
   * 批量发送 系统消息
   *
   * @param request
   * @param content
   * @param cusId
   * @return
   */
  @RequestMapping(value = "/letter/sendSystemInfoByCusIds")
  @ResponseBody
  public Map<String, Object> sendSystemInfoByCusIds(
      @ModelAttribute User user,
      HttpServletRequest request,
      @ModelAttribute("page") PageEntity page) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
      page.setPageSize(10000);
      // 查询学员列表
      List<User> list = userService.getUserListAndCourse(user, page);

      String content = request.getParameter("messsageContent"); // 发送系统消息的内容
      if (list == null || list.size() == 0) {
        map.put("message", "没有符合条件的会员");
      } else {
        List<MsgReceive> msgrcList = new ArrayList<MsgReceive>();
        for (int i = 0; i < list.size(); i++) {
          MsgReceive msgReceive1 = new MsgReceive();
          msgReceive1.setContent(content);
          msgReceive1.setAddTime(new Date());
          msgReceive1.setReceivingCusId(list.get(i).getId());
          msgReceive1.setStatus(LetterConstans.LETTER_STATUS_READ);
          msgReceive1.setType(LetterConstans.LETTER_TYPE_SYSTEMINFORM);
          msgReceive1.setUpdateTime(new Date());
          msgReceive1.setShowname("");
          msgReceive1.setCusId(0L);
          msgrcList.add(msgReceive1);
        }
        // 发送
        msgReceiveService.addMsgReceiveBatch(msgrcList);
        map.put("message", "success");
      }

    } catch (Exception e) {
      logger.error("AdminLetterAction.sendSystemInfoByCusIds", e);
      setExceptionRequest(request, e);
    }
    return map;
  }