Пример #1
0
  @ResponseBody
  @RequestMapping(value = "/user/cinfo.htm", method = RequestMethod.POST)
  public BizResponse cinfo(String no, String unick) {
    this.setWebData("no", no);

    // 操作结果
    BizResponse response = this.newBizResponse();

    try {
      // 查找
      UserModel user = this.userService.findByNo(no);
      if (user == null) {
        this.buildResponse(response, BizResponseEnum.OBJECT_NOT_EXIST);
        return response;
      }

      // 长度
      unick = StringUtils.trimToEmpty(unick);
      user.setNickName(TextUtils.truncate(unick, DAS.USER.NICK_NAME_MAX));

      // 更新
      this.userService.update(user);
    } catch (Exception e) {
      logger.error("修改登录用户基本信息异常!", e);
      this.buildResponse(response, BizResponseEnum.SYSTEM_ERROR);
    }

    // JSON返回
    return response;
  }
Пример #2
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;
  }