Skip to content

Commit

Permalink
[fix][#93] 온보딩 상태 조회 & 온보딩 상태 업데이트 api 리턴값, 요청값 불린으로 하게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-june-young committed Aug 30, 2024
1 parent b3d17c9 commit bb13a18
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ResponseEntity<Void> updateMemberOnboardStatus(
@AuthUser User user,
@RequestBody UserOnboardStatusUpdateRequest request
) {
userService.updateUserOnboardStatus(user, request.onboardStatus());
userService.updateUserOnboardStatus(user, request.isOnboardComplete());
return ResponseEntity.ok(null);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.server.bbo_gak.domain.user.dto.request;

public record UserOnboardStatusUpdateRequest(String onboardStatus) {
public record UserOnboardStatusUpdateRequest(Boolean isOnboardComplete) {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.server.bbo_gak.domain.user.dto.response;

public record UserOnboardStatusGetResponse(
String onboardStatus
Boolean isOnboardComplete
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
@Getter
@AllArgsConstructor
public enum OnboardStatus {
NOT_STARTED("온보딩_미완료"),
COMPLETED("온보딩_완료");
NOT_STARTED(false),
COMPLETED(true);

private final String value;
private final Boolean value; // 온보딩 수행 여부 (true면 온보딩 완료)

public static OnboardStatus findByValue(String value) {
public static OnboardStatus findByValue(Boolean isOnboardComplete) {
return Arrays.stream(OnboardStatus.values())
.filter(onboardStatus -> onboardStatus.getValue().equals(value))
.filter(onboardStatus -> onboardStatus.getValue().equals(isOnboardComplete))
.findFirst()
.orElseThrow((() -> new NotFoundException(ErrorCode.ONBOARD_STATUS_NOT_FOUND)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface UserService {

void updateUserJob(User user, String job);

void updateUserOnboardStatus(User user, String onboardStatus);
void updateUserOnboardStatus(User user, Boolean isOnboardComplete);

void getUser();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void updateUserJob(User user, String job) {
}

@Transactional
public void updateUserOnboardStatus(User user, String onboardStatus){
user.updateOnboardStatus(OnboardStatus.findByValue(onboardStatus));
public void updateUserOnboardStatus(User user, Boolean isOnboardComplete){
user.updateOnboardStatus(OnboardStatus.findByValue(isOnboardComplete));
userRepository.save(user);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public enum ErrorCode {
//User
USER_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 유저를 찾을 수 없습니다."),
JOB_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 직업을 찾을 수 없습니다"),
ONBOARD_STATUS_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 온보딩 상태를 찾을 수 없습니다"),
ONBOARD_STATUS_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 온보딩 상태를 찾을 수 없습니다. (잘못된 온보딩 상태를 입력하셨습니다)"),

//Image
IMAGE_FILE_EXTENSION_NOT_FOUND(HttpStatus.BAD_REQUEST, "지원하지 않는 파일 확장자입니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class 온보딩상태_조회 {
public void 성공_온보딩_완료_상태() throws Exception {

//given
UserOnboardStatusGetResponse response = new UserOnboardStatusGetResponse("온보딩_완료");
UserOnboardStatusGetResponse response = new UserOnboardStatusGetResponse(true);

//then
mockMvc.perform(restDocsFactory.createRequest(DEFAULT_URL + "/onboard-status", null, HttpMethod.GET,
Expand All @@ -64,7 +64,7 @@ class 온보딩상태_조회 {
public void 성공_온보딩_미완료_상태() throws Exception {

//given
UserOnboardStatusGetResponse response = new UserOnboardStatusGetResponse("온보딩_미완료");
UserOnboardStatusGetResponse response = new UserOnboardStatusGetResponse(false);

//then
mockMvc.perform(restDocsFactory.createRequest(DEFAULT_URL + "/onboard-status", null, HttpMethod.GET,
Expand All @@ -82,7 +82,7 @@ class 온보딩상태_업데이트 {
public void 성공() throws Exception {

//given
UserOnboardStatusUpdateRequest request = new UserOnboardStatusUpdateRequest("온보딩_완료");
UserOnboardStatusUpdateRequest request = new UserOnboardStatusUpdateRequest(true);

//then
mockMvc.perform(restDocsFactory.createRequest(DEFAULT_URL + "/onboard-status", request, HttpMethod.PUT,
Expand Down

0 comments on commit bb13a18

Please sign in to comment.