Ejemplo n.º 1
0
 // 激活账号
 @RequestMapping(value = "/active.jspx", method = RequestMethod.GET)
 public String active(
     String username,
     String key,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = validateActive(username, key, request, response);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   UnifiedUser user = unifiedUserMng.active(username, key);
   BbsUser bbsUser = bbsUserMng.findById(user.getId());
   String ip = RequestUtils.getIpAddr(request);
   authMng.activeLogin(user, ip, request, response, session);
   // 登录记录
   BbsLoginLog loginLog = new BbsLoginLog();
   loginLog.setIp(RequestUtils.getIpAddr(request));
   Calendar calendar = Calendar.getInstance();
   loginLog.setLoginTime(calendar.getTime());
   loginLog.setUser(bbsUser);
   bbsLoginMng.save(loginLog);
   // 在线时长统计
   BbsUserOnline online = bbsUser.getUserOnline();
   // 首次登陆
   online = new BbsUserOnline();
   online.setUser(bbsUser);
   online.initial();
   userOnlineMng.save(online);
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(
       request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_ACTIVE_SUCCESS);
 }
 @RequestMapping("/group/v_list.do")
 public String list(Integer pageNo, HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   List<BbsUserGroup> list = manager.getList(site.getId());
   model.addAttribute("list", list);
   model.addAttribute("groupType", 1);
   return "group/list";
 }
 @RequestMapping("/group/o_save.do")
 public String save(
     String[] name,
     String[] imgPath,
     Integer[] id,
     Long[] point,
     short groupType,
     HttpServletRequest request,
     ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   manager.saveOrUpdateGroups(site.getId(), groupType, name, imgPath, id, point);
   return "redirect:v_list.do";
 }
Ejemplo n.º 4
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);
 }
 @RequestMapping(value = "/group/v_tree.do")
 public String tree(
     String root,
     Integer groupId,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   log.debug("tree path={}", root);
   boolean isRoot;
   // jquery treeview的根请求为root=source
   if (StringUtils.isBlank(root) || "source".equals(root)) {
     isRoot = true;
   } else {
     isRoot = false;
   }
   model.addAttribute("isRoot", isRoot);
   WebErrors errors = validateTree(root, request);
   if (errors.hasErrors()) {
     log.error(errors.getErrors().get(0));
     ResponseUtils.renderJson(response, "[]");
     return null;
   }
   CmsSite site = CmsUtils.getSite(request);
   BbsUserGroup group = manager.findById(groupId);
   Integer[] postTypeIds = group.fetchIds(group.getPostTypes());
   if (isRoot) {
     List<BbsForum> list;
     list = bbsForumMng.getList(site.getId());
     model.addAttribute("list", list);
   } else {
     List<BbsPostType> list;
     Integer parentId;
     if (StringUtils.isNotBlank(root) && root.contains(",")) {
       parentId = Integer.valueOf(root.split(",")[0]);
       list = bbsPostTypeMng.getList(site.getId(), null, parentId);
     } else {
       parentId = Integer.valueOf(root);
       list = bbsPostTypeMng.getList(site.getId(), parentId, null);
     }
     model.addAttribute("list", list);
   }
   model.put("postTypeIds", postTypeIds);
   response.setHeader("Cache-Control", "no-cache");
   response.setContentType("text/json;charset=UTF-8");
   return "group/tree";
 }
 @RequestMapping("/group/v_edit.do")
 public String edit(
     Integer groupId,
     short groupType,
     Integer pageNo,
     HttpServletRequest request,
     ModelMap model) {
   BbsUserGroup group = manager.findById(groupId);
   CmsSite site = CmsUtils.getSite(request);
   List<BbsPostType> postTypes = bbsPostTypeMng.getList(CmsUtils.getSiteId(request), null, null);
   List<BbsPostType> tempList;
   Map<String, List<BbsPostType>> childPostTypes = new HashMap<String, List<BbsPostType>>();
   for (BbsPostType parent : postTypes) {
     tempList = bbsPostTypeMng.getList(site.getId(), null, parent.getId());
     childPostTypes.put(parent.getId().toString(), tempList);
   }
   model.put("childPostTypes", childPostTypes);
   model.put("postTypes", postTypes);
   model.put("bbsUserGroup", group);
   model.put("groupType", groupType);
   return "group/edit";
 }
Ejemplo n.º 7
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);
     */
  }
Ejemplo n.º 8
0
 @RequestMapping(value = "/register.jspx", method = RequestMethod.GET)
 public String input(HttpServletRequest request, HttpServletResponse response, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER);
 }