Skip to content

Commit

Permalink
[feat] 닉네임 중복검사 API
Browse files Browse the repository at this point in the history
  • Loading branch information
ksj000625 committed Dec 7, 2024
1 parent b038b92 commit 2cb7b6a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import site.billbill.apiserver.api.auth.dto.request.*;
import site.billbill.apiserver.api.auth.dto.response.NicknameResponse;
import site.billbill.apiserver.api.auth.service.AuthService;
import site.billbill.apiserver.api.auth.service.OAuthService;
import site.billbill.apiserver.api.users.service.UserService;
import site.billbill.apiserver.common.response.BaseResponse;
import site.billbill.apiserver.common.utils.jwt.dto.JwtDto;

Expand All @@ -30,6 +32,7 @@ public class AuthController {

private final AuthService authService;
private final OAuthService oAuthService;
private final UserService userService;

@Operation(summary = "회원 가입(일반)", description = "일반 회원 가입 API")
@ResponseStatus(HttpStatus.CREATED)
Expand Down Expand Up @@ -64,4 +67,14 @@ public BaseResponse<JwtDto> kakaoCallback(@RequestParam("code") String code) {
public BaseResponse<JwtDto> identity(@RequestBody IdentityVerificationRequest request) {
return null;
}

@Operation(summary = "닉네임 중복검사", description = "닉네임 중복검사")
@ResponseStatus(HttpStatus.OK)
@GetMapping("/nickname")
public BaseResponse<NicknameResponse> getNicknameValidity(@RequestParam String nickname) {
return new BaseResponse<>(NicknameResponse.builder()
.valid(authService.getNicknameValidity(nickname))
.build());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package site.billbill.apiserver.api.auth.dto.response;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class NicknameResponse {
private boolean valid;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface AuthService {
JwtDto reissue(String refreshToken);

boolean identifyUser(IdentityRequest request);

boolean getNicknameValidity(String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public boolean identifyUser(IdentityRequest request) {
return false;
}

@Override
public boolean getNicknameValidity(String nickname) {
return !userRepository.existsByNickname(nickname);
}

/**
* Method that if user is withdrawn
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
public interface UserRepository extends JpaRepository<UserJpaEntity, String>, UserDslRepository {
Optional<UserJpaEntity> findByUserIdAndWithdrawStatus(String userId, boolean withdrawStatus);
Optional<UserJpaEntity> findByProviderId(String providerId);
boolean existsByNickname(String nickname);
}

0 comments on commit 2cb7b6a

Please sign in to comment.