From 7c0ef7d1c72c15cdd82a83a2a699c15ebab950f6 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 17:14:52 +0900 Subject: [PATCH 01/12] =?UTF-8?q?refactor=20:=20=EB=8B=89=EB=84=A4?= =?UTF-8?q?=EC=9E=84=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dangjang/domain/user/controller/UserController.java | 3 ++- .../dangjang/domain/user/dto/request/SignUpRequest.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java b/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java index aec468a4..3287d81a 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java @@ -46,7 +46,8 @@ public class UserController { // TODO 전체 수정 (위치: signup, 이름: dup */ @GetMapping("/duplicateNickname") public ResponseEntity> checkDuplicateNickname( - @RequestParam @Pattern(regexp = "^[ㄱ-ㅎ가-힣a-zA-Z0-9]{1,8}$", message = "닉네임은 영어,한글,숫자 1~8글자 이내로 이루어져있어야 합니다.") @NotBlank(message = "닉네임은 1~8글자 이내여야 합니다.") String nickname) { + @RequestParam @Pattern(regexp = "^[가-힣ㄱ-ㅎㅏ-ㅣa-zA-Z0-9]{1,8}$", message = "닉네임은 영어,한글,숫자 1~8글자 이내로 이루어져있어야 합니다.") @NotBlank(message = "닉네임은 1~8글자 이내여야 합니다.") String nickname) { + System.out.println("닉네임 : " + nickname); DuplicateNicknameResponse duplicateNicknameResponse = userSignupService.checkDuplicatedNickname(nickname); return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), duplicateNicknameResponse)); } diff --git a/src/main/java/com/coniverse/dangjang/domain/user/dto/request/SignUpRequest.java b/src/main/java/com/coniverse/dangjang/domain/user/dto/request/SignUpRequest.java index 3e09668d..3bd8d25c 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/dto/request/SignUpRequest.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/dto/request/SignUpRequest.java @@ -18,7 +18,7 @@ public record SignUpRequest(@NotBlank(message = "oauth 접근 토큰은 필수로 입력해야 합니다.") String accessToken, @Pattern(regexp = "^[a-z]*$", message = "provider는 소문자여야 합니다.") @NotBlank(message = "oauth provider는 필수로 입력해야 합니다.") String provider, - @Pattern(regexp = "^[ㄱ-ㅎ가-힣a-zA-Z0-9]{1,8}$", message = "닉네임은 영어,한글,숫자 1~8글자 이내로 이루어져있어야 합니다.") String nickname, + @Pattern(regexp = "^[가-힣ㄱ-ㅎㅏ-ㅣa-zA-Z0-9]{1,8}$", message = "닉네임은 영어,한글,숫자 1~8글자 이내로 이루어져있어야 합니다.") String nickname, @NotNull(message = "성별은 필수로 입력해야 합니다.") Boolean gender, @NotNull(message = "생년월일은 필수로 입력해야 합니다.") @Past(message = "생년월일은 현재보다 과거이어야 합니다.") LocalDate birthday, From 56e6db2f6d5728d64da9acbcd59b276194378424 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:12:58 +0900 Subject: [PATCH 02/12] =?UTF-8?q?feat=20:=20=EA=B1=B4=EA=B0=95=EC=A7=80?= =?UTF-8?q?=ED=91=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=BC=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HealthMetricController.java | 18 ++++++++++++++++++ .../repository/HealthMetricRepository.java | 10 ++++++++++ .../service/HealthMetricSearchService.java | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java index cbf7342b..6cdf78d6 100644 --- a/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.coniverse.dangjang.domain.healthmetric.dto.HealthMetricLastDateResponse; import com.coniverse.dangjang.domain.healthmetric.dto.request.HealthMetricPatchRequest; import com.coniverse.dangjang.domain.healthmetric.dto.request.HealthMetricPostRequest; import com.coniverse.dangjang.domain.healthmetric.dto.response.HealthMetricChartResponse; @@ -22,6 +23,7 @@ import com.coniverse.dangjang.domain.healthmetric.exception.SameTypeException; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricChartSearchService; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricRegisterService; +import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricSearchService; import com.coniverse.dangjang.global.dto.SuccessSingleResponse; import com.coniverse.dangjang.global.validator.ValidLocalDate; @@ -41,6 +43,7 @@ public class HealthMetricController { private final HealthMetricRegisterService healthMetricRegisterService; private final HealthMetricChartSearchService healthMetricChartSearchService; + private final HealthMetricSearchService healthMetricSearchService; /** * HTTP POST METHOD @@ -85,4 +88,19 @@ public ResponseEntity> getHealt LocalDate.parse(endDate)); return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), response)); } + + /** + * 마지막 건강지표 생성일을 조회한다 + * + * @param principal 유저 정보 + * @return 유저의 마지막 건강지표 생성일 + * @since 1.1.0 + */ + + @GetMapping("/lastDate") + public ResponseEntity> getHealthMetricLastDate(@AuthenticationPrincipal User principal) { + String oauthId = principal.getUsername(); + HealthMetricLastDateResponse response = healthMetricSearchService.findHealthMetricLastDate(oauthId); + return ResponseEntity.ok(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), response)); + } } diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/repository/HealthMetricRepository.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/repository/HealthMetricRepository.java index b1cc7bdd..15251db9 100644 --- a/src/main/java/com/coniverse/dangjang/domain/healthmetric/repository/HealthMetricRepository.java +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/repository/HealthMetricRepository.java @@ -67,4 +67,14 @@ public interface HealthMetricRepository extends JpaRepository findLastWeekByGroupCodeAndCreatedAt(String oauthId, GroupCode groupCode, LocalDate startDate, LocalDate endDate); + + /** + * 사용자의 health metrics 마지막 생성일 조회 + * + * @param oauthId 사용자 ID + * @return CreatedAt + * @since 1.1.0 + */ + @Query("SELECT h.healthMetricId.createdAt FROM HealthMetric h WHERE h.healthMetricId.oauthId = ?1 ORDER BY h.healthMetricId.createdAt DESC LIMIT 1") + Optional findCreatedAtByOauthId(String oauthId); } diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchService.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchService.java index 8596a7a9..9137d0b2 100644 --- a/src/main/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchService.java +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchService.java @@ -8,6 +8,7 @@ import com.coniverse.dangjang.domain.code.enums.CommonCode; import com.coniverse.dangjang.domain.code.enums.GroupCode; +import com.coniverse.dangjang.domain.healthmetric.dto.HealthMetricLastDateResponse; import com.coniverse.dangjang.domain.healthmetric.entity.HealthMetric; import com.coniverse.dangjang.domain.healthmetric.exception.HealthMetricNotFoundException; import com.coniverse.dangjang.domain.healthmetric.repository.HealthMetricRepository; @@ -76,4 +77,17 @@ public List findWeeklyHealthMetricById(String oauthId, CommonCode public List findWeeklyHealthMetricByGroupCode(String oauthId, GroupCode code, LocalDate startDate, LocalDate endDate) { return healthMetricRepository.findLastWeekByGroupCodeAndCreatedAt(oauthId, code, startDate, endDate); } + + /** + * 유저의 마지막 건강 지표 생성일을 조회한다. + * + * @param oauthId 유저 아이디 + * @return HealthMetricLastDateResponse 유저의 마지막 건강 지표 생성일 + * @throws HealthMetricNotFoundException 유저의 건강 지표를 찾을 수 없을 경우 발생한다. + * @since 1.1.0 + */ + public HealthMetricLastDateResponse findHealthMetricLastDate(String oauthId) { + LocalDate lastDate = healthMetricRepository.findCreatedAtByOauthId(oauthId).orElseThrow(HealthMetricNotFoundException::new); + return new HealthMetricLastDateResponse(lastDate); + } } From 9b5123cfa2f65bc1da9f1443c96a05d8c6633600 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:13:24 +0900 Subject: [PATCH 03/12] =?UTF-8?q?feat=20:=20=EA=B1=B4=EA=B0=95=EC=A7=80?= =?UTF-8?q?=ED=91=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20response=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/HealthMetricLastDateResponse.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/coniverse/dangjang/domain/healthmetric/dto/HealthMetricLastDateResponse.java diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/dto/HealthMetricLastDateResponse.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/dto/HealthMetricLastDateResponse.java new file mode 100644 index 00000000..ec3b589c --- /dev/null +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/dto/HealthMetricLastDateResponse.java @@ -0,0 +1,12 @@ +package com.coniverse.dangjang.domain.healthmetric.dto; + +import java.time.LocalDate; + +/** + * health metric last Date + * + * @author EVE + * @since 1.1.0 + */ +public record HealthMetricLastDateResponse(LocalDate date) { +} From b6da4bcf773f99da7630ed490319e66ffa4f413c Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:15:57 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=8B=9C,=20=ED=97=AC=EC=8A=A4=EC=BB=A4=EB=84=A5=ED=8A=B8=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99=20=EC=97=AC=EB=B6=80=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/DefaultOauthLoginService.java | 4 +++- .../domain/healthmetric/enums/HealthConnect.java | 13 ++++++++++--- .../domain/user/repository/UserRepository.java | 11 +++++++++++ .../domain/user/service/UserSearchService.java | 11 +++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/auth/service/DefaultOauthLoginService.java b/src/main/java/com/coniverse/dangjang/domain/auth/service/DefaultOauthLoginService.java index 33d4e218..ff5aa92e 100644 --- a/src/main/java/com/coniverse/dangjang/domain/auth/service/DefaultOauthLoginService.java +++ b/src/main/java/com/coniverse/dangjang/domain/auth/service/DefaultOauthLoginService.java @@ -21,6 +21,7 @@ import com.coniverse.dangjang.domain.auth.mapper.AuthMapper; import com.coniverse.dangjang.domain.auth.repository.BlackTokenRepository; import com.coniverse.dangjang.domain.auth.repository.RefreshTokenRepository; +import com.coniverse.dangjang.domain.healthmetric.enums.HealthConnect; import com.coniverse.dangjang.domain.infrastructure.auth.client.OAuthClient; import com.coniverse.dangjang.domain.infrastructure.auth.dto.OAuthInfoResponse; import com.coniverse.dangjang.domain.notification.service.NotificationService; @@ -82,8 +83,9 @@ public LoginResponse login(OauthLoginRequest params, String fcmToken) { OAuthInfoResponse oAuthInfoResponse = request(params); User user = userSearchService.findUserByOauthId(oAuthInfoResponse.getOauthId()); notificationService.saveFcmToken(fcmToken, user.getOauthId()); + HealthConnect healthConnect = userSearchService.findInterlockHealthConnect(user.getOauthId()); user.verifyActiveUser(); - return new LoginResponse(user.getNickname(), false, false); + return new LoginResponse(user.getNickname(), false, healthConnect.isConnecting()); } /** diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/enums/HealthConnect.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/enums/HealthConnect.java index c8a7fe9d..339da121 100644 --- a/src/main/java/com/coniverse/dangjang/domain/healthmetric/enums/HealthConnect.java +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/enums/HealthConnect.java @@ -1,5 +1,8 @@ package com.coniverse.dangjang.domain.healthmetric.enums; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * health connect 연동여부 Enum *

@@ -8,8 +11,12 @@ * @author EVE * @since 1.0.0 */ +@AllArgsConstructor +@Getter public enum HealthConnect { - NEVER_CONNECTED, - CONNECTING, - DISCONNECTED + NEVER_CONNECTED(false), + CONNECTING(true), + DISCONNECTED(false); + + boolean isConnecting; } diff --git a/src/main/java/com/coniverse/dangjang/domain/user/repository/UserRepository.java b/src/main/java/com/coniverse/dangjang/domain/user/repository/UserRepository.java index 7fca50a2..7e00e61c 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/repository/UserRepository.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/repository/UserRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import com.coniverse.dangjang.domain.healthmetric.enums.HealthConnect; import com.coniverse.dangjang.domain.user.entity.User; /** @@ -29,4 +30,14 @@ public interface UserRepository extends JpaRepository { */ @Query("SELECT u FROM users u left join fetch u.userPoint up where u.oauthId = :oauthId") Optional findJoinUserPoint(@Param("oauthId") String oauthId); + + /** + * health connect 연동 여부 조회 + * + * @param oauthId 사용자 pk + * @return HealthConnect 연동여부 + * @since 1.1.0 + */ + @Query("SELECT u.healthConnect FROM users u WHERE u.oauthId = :oauthId") + HealthConnect findHealthConnectByOauthId(String oauthId); } diff --git a/src/main/java/com/coniverse/dangjang/domain/user/service/UserSearchService.java b/src/main/java/com/coniverse/dangjang/domain/user/service/UserSearchService.java index c5932c01..93263f25 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/service/UserSearchService.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/service/UserSearchService.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.coniverse.dangjang.domain.healthmetric.enums.HealthConnect; import com.coniverse.dangjang.domain.user.entity.User; import com.coniverse.dangjang.domain.user.exception.NonExistentUserException; import com.coniverse.dangjang.domain.user.repository.UserRepository; @@ -56,4 +57,14 @@ public Optional findNickname(String nickname) { public User findJoinUserPoint(String oauthId) { return userRepository.findJoinUserPoint(oauthId).orElseThrow(NonExistentUserException::new); } + + /** + * 헬스커넥트 연동 여부를 조회한다. + * + * @param oauthId 사용자 PK + * @return boolean 헬스커넥트 연동 여부 + */ + public HealthConnect findInterlockHealthConnect(String oauthId) { + return userRepository.findHealthConnectByOauthId(oauthId); + } } From 651c99ff4522872c6bb0f633f589f3cf5d6897b1 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:24:51 +0900 Subject: [PATCH 05/12] =?UTF-8?q?test=20:=20=EA=B1=B4=EA=B0=95=EC=A7=80?= =?UTF-8?q?=ED=91=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthConnectControllerTest.java | 3 ++- .../HealthMetricControllerTest.java | 24 +++++++++++++++++++ .../dangjang/support/ControllerTest.java | 5 ++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthConnectControllerTest.java b/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthConnectControllerTest.java index c44aa9a9..428e901a 100644 --- a/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthConnectControllerTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthConnectControllerTest.java @@ -41,7 +41,7 @@ class HealthConnectControllerTest extends ControllerTest { } @Test - void 헬스_커넥를_연동하면_성공_메시지를_반환한다() throws Exception { + void 헬스_커넥트를_연동하면_성공_메시지를_반환한다() throws Exception { // given HealthConnectRegisterRequest request = 헬스_커넥트_연동_요청(true); String content = objectMapper.writeValueAsString(request); @@ -56,4 +56,5 @@ class HealthConnectControllerTest extends ControllerTest { jsonPath("$.data").doesNotExist() ); } + } \ No newline at end of file diff --git a/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricControllerTest.java b/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricControllerTest.java index 27a62b07..1a9db23b 100644 --- a/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricControllerTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricControllerTest.java @@ -23,6 +23,7 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import com.coniverse.dangjang.domain.healthmetric.dto.HealthMetricLastDateResponse; import com.coniverse.dangjang.domain.healthmetric.dto.request.HealthMetricPatchRequest; import com.coniverse.dangjang.domain.healthmetric.dto.request.HealthMetricPostRequest; import com.coniverse.dangjang.domain.healthmetric.dto.response.BloodSugarMinMax; @@ -30,6 +31,7 @@ import com.coniverse.dangjang.domain.healthmetric.dto.response.HealthMetricResponse; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricChartSearchService; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricRegisterService; +import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricSearchService; import com.coniverse.dangjang.support.ControllerTest; import com.coniverse.dangjang.support.annotation.WithDangjangUser; import com.fasterxml.jackson.core.JsonProcessingException; @@ -50,6 +52,8 @@ class HealthMetricControllerTest extends ControllerTest { private HealthMetricRegisterService healthMetricRegisterService; @Autowired private HealthMetricChartSearchService healthMetricChartSearchService; + @Autowired + private HealthMetricSearchService healthMetricSearchService; public static LocalDate 시작_날짜 = LocalDate.parse("2023-12-31"); public static LocalDate 마지막_날짜 = LocalDate.parse("2024-01-06"); public static LocalDate 생성_날짜 = LocalDate.of(2023, 12, 31); @@ -247,4 +251,24 @@ void setUp() throws JsonProcessingException { jsonPath("$.errorCode").value(400) ); } + + @Order(700) + @Test + void 건강지표_마지막_생성일을_전달한다() throws Exception { + //given + String subUrl = URL + "/last-date"; + LocalDate lastDate = LocalDate.now(); + HealthMetricLastDateResponse response = new HealthMetricLastDateResponse(lastDate); + given(healthMetricSearchService.findHealthMetricLastDate(any())).willReturn(response); + + //when + ResultActions resultActions = get(mockMvc, subUrl); + + //then + resultActions.andExpectAll( + status().isOk(), + jsonPath("$.message").value("OK"), + jsonPath("$.data.date").value(response.date().toString()) + ); + } } diff --git a/src/test/java/com/coniverse/dangjang/support/ControllerTest.java b/src/test/java/com/coniverse/dangjang/support/ControllerTest.java index cdda10bf..aa08052e 100644 --- a/src/test/java/com/coniverse/dangjang/support/ControllerTest.java +++ b/src/test/java/com/coniverse/dangjang/support/ControllerTest.java @@ -24,12 +24,11 @@ import com.coniverse.dangjang.domain.healthmetric.service.HealthConnectService; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricChartSearchService; import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricRegisterService; +import com.coniverse.dangjang.domain.healthmetric.service.HealthMetricSearchService; import com.coniverse.dangjang.domain.intro.controller.IntroController; import com.coniverse.dangjang.domain.intro.service.IntroService; import com.coniverse.dangjang.domain.log.controller.AppLogController; import com.coniverse.dangjang.domain.log.service.LogService; -import com.coniverse.dangjang.domain.log.controller.AppLogController; -import com.coniverse.dangjang.domain.log.service.LogService; import com.coniverse.dangjang.domain.notification.controller.NotificationController; import com.coniverse.dangjang.domain.notification.service.NotificationService; import com.coniverse.dangjang.domain.point.controller.PointController; @@ -109,5 +108,7 @@ public class ControllerTest { private UserWithdrawalService userWithdrawalService; @MockBean private NotificationService notificationService; + @MockBean + private HealthMetricSearchService healthMetricSearchService; } From 00a7518f9646ac285e5803cde7664c6aebbf8ab5 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:25:26 +0900 Subject: [PATCH 06/12] =?UTF-8?q?refactor=20:=20=EA=B1=B4=EA=B0=95?= =?UTF-8?q?=EC=A7=80=ED=91=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EC=97=94=EB=93=9C?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/healthmetric/controller/HealthMetricController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java b/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java index 6cdf78d6..02cc2f09 100644 --- a/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java +++ b/src/main/java/com/coniverse/dangjang/domain/healthmetric/controller/HealthMetricController.java @@ -97,7 +97,7 @@ public ResponseEntity> getHealt * @since 1.1.0 */ - @GetMapping("/lastDate") + @GetMapping("/last-date") public ResponseEntity> getHealthMetricLastDate(@AuthenticationPrincipal User principal) { String oauthId = principal.getUsername(); HealthMetricLastDateResponse response = healthMetricSearchService.findHealthMetricLastDate(oauthId); From de2899dc2c78c67d878753140a6b67732c0c0310 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:29:58 +0900 Subject: [PATCH 07/12] =?UTF-8?q?test=20:=20=ED=97=AC=EC=8A=A4=EC=BB=A4?= =?UTF-8?q?=EB=84=A5=ED=8A=B8=20=EC=97=B0=EB=8F=99=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/OauthLoginServiceTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java index 4a2dc42a..e377b9ac 100644 --- a/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java @@ -89,6 +89,26 @@ void tearDown() { ); } + @Order(200) + @Test + void 헬스커넥트를_연동한_유저면_로그인시_healthConnect를_true로_반환한다() { + //given + User 이브 = userRepository.save(유저_이브()); + 이브.connectToHealthConnect(); + entityManager.flush(); + KakaoLoginRequest request = 카카오_로그인_요청(); + int tokenCount = 0; + //when + LoginResponse response = oauthLoginService.login(request, fcmToken); + + //then + assertAll( + () -> assertThat(response.nickname()).isEqualTo(이브.getNickname()), + () -> assertThat(response.dangjangClub()).isFalse(), + () -> assertThat(response.healthConnect()).isTrue() + ); + } + @Order(300) @Test void 존재하는_사용자라면_auth토큰을_발급해준다() { From 08ddb8c9426d2f09d363001ed870908562f468fc Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:31:28 +0900 Subject: [PATCH 08/12] =?UTF-8?q?test=20:=20=ED=97=AC=EC=8A=A4=EC=BB=A4?= =?UTF-8?q?=EB=84=A5=ED=8A=B8=20=EC=97=B0=EB=8F=99=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dangjang/domain/auth/service/OauthLoginServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java index e377b9ac..5919ac96 100644 --- a/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/auth/service/OauthLoginServiceTest.java @@ -89,7 +89,7 @@ void tearDown() { ); } - @Order(200) + @Order(250) @Test void 헬스커넥트를_연동한_유저면_로그인시_healthConnect를_true로_반환한다() { //given From 4f3d8f9e8aafcd1cc2feffe7bb61de85ec39e67f Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 19:41:39 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor=20:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=EC=8B=9C,=20=ED=97=AC=EC=8A=A4=EC=BB=A4?= =?UTF-8?q?=EB=84=A5=ED=8A=B8=20=EC=97=B0=EB=8F=99=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dangjang/domain/user/service/UserSignupService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/user/service/UserSignupService.java b/src/main/java/com/coniverse/dangjang/domain/user/service/UserSignupService.java index 595cc28d..b2c5bfe6 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/service/UserSignupService.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/service/UserSignupService.java @@ -66,7 +66,7 @@ public LoginResponse signUp(SignUpRequest signUpRequest, String fcmToken) { registerWeight(savedUser, signUpRequest.weight()); pointService.addSignupPoint(savedUser.getOauthId()); notificationService.saveFcmToken(fcmToken, savedUser.getOauthId()); - return authMapper.toLoginResponse(savedUser.getNickname(), false, false); + return authMapper.toLoginResponse(savedUser.getNickname(), false, savedUser.getHealthConnect().isConnecting()); } /** From 96b5e54e7420c0a856357681ae97c5cf4fde9b6f Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 20:02:05 +0900 Subject: [PATCH 10/12] =?UTF-8?q?refactor=20:=20print=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dangjang/domain/user/controller/UserController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java b/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java index 3287d81a..ba57f4a6 100644 --- a/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java +++ b/src/main/java/com/coniverse/dangjang/domain/user/controller/UserController.java @@ -47,7 +47,6 @@ public class UserController { // TODO 전체 수정 (위치: signup, 이름: dup @GetMapping("/duplicateNickname") public ResponseEntity> checkDuplicateNickname( @RequestParam @Pattern(regexp = "^[가-힣ㄱ-ㅎㅏ-ㅣa-zA-Z0-9]{1,8}$", message = "닉네임은 영어,한글,숫자 1~8글자 이내로 이루어져있어야 합니다.") @NotBlank(message = "닉네임은 1~8글자 이내여야 합니다.") String nickname) { - System.out.println("닉네임 : " + nickname); DuplicateNicknameResponse duplicateNicknameResponse = userSignupService.checkDuplicatedNickname(nickname); return ResponseEntity.ok().body(new SuccessSingleResponse<>(HttpStatus.OK.getReasonPhrase(), duplicateNicknameResponse)); } From 0b764a91cbd64ca7c579ca6122ca09cafbfd859e Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 20:24:12 +0900 Subject: [PATCH 11/12] =?UTF-8?q?test=20:=20=EA=B1=B4=EA=B0=95=EC=A7=80?= =?UTF-8?q?=ED=91=9C=20=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/HealthMetricSearchServiceTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java index 09e17757..557633dd 100644 --- a/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java @@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import com.coniverse.dangjang.domain.code.enums.CommonCode; +import com.coniverse.dangjang.domain.healthmetric.dto.HealthMetricLastDateResponse; import com.coniverse.dangjang.domain.healthmetric.entity.HealthMetric; import com.coniverse.dangjang.domain.healthmetric.exception.HealthMetricNotFoundException; import com.coniverse.dangjang.domain.healthmetric.repository.HealthMetricRepository; @@ -40,6 +41,7 @@ class HealthMetricSearchServiceTest { @Autowired private UserRepository userRepository; private String oauthId; + private LocalDate 마지막_생성일 = 조회_날짜.plusDays(10); @BeforeEach void setUpUser() { @@ -50,6 +52,7 @@ void setUpUser() { .mapToObj(i -> 건강지표_엔티티(user, 조회_타입, 조회_날짜.plusDays(i))) .toList() ); + healthMetricRepository.save(건강지표_엔티티(user, 조회_타입, 마지막_생성일)); } @Test @@ -126,4 +129,14 @@ void setUpUser() { && 조회된_건강지표_리스트.get(i - 1).getCreatedAt().equals(조회_날짜.plusDays(i))) ); } + + @Test + void 건강지표_마지막_생성일을_조회한다() { + // when + HealthMetricLastDateResponse 조회된_마지막_생성일 = healthMetricSearchService.findHealthMetricLastDate(oauthId); + + // then + assertThat(조회된_마지막_생성일.date()).isEqualTo(마지막_생성일); + } + } From d2412f986904bf446dcffaa47a61eeb846fd93fd Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Tue, 17 Oct 2023 20:27:56 +0900 Subject: [PATCH 12/12] =?UTF-8?q?test=20:=20=EC=B5=9C=EA=B7=BC=20=EA=B1=B4?= =?UTF-8?q?=EA=B0=95=EC=A7=80=ED=91=9C=20=ED=83=80=EC=9E=85=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../healthmetric/service/HealthMetricSearchServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java index 557633dd..86bf0d6b 100644 --- a/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/healthmetric/service/HealthMetricSearchServiceTest.java @@ -96,7 +96,7 @@ void setUpUser() { // then assertAll( () -> assertThat(조회된_건강지표.getType()).isEqualTo(조회_타입), - () -> assertThat(조회된_건강지표.getCreatedAt()).isEqualTo(조회_날짜.plusDays(9)), + () -> assertThat(조회된_건강지표.getCreatedAt()).isEqualTo(마지막_생성일), () -> assertThat(조회된_건강지표.getOauthId()).isEqualTo(oauthId) ); }