Exemplo n.º 1
0
  /**
   * @Description: 会员注册
   *
   * @param @param paramBean
   * @param @param request
   * @param @param response
   * @return void
   * @throws
   * @author Harrisson
   * @date 2015-5-16 下午1:59:10
   */
  @ResponseBody
  @RequestMapping(value = "/UserRegister", method = RequestMethod.POST)
  public void userRegister(
      @RequestBody Member members, HttpServletRequest request, HttpServletResponse response) {
    Map<String, Object> map = new HashMap<String, Object>();

    try {
      map.put("UserName", members.getUsername());
      map.put("Question", members.getQuestion());
      map.put("Answer", members.getAnswer());
      map.put("Password", MD5.MD5(members.getPassword()));
      map.put("memberId", RandomIDUtil.genUUID());
      if (!memberService.checkUserName(members.getUsername())) {

        Member member = memberService.userRegister(map);
        if (member != null) {
          printJsonSingle(SEND_OK, SEND_OK_MSG, member, request, response);
        } else {
          printJsonSingle(SEND_FAIL, "注册失败,请检查注册信息是否正确", null, request, response);
        }
      } else {
        printJsonSingle(SEND_FAIL, "注册失败,该用户名已存在", null, request, response);
      }
    } catch (Exception e) {
      e.printStackTrace();
      try {
        log.error("UserRegister:" + e.getMessage());
        printJsonSingle(SEND_FAIL, CATCH_CHECK, null, request, response);
      } catch (IOException e1) {
      }
    }
  }
Exemplo n.º 2
0
 /**
  * @Description: 账号登陆
  *
  * @param @param paramBean
  * @param @param request
  * @param @param response
  * @return void
  * @throws
  * @author Harrisson
  * @date 2015-5-16 下午1:14:55
  */
 @ResponseBody
 @RequestMapping(value = "/Login", method = RequestMethod.POST)
 public void login(
     @RequestBody Member members, HttpServletRequest request, HttpServletResponse response) {
   Map<String, Object> map = new HashMap<String, Object>();
   try {
     map.put("UserName", members.getUsername());
     map.put("Password", MD5.MD5(members.getPassword()));
     Member member = memberService.login(map);
     if (member != null) {
       printJsonSingle(SEND_OK, SEND_OK_MSG, member, request, response);
     } else {
       printJsonSingle(SEND_FAIL, "登录失败,请检查账号或密码是否正确", null, request, response);
     }
   } catch (Exception e) {
     e.printStackTrace();
     try {
       log.error("Login:" + e.getMessage());
       printJsonSingle(SEND_FAIL, CATCH_CHECK, null, request, response);
     } catch (IOException e1) {
     }
   }
 }