@Override
  public ServiceResult send(String toMailAddr, String subject, String content, Integer mailType) {
    ServiceResult result = new ServiceResult(false);
    MimeMessage mailMessage = mailSender.createMimeMessage();
    // 设置utf-8或GBK编码,否则邮件会有乱码
    MimeMessageHelper messageHelper = null;
    // 设置邮件参数
    SystemConfig systemConfig = systemConfigDAO.load(1);
    try {
      messageHelper = new MimeMessageHelper(mailMessage, true, "utf-8");
      messageHelper.setFrom(
          systemConfig.getEmailCode(),
          systemConfig.getCompanyName()); // 发送者,这里还可以另起Email别名,不用和xml里的username一致
      messageHelper.setTo(toMailAddr); // 接受者
      messageHelper.setSubject(subject); // 主题
      messageHelper.setText(content, true); // 邮件内容
      mailSender.send(mailMessage);
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
    }

    MailsHistory mailsHistory = new MailsHistory();
    mailsHistory.setTitle(subject);
    mailsHistory.setContent(content);
    mailsHistory.setReceiveIDs(toMailAddr);
    mailsHistory.setMailType(mailType);
    mailsHistoryDAO.save(mailsHistory);

    result.setIsSuccess(true);
    return result;
  }
Beispiel #2
0
 /**
  * @Description: 学生端展示大赛章程 @Created Time: 2013-6-18 上午11:26:18 @Author lys
  *
  * @return
  */
 public String initCompetitionRule() {
   String competitionId = getParameter("competitionId");
   String content = informationService.initCompetitionRule(competitionId);
   SystemConfig systemConfig = systemConfigDAO.load(1);
   request.setAttribute("content", content);
   request.setAttribute("systemConfig", systemConfig);
   return SUCCESS;
 }
Beispiel #3
0
 /**
  * @Description: 初始化赛事公告 @Created Time: 2013-6-18 上午11:18:42 @Author lys
  *
  * @return
  */
 public String initNotice() {
   String competitionId = getParameter("competitionId");
   Map<String, Object> map =
       informationService.initNotice(competitionId, page, GobelConstants.DEFAULTPAGESIZE);
   SystemConfig systemConfig = systemConfigDAO.load(1);
   request.setAttribute("noticeList", map.get("noticeList"));
   request.setAttribute("total", map.get("total"));
   request.setAttribute("currPage", page);
   request.setAttribute("systemConfig", systemConfig);
   return SUCCESS;
 }
Beispiel #4
0
 /**
  * @Description: 赛事公告明细 @Created Time: 2013-6-18 上午11:19:11 @Author lys
  *
  * @return
  */
 public String noticeDetail() {
   String competitionId = getParameter("competitionId");
   request.removeAttribute("content");
   Information information;
   information = informationService.getInformationById(competitionId, model.getInformationId());
   SystemConfig systemConfig = systemConfigDAO.load(1);
   if (information != null) {
     request.setAttribute("content", information.getContent());
     request.setAttribute("informationTitle", information.getInformationTitle());
   }
   request.setAttribute("systemConfig", systemConfig);
   return SUCCESS;
 }
  public String init() {

    Integer competitionId = Integer.parseInt(getParameter("competitionId"));
    String competitionGroupId = getParameter("competitionGroupId");
    Map<String, Object> map =
        competitionPrizeStudentService.init(
            competitionId, competitionGroupId, page, GobelConstants.DEFAULTPAGESIZE);
    SystemConfig systemConfig = systemConfigDAO.load(1);
    request.setAttribute("competitionPrizeStudentList", map.get("competitionPrizeStudentList"));
    request.setAttribute("total", map.get("total"));
    request.setAttribute("currPage", page);
    request.setAttribute("competitionGroupList", map.get("competitionGroupList"));
    request.setAttribute("systemConfig", systemConfig);
    return SUCCESS;
  }