一坨代码的痛定思痛,我的眼睛真的近视 。(反思四)

一坨代码的痛定思痛,我的眼睛真的近视 。(反思四)

 

  @PostMapping("login")
  @ApiOperation("2022-08-06-客户账号登录")
  public Result<Map<String, Object>> login(@RequestBody LoginDTO login) {
    Result result = new Result();
    //表单校验
    ValidatorUtils.validateEntity(login);
    //用户信息
    MallShopAccountEntity mallShopAccount = mallShopAccountService.getMallShopAccountByUsername(login.getMobile().trim(), 1);

    //用户不存在
    if (mallShopAccount == null) {
      throw new SxbException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
    }

    if (mallShopAccount.getEnabled().equals(0)) {
      result.setMsg("该账号被禁用了,请联系后台管理人员!");
      result.setCode(ErrorCode.DATA_NOT_EXIST);
      return result;
    }

    MallShopEntity mallShopEntity = mallShopService.selectById(mallShopAccount.getShopId());
    if (null == mallShopEntity) {
      throw new SxbException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
    }
    // 客户类型id  0 是  1 是客户
    if (!mallShopEntity.getTradeTypeId().equals(1)) {
      throw new SxbException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
    }

    if (mallShopEntity.getAuditState().equals(0)) {
      result.setMsg("该客户还没审核,请联系后台管理人员!");
      result.setCode(ErrorCode.DATA_NOT_EXIST);
      return result;
    }

    if (mallShopEntity.getAuditState().equals(-1)) {
      result.setMsg("该客户审核不通过,请联系后台管理人员!");
      result.setCode(ErrorCode.DATA_NOT_EXIST);
      return result;
    }
    if (mallShopEntity.getEnabled().equals(0)) {
      result.setMsg("该客户被禁用了,请联系后台管理人员!");
      result.setCode(ErrorCode.DATA_NOT_EXIST);
      return result;
    }

    //密码错误
    if (!PasswordUtils.matches(login.getPassword().trim(), mallShopAccount.getPassword())) {
      throw new SxbException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
    }

    return mallShopTokenService.createCusToken(mallShopAccount.getId());
  }

f395e29c-e440-45af-ad91-73b4bc59b607

 

posted @ 2026-01-09 02:38  升鲜宝供应链管理系统  阅读(5)  评论(0)    收藏  举报