예제 #1
0
  @ResponseBody
  @RequestMapping(value = "/user/create.htm", method = RequestMethod.POST)
  public BizResponse create(String uname, String passwd, String passwd2, String uemail) {
    // 操作结果
    BizResponse response = this.newBizResponse();

    try {
      // 参数检查
      if (StringUtils.isBlank(uname)
          || StringUtils.isBlank(passwd)
          || StringUtils.isBlank(uemail)) {
        this.buildResponse(response, BizResponseEnum.REQUIRE_PARAM);
        return response;
      }

      if (!StringUtils.equals(passwd, passwd2)) {
        this.buildResponse(response, BizResponseEnum.INVALID_PASSWD);
        return response;
      }

      // 用户名检查
      UserModel user = this.userService.findByNickName(uname);
      if (user != null) {
        this.buildResponse(response, BizResponseEnum.EXIST_UNAME);
        return response;
      }

      // 电子邮箱检查
      // TODO:

      // 新建
      user = this.newInitUser();
      user.setNo(UserConverter.encode(this.userTicketService.nextValue()));
      user.setNickName(uname);
      user.setPasswd(MD5Utils.digest(passwd));
      user.setEmail(uemail);

      // 更新
      this.userService.create(user);
      response.getBizData().put(BizResponse.BIZ_ID_KEY, uname);
    } catch (Exception e) {
      logger.error("新增用户异常!", e);
      this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR);
    }

    // JSON返回
    return response;
  }
  /** 后台用户同步 */
  @ResponseBody
  @RequestMapping(value = "/admin/tick.html", method = RequestMethod.POST)
  public BizResponse bopsTick() {
    // 操作结果
    BizResponse response = this.newBizResponse();
    response.getBizData().put("stamp", DateUtils.toStringDL(new Date()));

    try {
      // response.getBizData().put("stamp", DateUtils.toStringDL(new Date()));
    } catch (Exception e) {
      logger.error("后台用户同步!", e);
      this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR);
    }

    // JSON返回
    return response;
  }