Ejemplo n.º 1
0
 /**
  * 查询短信详情
  *
  * @param model
  * @param id
  * @return
  */
 @RequestMapping("/user/sendMsgInfo/{id}")
 public String querySendMobleMsgInfo(Model model, @PathVariable("id") Long id) {
   try {
     UserMobileMsg userMobileMsg = userMobileMsgService.queryUserMobileMsgById(id);
     model.addAttribute("userMobileMsg", userMobileMsg);
   } catch (Exception e) {
     logger.error("querySendMobleMsgInfo", e);
   }
   return sendMobileMsgInfo;
 }
Ejemplo n.º 2
0
 /**
  * 删除短信
  *
  * @param model
  * @param id
  * @return
  */
 @RequestMapping("/user/delMsgById/{id}")
 @ResponseBody
 public Map<String, Object> delUserMobileMsgById(Model model, @PathVariable("id") Long id) {
   try {
     userMobileMsgService.delUserMobileMsg(id);
     this.setJson(true, "删除成功", null);
   } catch (Exception e) {
     logger.error("delUserMobileMsgById", e);
     this.setJson(false, "删除失败!", null);
   }
   return json;
 }
Ejemplo n.º 3
0
 /**
  * 修改短信
  *
  * @return
  */
 @RequestMapping("/user/updateUserMsg")
 @ResponseBody
 public Map<String, Object> updateUserMsg(HttpServletRequest request) {
   try {
     UserMobileMsg userMobileMsg = new UserMobileMsg();
     userMobileMsg.setId(Integer.parseInt(request.getParameter("msgId")));
     userMobileMsg.setContent(request.getParameter("content"));
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
     userMobileMsg.setSendTime(df.parse(request.getParameter("sendTime")));
     userMobileMsgService.updateUserMobileMsg(userMobileMsg);
     this.setJson(true, "修改成功", null);
   } catch (Exception e) {
     logger.error("updateUserMsg", e);
     this.setJson(false, "修改失败", null);
   }
   return json;
 }
Ejemplo n.º 4
0
 /**
  * 短信管理
  *
  * @param model
  * @param request
  * @param userMobileMsg
  * @param page
  * @return
  */
 @RequestMapping("/user/sendMsglist")
 public String querySendMobileMsgList(
     Model model,
     HttpServletRequest request,
     @ModelAttribute("userMobileMsg") UserMobileMsg userMobileMsg,
     @ModelAttribute("page") PageEntity page) {
   try {
     this.setPage(page);
     this.getPage().setPageSize(10);
     List<UserMobileMsg> list =
         userMobileMsgService.queryUserMobileMsgList(userMobileMsg, this.getPage());
     model.addAttribute("list", list);
     model.addAttribute("page", this.getPage());
   } catch (Exception e) {
     logger.error("querySendMobileMsgList", e);
   }
   return sendMobileMsgList;
 }
Ejemplo n.º 5
0
  /**
   * 发送短信
   *
   * @param request
   * @return
   */
  @RequestMapping("/user/sendMsg")
  @ResponseBody
  public Map<String, Object> sendMobileMsg(HttpServletRequest request) {
    try {

      List<UserMobileMsg> msgList = new ArrayList<UserMobileMsg>();

      String linksman = request.getParameter("linksman"); // 获取联系人
      String content = request.getParameter("content"); // 获取内容
      Integer type = Integer.parseInt(request.getParameter("sendType")); // 发送方式

      Date now = new Date();
      Date sendTime = now;
      if (type == 2) { // 定时发送

        if (StringUtils.isEmpty(request.getParameter("sendTime"))) {
          this.setJson(false, "定时发送时间不能为空", "");
          return json;
        }
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        sendTime = df.parse(request.getParameter("sendTime")); // 定时发送时间
      }
      if (StringUtils.isNotEmpty(linksman) && StringUtils.isNotEmpty(content)) {
        // 验证手机
        Map<String, Object> returnMap = checkMobile(linksman);
        // 错误信息
        String errorMobile = returnMap.get("errorMobile").toString();
        if (Boolean.parseBoolean(returnMap.get("flag").toString()) == false) {
          this.setJson(false, errorMobile, "");
          return json;
        } else {
          // 添加发送记录
          JsonObject user = SingletonLoginUtils.getSysUser(request);
          UserMobileMsg userMobileMsg = new UserMobileMsg();
          userMobileMsg.setSendTime(sendTime);
          if (type == 1) { // 正常发送
            userMobileMsg.setStatus(1);
          } else { // 定时发送
            userMobileMsg.setStatus(2);
          }
          userMobileMsg.setId(0);
          userMobileMsg.setType(type);

          userMobileMsg.setContent(content);
          userMobileMsg.setMobile(returnMap.get("mobileList").toString());
          if (ObjectUtils.isNotNull(user)) {
            userMobileMsg.setUserId(user.get("userId").getAsLong());
          } else {
            userMobileMsg.setUserId(0L);
          }
          userMobileMsg.setCreateTime(now);
          msgList.add(userMobileMsg);
          // 添加记录 暂不发送
          userMobileMsgService.addUserMobileMsg(msgList);
          if (type == 1) { // 正常发送
            userMobileMsgService.batchSendMobileMsg(
                content, returnMap.get("mobileList").toString().split(","), 3);
          }
          errorMobile = "发送成功";
        }
        this.setJson(Boolean.parseBoolean(returnMap.get("flag").toString()), errorMobile, "");
      } else {
        this.setJson(false, "联系人或内容不能为空", null);
      }
    } catch (Exception e) {
      logger.error("sendMobileMsg", e);
    }
    return json;
  }