From 2c2a8f1c8cdc6022d2ff393f8a20e589fb98af6f Mon Sep 17 00:00:00 2001 From: jun02160 Date: Sat, 24 Feb 2024 01:38:13 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[FEAT]=20User=20=ED=99=88=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20=EC=B2=AB=20=EC=A7=84=EC=9E=85=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84=20#125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/qna/QnAController.java | 6 +++++ .../dto/response/FirstEntryResponseDto.java | 22 +++++++++++++++++++ .../org/umbba/api/service/qna/QnAService.java | 11 ++++++++++ .../umbba/common/exception/SuccessType.java | 1 + .../org/umbba/domain/domain/user/User.java | 6 +++++ 5 files changed, 46 insertions(+) create mode 100644 umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java index 27918114..c40c487c 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java @@ -100,4 +100,10 @@ public ApiResponse getMyUserInfo(Principal principal) { return ApiResponse.success(SuccessType.GET_MY_USER_INFO_SUCCESS, qnAService.getUserInfo(getUserFromPrincial(principal))); } + @PatchMapping("/user/first") + @ResponseStatus(HttpStatus.OK) + public ApiResponse firstEntry(Principal principal) { + return ApiResponse.success(SuccessType.GET_USER_FIRST_ENTRY_SUCCESS, qnAService.updateUserFirstEntry(getUserFromPrincial(principal))); + } + } diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java new file mode 100644 index 00000000..7a83dd24 --- /dev/null +++ b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java @@ -0,0 +1,22 @@ +package sopt.org.umbba.api.controller.qna.dto.response; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +import lombok.Builder; +import lombok.Getter; +import sopt.org.umbba.domain.domain.user.User; + +@Getter +@Builder +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class FirstEntryResponseDto { + + private Boolean isFirstEntry; + + public static FirstEntryResponseDto of(User user) { + return FirstEntryResponseDto.builder() + .isFirstEntry(user.isFirstEntry()) + .build(); + } +} diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java index 9da16c57..d7432a8c 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java @@ -345,6 +345,8 @@ else if (childList.get(3) != YES || parentList.get(3) != YES) { // 메인페이지 정보 public GetMainViewResponseDto getMainInfo(Long userId) { + // updateUserFirstEntry(userId); + Parentchild parentchild = getParentchild(userId); List qnaList = getQnAListByParentchild(parentchild); @@ -359,6 +361,15 @@ public GetMainViewResponseDto getMainInfo(Long userId) { return GetMainViewResponseDto.of(currentQnA, parentchild.getCount()); } + @Transactional + public FirstEntryResponseDto updateUserFirstEntry(Long userId) { + User user = getUserById(userId); + if (user.isFirstEntry()) { + user.updateIsFirstEntry(); + } + return FirstEntryResponseDto.of(user); + } + @Transactional public void restartQna(Long userId) { Parentchild parentchild = getParentchild(userId); diff --git a/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java b/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java index e68ab841..d2245788 100644 --- a/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java +++ b/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java @@ -28,6 +28,7 @@ public enum SuccessType { GET_MY_USER_INFO_SUCCESS(HttpStatus.OK, "마이페이지 내 정보 조회에 성공했습니다."), TEST_SUCCESS(HttpStatus.OK, "데모데이 테스트용 API 호출에 성공했습니다."), RESTART_QNA_SUCCESS(HttpStatus.OK, "7일 이후 문답이 정상적으로 시작되었습니다."), + GET_USER_FIRST_ENTRY_SUCCESS(HttpStatus.OK, "7일 이후 문답이 정상적으로 시작되었습니다."), /** diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java index 91db80bf..db21a35f 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java @@ -89,6 +89,8 @@ public void updateFcmToken(String fcmToken) { private boolean deleted = Boolean.FALSE; + private boolean isFirstEntry = Boolean.TRUE; + // 로그인 새롭게 할 때마다 해당 필드들 업데이트 public void updateSocialInfo(String socialNickname, String socialProfileImage, String socialAccessToken/*, String socialRefreshToken*/) { this.socialNickname = socialNickname; @@ -103,6 +105,10 @@ public void updateOnboardingInfo(String name, String gender, Integer bornYear) { this.bornYear = bornYear; } + public void updateIsFirstEntry() { + this.isFirstEntry = false; + } + public void deleteSocialInfo() { this.socialPlatform = SocialPlatform.WITHDRAW; this.socialNickname = null; From b6496e254c3203f6167c42147376a822bab983d5 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Sat, 24 Feb 2024 02:10:06 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[FEAT]=20=EC=B2=AB=20=ED=8A=9C=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=EC=96=BC=20=EC=A7=88=EB=AC=B8=20=EB=8B=B5=EB=B3=80=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=9D=91=EB=8B=B5=20=EC=BC=80=EC=9D=B4?= =?UTF-8?q?=EC=8A=A4=20=EC=B6=94=EA=B0=80=20#125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/GetInvitationResponseDto.java | 16 ++++++++++++++- .../org/umbba/api/service/qna/QnAService.java | 20 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/GetInvitationResponseDto.java b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/GetInvitationResponseDto.java index 5c61e0da..29490bf8 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/GetInvitationResponseDto.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/GetInvitationResponseDto.java @@ -10,7 +10,7 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class GetInvitationResponseDto { - private int responseCase; // case를 1,2,3으로 구분 (Client) + private int responseCase; // case를 1,2,3,4으로 구분 (Client) // 예외상황에 따른 필드 private String inviteCode; @@ -19,12 +19,15 @@ public class GetInvitationResponseDto { private Boolean relativeUserActive; + private Boolean isUserFirstAnswer; + // 1. 오늘의 질문을 조회한 일반적인 경우 public static GetInvitationResponseDto of () { return GetInvitationResponseDto.builder() .responseCase(1) .relativeUserActive(true) + .isUserFirstAnswer(true) .build(); } @@ -36,6 +39,7 @@ public static GetInvitationResponseDto of (String inviteCode, String inviteUsern .inviteUsername(inviteUsername) .installUrl(installUrl) .relativeUserActive(true) + .isUserFirstAnswer(true) .build(); } @@ -44,6 +48,16 @@ public static GetInvitationResponseDto of (boolean relativeUserActive) { return GetInvitationResponseDto.builder() .responseCase(3) .relativeUserActive(relativeUserActive) + .isUserFirstAnswer(true) + .build(); + } + + // 4. 아직 첫 질문에 답변하지 않은 경우 + public static GetInvitationResponseDto ofFirst (boolean isUserFirstAnswer) { + return GetInvitationResponseDto.builder() + .responseCase(4) + .relativeUserActive(true) + .isUserFirstAnswer(isUserFirstAnswer) .build(); } } diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java index d7432a8c..5d759314 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java @@ -66,7 +66,10 @@ public GetInvitationResponseDto getInvitation(Long userId) { log.info("matchUser: {} -> parentchildDao.findMatchUserByUserId()의 결과", matchUser); // 유저의 상태에 따른 분기처리 - if (matchUser.isEmpty()) { + if (!checkFirstAnswerCompleted(userId)) { + return firstTutorialQnA(); + } + else if (matchUser.isEmpty()) { return invitation(userId); } else if (matchUser.get().getUsername() == null) { @@ -78,6 +81,17 @@ else if (matchUser.get().getSocialPlatform().equals(SocialPlatform.WITHDRAW)) { return GetInvitationResponseDto.of(); } + private boolean checkFirstAnswerCompleted(Long userId) { + User user = getUserById(userId); + QnA firstQnA = user.getParentChild().getQnaList().get(0); + + if (user.isMeChild() && firstQnA.isChildAnswer()) { + return true; + } else if (!user.isMeChild() && firstQnA.isParentAnswer()) { + return true; + } + return false; + } @Transactional public void answerTodayQuestion(Long userId, TodayAnswerRequestDto request) { @@ -447,6 +461,10 @@ private GetInvitationResponseDto withdrawUser() { return GetInvitationResponseDto.of(false); } + private GetInvitationResponseDto firstTutorialQnA() { + return GetInvitationResponseDto.ofFirst(false); + } + /** * 데모데이 테스트용 메서드 From 0737e30779b8b09ce8ee438bc21f15143891601f Mon Sep 17 00:00:00 2001 From: jun02160 Date: Sat, 24 Feb 2024 02:45:25 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[FIX]=20=EC=B2=AB=20=EC=A7=84=EC=9E=85=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD=20#125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/umbba/api/controller/qna/QnAController.java | 2 +- .../controller/qna/dto/response/FirstEntryResponseDto.java | 4 ++-- .../java/sopt/org/umbba/api/service/qna/QnAService.java | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java index c40c487c..9a1c7b78 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/QnAController.java @@ -100,7 +100,7 @@ public ApiResponse getMyUserInfo(Principal principal) { return ApiResponse.success(SuccessType.GET_MY_USER_INFO_SUCCESS, qnAService.getUserInfo(getUserFromPrincial(principal))); } - @PatchMapping("/user/first") + @PatchMapping("/home/first") @ResponseStatus(HttpStatus.OK) public ApiResponse firstEntry(Principal principal) { return ApiResponse.success(SuccessType.GET_USER_FIRST_ENTRY_SUCCESS, qnAService.updateUserFirstEntry(getUserFromPrincial(principal))); diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java index 7a83dd24..21d95062 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/controller/qna/dto/response/FirstEntryResponseDto.java @@ -14,9 +14,9 @@ public class FirstEntryResponseDto { private Boolean isFirstEntry; - public static FirstEntryResponseDto of(User user) { + public static FirstEntryResponseDto of(boolean isFirstEntry) { return FirstEntryResponseDto.builder() - .isFirstEntry(user.isFirstEntry()) + .isFirstEntry(isFirstEntry) .build(); } } diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java index 5d759314..5bdf0e54 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/qna/QnAService.java @@ -378,10 +378,11 @@ public GetMainViewResponseDto getMainInfo(Long userId) { @Transactional public FirstEntryResponseDto updateUserFirstEntry(Long userId) { User user = getUserById(userId); - if (user.isFirstEntry()) { - user.updateIsFirstEntry(); + if (!user.isFirstEntry()) { + return FirstEntryResponseDto.of(false); } - return FirstEntryResponseDto.of(user); + user.updateIsFirstEntry(); + return FirstEntryResponseDto.of(true); } @Transactional From 35eb7492821794fec8562ada268b72ba43e07a30 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Sat, 24 Feb 2024 12:36:53 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[FIX]=20isFirstEntry=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20default=20?= =?UTF-8?q?=EA=B0=92=20=EC=A0=81=EC=9A=A9=20#125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../umbba/api/service/user/AuthService.java | 1 + .../org/umbba/domain/domain/user/User.java | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java b/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java index e72c3164..8a2a4682 100644 --- a/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java +++ b/umbba-api/src/main/java/sopt/org/umbba/api/service/user/AuthService.java @@ -56,6 +56,7 @@ public UserLoginResponseDto login(String socialAccessToken, SocialLoginRequestDt .isMeChild(true) .isMatchFinish(false) .fcmToken(request.getFcmToken()) + .isFirstEntry(true) .build(); userRepository.save(user); diff --git a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java index db21a35f..36334cf0 100644 --- a/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java +++ b/umbba-domain/src/main/java/sopt/org/umbba/domain/domain/user/User.java @@ -1,15 +1,32 @@ package sopt.org.umbba.domain.domain.user; -import lombok.*; -import lombok.extern.slf4j.Slf4j; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.ConstraintMode; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.ForeignKey; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import sopt.org.umbba.domain.domain.common.AuditingTimeEntity; import sopt.org.umbba.domain.domain.parentchild.Parentchild; -import javax.persistence.*; -import java.util.List; - @Slf4j @Entity @Table(name = "`User`") From 16d00d34eaa788e9309397dfd6781fa91f7967f7 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Sat, 24 Feb 2024 12:47:58 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[CHORE]=20=EC=84=B1=EA=B3=B5=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=AF=B8=EB=B0=98?= =?UTF-8?q?=EC=98=81=20=EC=82=AC=ED=95=AD=20=EC=A0=81=EC=9A=A9=20#125?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/sopt/org/umbba/common/exception/SuccessType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java b/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java index d2245788..14760146 100644 --- a/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java +++ b/umbba-common/src/main/java/sopt/org/umbba/common/exception/SuccessType.java @@ -28,7 +28,7 @@ public enum SuccessType { GET_MY_USER_INFO_SUCCESS(HttpStatus.OK, "마이페이지 내 정보 조회에 성공했습니다."), TEST_SUCCESS(HttpStatus.OK, "데모데이 테스트용 API 호출에 성공했습니다."), RESTART_QNA_SUCCESS(HttpStatus.OK, "7일 이후 문답이 정상적으로 시작되었습니다."), - GET_USER_FIRST_ENTRY_SUCCESS(HttpStatus.OK, "7일 이후 문답이 정상적으로 시작되었습니다."), + GET_USER_FIRST_ENTRY_SUCCESS(HttpStatus.OK, "유저의 첫 진입여부 조회에 성공했습니다."), /**