Ejemplo n.º 1
0
 /** 查询邮件详情 */
 @RequestMapping("/user/sendEmailMsgInfo/{id}")
 public String querySendEmailMsgInfo(Model model, @PathVariable("id") Long id) {
   try {
     UserEmailMsg userEmailMsg = userEmailMsgService.queryUserEmailMsgById(id);
     model.addAttribute("userEmailMsg", userEmailMsg);
   } catch (Exception e) {
     logger.error("querySendMobleMsgInfo", e);
   }
   return sendEmailMsgInfo;
 }
Ejemplo n.º 2
0
 /** 邮箱管理 */
 @RequestMapping("/sendEmail/del")
 public String delSendEmailMsg(
     Model model, HttpServletRequest request, @RequestParam("id") Long id) {
   try {
     userEmailMsgService.delUserEmailMsgById(id);
   } catch (Exception e) {
     logger.error("delSendEmailMsg", e);
   }
   return "redirect:/admin/user/sendEmaillist";
 }
Ejemplo n.º 3
0
 /** 邮箱管理 */
 @RequestMapping("/user/sendEmaillist")
 public String querySendEmailMsgList(
     Model model,
     HttpServletRequest request,
     @ModelAttribute("userEmailMsg") UserEmailMsg userEmailMsg,
     @ModelAttribute("page") PageEntity page) {
   try {
     this.setPage(page);
     this.getPage().setPageSize(10);
     List<UserEmailMsg> list =
         userEmailMsgService.queryUserEmailMsgList(userEmailMsg, this.getPage());
     model.addAttribute("list", list);
     model.addAttribute("page", this.getPage());
   } catch (Exception e) {
     logger.error("querySendEmailMsgList", e);
   }
   return sendEmailMsgList;
 }
Ejemplo n.º 4
0
  /** 修改定时未发送的邮件 */
  @RequestMapping("/sendEmailMsg/update")
  @ResponseBody
  public Object updateSendEmailMsgInfo(HttpServletRequest request, UserEmailMsg userEmailMsg) {
    try {
      String sendTime = request.getParameter("sendTime");
      if ("".equals(sendTime)) {
        this.setJson(false, "请输入发送时间", "");
        return json;
      }
      SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      Date sendtime = formatDate.parse(sendTime);
      if (!sendtime.after(new Date())) {
        this.setJson(false, "定时发送的时间要大于当前日期", "");
        return json;
      }

      userEmailMsgService.updateUserEmailMsgById(userEmailMsg);
      this.setJson(true, "成功", "");
    } catch (Exception e) {
      logger.error("querySendMobleMsgInfo", e);
    }
    return json;
  }
Ejemplo n.º 5
0
  /**
   * 发送邮件
   *
   * @param request
   * @return
   */
  @RequestMapping("/user/sendEmailMsg")
  @ResponseBody
  public Map<String, Object> sendEmailMsg(HttpServletRequest request) {
    try {
      String linksman = request.getParameter("linksman"); // 获取联系人
      String title = request.getParameter("title"); // 获取标题
      String content = request.getParameter("content"); // 获取内容

      int type = Integer.valueOf(request.getParameter("type")); // 邮件类型
      String startTime = request.getParameter("startTime"); // 发送时间
      Date starttime = new Date();
      // 如果是定时短信发送时间要大于当前时间
      if (type == 2) {
        if ("".equals(startTime)) {
          this.setJson(false, "请输入发送时间", "");
          return json;
        }
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        starttime = formatDate.parse(startTime);
        if (!starttime.after(new Date())) {
          this.setJson(false, "定时发送的时间要大于当前日期", "");
          return json;
        }
      }

      if (StringUtils.isNotEmpty(linksman)
          && StringUtils.isNotEmpty(content)
          && StringUtils.isNotEmpty(title)) {
        // 验证邮箱
        Map<String, Object> returnMap = checkEmail(linksman);
        // 错误信息
        String errorEmail = returnMap.get("errorMessage").toString();
        if (Boolean.parseBoolean(returnMap.get("flag").toString()) == false) {
          this.setJson(false, errorEmail, "");
          return json;
        } else {
          JsonObject user = SingletonLoginUtils.getSysUser(request);
          List<UserEmailMsg> emailMsgList = new ArrayList<UserEmailMsg>();
          UserEmailMsg userEmailMsg = new UserEmailMsg();
          userEmailMsg.setId(0);
          userEmailMsg.setTitle(title);
          userEmailMsg.setContent(content);
          userEmailMsg.setEmail(returnMap.get("returnList").toString());
          userEmailMsg.setType(type);
          userEmailMsg.setSendTime(starttime);
          if (type == 1) {
            // 发送邮件
            userEmailMsgService.batchSendEmail(
                returnMap.get("returnList").toString().split(","), content, title, 3);
            // emailService.sendBatchMail(returnMap.get("returnList").toString().split(","),
            // content, title);
            userEmailMsg.setStatus(1);
          } else {
            userEmailMsg.setStatus(2);
          }
          if (ObjectUtils.isNotNull(user)) {
            userEmailMsg.setUserId(user.get("userId").getAsLong());
          } else {
            userEmailMsg.setUserId(0L);
          }
          userEmailMsg.setCreateTime(new Date());
          emailMsgList.add(userEmailMsg);
          userEmailMsgService.addUserEmailMsg(emailMsgList);
          errorEmail = "发送成功";
        }
        this.setJson(Boolean.parseBoolean(returnMap.get("flag").toString()), errorEmail, "");
      } else {
        this.setJson(false, "联系人、标题或内容不能为空", null);
      }
    } catch (Exception e) {
      logger.error("sendEmailMsg", e);
    }
    return json;
  }