コード例 #1
0
  /**
   * Description:进入注册页面<br>
   *
   * @author justin.xu
   * @version 0.1 2014年4月21日
   * @param request
   * @return ModelAndView
   */
  @RequestMapping(value = "/toRegister")
  public ModelAndView toRegister(HttpServletRequest request, HttpServletResponse response) {
    /** *** 微信站点首页域名 **** */
    final String WX_MAIN_URL = new String("http://m.gcjr.com/regist");
    // 判断是否需要重定向和跳转
    String ua = currentRequest().getHeader("User-Agent");
    String inviterName = null;
    String realName = null; // 显示真实姓名
    ModelAndView mv = new ModelAndView("member/userRegiste");
    String userIdMD5 = request.getParameter("code");
    String redId = request.getParameter("redId");
    // 如果来自内部推广,则判断该链接的有效性,即邀请人是否存在
    if (userIdMD5 != null && !StringUtils.isEmpty(userIdMD5)) {
      MemberCnd memberCnd = new MemberCnd();
      memberCnd.setUserIdMD5(userIdMD5);
      MemberVo memberVo = memberService.queryMemberByCnd(memberCnd);
      RealNameApproVo vo = realNameApproMapper.getByUserId(memberVo.getId());
      if (vo != null && !StringUtils.isEmpty(vo.getSecuritRealName())) {
        realName = vo.getSecuritRealName();
      }
      if (null != memberVo && !StringUtils.isEmpty(memberVo.getUsername())) {
        inviterName = memberVo.getUsername();
      }
    }

    if (isMobileTerminal(ua)) {
      return redirect(WX_MAIN_URL)
          .addObject("inviterName", CharacterEncoder.encodeURL(inviterName, "UTF-8"))
          .addObject("realName", CharacterEncoder.encodeURL(realName, "UTF-8"))
          .addObject("redId", CharacterEncoder.encodeURL(redId, "UTF-8"));
    }
    CookieGenerator cookieGenerator = new CookieGenerator();
    cookieGenerator.setCookieMaxAge(30 * 24 * 60 * 60);
    String tid = request.getParameter("tid"); // 如果来源于易瑞特,则为必有参数
    if (null != tid) {
      cookieGenerator.setCookieName("tid");
      cookieGenerator.addCookie(response, tid);
      request.getSession().setAttribute("tid", tid);
    }

    String extendLinkSourceName = request.getParameter("source"); // 链接来源
    if (!StringUtils.isEmpty(extendLinkSourceName)) {
      String linkSourceValue = Dictionary.getValue(1100, extendLinkSourceName.trim());
      request.getSession().setAttribute("linkSourceValue", linkSourceValue);
    }
    return mv.addObject("inviterName", inviterName)
        .addObject("realName", realName)
        .addObject("redId", CharacterEncoder.encodeURL(redId, "UTF-8"));
  }
コード例 #2
0
  /** 推广注册2 */
  @RequestMapping(
      value = "/registMemberInfoCollectJson",
      produces = {"text/plain;charset=UTF-8"})
  @ResponseBody
  public String registMemberInfoCollectJson(
      Member member,
      HttpServletRequest request,
      HttpSession session,
      HttpServletResponse response) {
    member.setUsername(CharacterEncoder.decodeURL(member.getUsername(), "UTF-8"));

    MessageBox box = null;

    if (StringUtils.isEmpty(member.getUsername())) {
      box = MessageBox.build("0", "用户名不能为空");
    } else if (verifyUserNameLength(member)) {
      box = MessageBox.build("0", "用户名称长度应该位于2~16位之间");
    } else if (!VerifyContainSpecialChar.isContainSpecialChars(member.getUsername())) {
      box = MessageBox.build("0", "用户名包含特殊字符串");
    } else if (memberRegisterService.existsContainSensitiveForUserName(
        member.getUsername().replaceAll(" ", ""))) {
      box = MessageBox.build("0", "注册用户名包含敏感词");
    } else {
      box = registMemberInfo(member, request, session, response);
    }

    return JsonUtils.bean2Json(box);
  }