コード例 #1
0
 @RequestMapping(value = "/topic/search*.jhtml")
 public String searchSubmit(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   FrontUtils.frontData(request, model, site);
   String keywords = RequestUtils.getQueryParam(request, "keywords");
   String forumIdStr = RequestUtils.getQueryParam(request, "forumId");
   Integer forumId = 0;
   if (forumIdStr != null && StringUtils.isNotBlank(forumIdStr)) {
     forumId = Integer.parseInt(forumIdStr);
   }
   model.put("keywords", keywords);
   model.put("forumId", forumId);
   FrontUtils.frontPageData(request, model);
   return FrontUtils.getTplPath(request, site, TPLDIR_SPECIAL, SEARCH_RESULT);
 }
コード例 #2
0
  @RequestMapping(value = "/register.jspx", method = RequestMethod.POST)
  public String submit(
      String username,
      String email,
      String password,
      BbsUserExt userExt,
      String captcha,
      String nextUrl,
      HttpServletRequest request,
      HttpServletResponse response,
      ModelMap model)
      throws IOException {
    CmsSite site = CmsUtils.getSite(request);
    BbsConfig config = bbsConfigMng.findById(site.getId());
    WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    String ip = RequestUtils.getIpAddr(request);
    Integer groupId = null;
    BbsUserGroup group = bbsConfigMng.findById(site.getId()).getRegisterGroup();
    if (group != null) {
      groupId = group.getId();
    }
    BbsUser user = null;
    if (config.getEmailValidate()) {
      EmailSender sender = configMng.getEmailSender();
      MessageTemplate msgTpl = configMng.getRegisterMessageTemplate();
      if (sender == null) {
        // 邮件服务器没有设置好
        model.addAttribute("status", 4);
      } else if (msgTpl == null) {
        // 邮件模板没有设置好
        model.addAttribute("status", 5);
      } else {
        try {
          user =
              bbsUserMng.registerMember(
                  username, email, password, ip, groupId, userExt, false, sender, msgTpl);
          bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
          model.addAttribute("status", 0);
        } catch (Exception e) {
          // 发送邮件异常
          model.addAttribute("status", 100);
          model.addAttribute("message", e.getMessage());
          log.error("send email exception.", e);
        }
      }
      log.info("member register success. username={}", username);
      if (!StringUtils.isBlank(nextUrl)) {
        response.sendRedirect(nextUrl);
        return null;
      } else {
        FrontUtils.frontData(request, model, site);
        FrontUtils.frontPageData(request, model);
        return FrontUtils.getTplPath(
            request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_RESULT);
      }
    } else {
      user = bbsUserMng.registerMember(username, email, password, ip, groupId, userExt);
      bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
      log.info("member register success. username={}", username);
      FrontUtils.frontData(request, model, site);
      FrontUtils.frontPageData(request, model);
      model.addAttribute("success", true);
      return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, LOGIN_INPUT);
    }

    /*
     * BbsUser user = bbsUserMng.registerMember(username, email, password,
     * ip, groupId, userExt);
     */
  }