From 877ad819e00b7c6e5423eecceee7f12f74b449b0 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Mon, 25 Mar 2024 01:05:17 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A7=20chore:=20=EC=83=81=EB=8C=80?= =?UTF-8?q?=20=EC=9C=A0=EC=A0=80=20=ED=83=80=EC=9E=85=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20#148?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MissionHistoryResponse.java | 2 ++ .../src/test/java/fixture/UserMissionFixture.java | 2 +- .../dto/response/MissionHistoryResult.java | 15 ++++++++++----- .../mission/service/UserMissionService.java | 6 +++--- .../external/firebase/config/FirebaseConfig.java | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/motivoo-api/src/main/java/sopt/org/motivoo/api/controller/mission/dto/response/MissionHistoryResponse.java b/motivoo-api/src/main/java/sopt/org/motivoo/api/controller/mission/dto/response/MissionHistoryResponse.java index 46e89f66..080df57b 100644 --- a/motivoo-api/src/main/java/sopt/org/motivoo/api/controller/mission/dto/response/MissionHistoryResponse.java +++ b/motivoo-api/src/main/java/sopt/org/motivoo/api/controller/mission/dto/response/MissionHistoryResponse.java @@ -11,6 +11,7 @@ @Builder public record MissionHistoryResponse( @JsonProperty("user_type") String userType, + @JsonProperty("opponent_user_type") String opponentUserType, @JsonProperty("today_mission") TodayUserMissionResponse todayMission, @JsonProperty("mission_history") List missionHistory ) { @@ -20,6 +21,7 @@ public static MissionHistoryResponse of(MissionHistoryResult result) { return MissionHistoryResponse.builder() .userType(result.userType()) + .opponentUserType(result.opponentUserType()) .todayMission(TodayUserMissionResponse.of(result.todayMission())) .missionHistory(result.missionHistory() != null ? result.missionHistory().stream().map(ParentchildMissionResponse::of) .collect(Collectors.toList()) : null).build(); diff --git a/motivoo-api/src/test/java/fixture/UserMissionFixture.java b/motivoo-api/src/test/java/fixture/UserMissionFixture.java index 02fbb2d2..78921fa4 100644 --- a/motivoo-api/src/test/java/fixture/UserMissionFixture.java +++ b/motivoo-api/src/test/java/fixture/UserMissionFixture.java @@ -74,7 +74,7 @@ public static MissionHistoryResponse createMissionHistoryResponse() { User childUser = createUser(); User parentUser = createUserV2(); - return MissionHistoryResponse.of(MissionHistoryResult.of(childUser, createUserMission(), createUserMissions(), createUserMissions())); + return MissionHistoryResponse.of(MissionHistoryResult.of(childUser, parentUser, createUserMission(), createUserMissions(), createUserMissions())); } public static TodayMissionResponse createTodayMissionResponse() { diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/dto/response/MissionHistoryResult.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/dto/response/MissionHistoryResult.java index 1279a4d3..8823edce 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/dto/response/MissionHistoryResult.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/dto/response/MissionHistoryResult.java @@ -16,34 +16,38 @@ @Builder public record MissionHistoryResult( String userType, + String opponentUserType, Boolean isTodayMissionChoiceCompleted, TodayUserMissionDto todayMission, List missionHistory ) { - public static MissionHistoryResult of(User user, UserMission todayMission, Map> missionGroupsByDate) { + public static MissionHistoryResult of(User user, User opponentUser, UserMission todayMission, Map> missionGroupsByDate) { List parentchildMissions = getParentchildMissionDtos(user, missionGroupsByDate); return MissionHistoryResult.builder() .userType(user.getType().getValue()) + .opponentUserType(opponentUser.getType().getValue()) .todayMission(TodayUserMissionDto.ofHistory(todayMission)) .missionHistory(parentchildMissions).build(); } - public static MissionHistoryResult of(User user, Map> missionGroupsByDate) { + public static MissionHistoryResult of(User user, User opponentUser, Map> missionGroupsByDate) { List parentchildMissions = getParentchildMissionDtos(user, missionGroupsByDate); return MissionHistoryResult.builder() .userType(user.getType().getValue()) + .opponentUserType(opponentUser.getType().getValue()) .missionHistory(parentchildMissions).build(); } - public static MissionHistoryResult of(User user) { + public static MissionHistoryResult of(User myUser, User opponentUser) { return MissionHistoryResult.builder() - .userType(user.getType().getValue()).build(); + .userType(myUser.getType().getValue()) + .opponentUserType(opponentUser.getType().getValue()).build(); } @NotNull @@ -63,10 +67,11 @@ private static List getParentchildMissionDtos(User user, // Test용 - public static MissionHistoryResult of(User user, UserMission todayMission, List myMissions, List opponentMissions) { + public static MissionHistoryResult of(User user, User opponentUser, UserMission todayMission, List myMissions, List opponentMissions) { return MissionHistoryResult.builder() .userType(user.getType().getValue()) + .opponentUserType(opponentUser.getType().getValue()) .todayMission(TodayUserMissionDto.ofHistory(todayMission)) .missionHistory(IntStream.range(0, myMissions.size()) .mapToObj(i -> ParentchildMissionDto.of(myMissions.get(i), opponentMissions.get(i))) diff --git a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/service/UserMissionService.java b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/service/UserMissionService.java index 4a3a5025..1809d9a7 100644 --- a/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/service/UserMissionService.java +++ b/motivoo-domain/src/main/java/sopt/org/motivoo/domain/mission/service/UserMissionService.java @@ -73,7 +73,7 @@ public MissionHistoryResult getUserMissionHistory(final Long userId) { // 유저의 미션 목록이 없는 경우 if (myUser.getUserMissions().isEmpty()) { - return MissionHistoryResult.of(myUser); + return MissionHistoryResult.of(myUser, opponentUser); } Map> missionsByDate = groupUserMissionsByDate(userId, opponentUser.getId()); @@ -83,10 +83,10 @@ public MissionHistoryResult getUserMissionHistory(final Long userId) { // 오늘의 미션을 아직 선택하지 않은 경우 if (!validateTodayDateMission(todayMission)) { - return MissionHistoryResult.of(myUser, missionsByDate); + return MissionHistoryResult.of(myUser, opponentUser, missionsByDate); } - return MissionHistoryResult.of(myUser, todayMission, missionsByDate); + return MissionHistoryResult.of(myUser, opponentUser, todayMission, missionsByDate); } private Map> groupUserMissionsByDate(Long myUserId, Long opponentUserId) { diff --git a/motivoo-external/src/main/java/sopt/org/motivoo/external/firebase/config/FirebaseConfig.java b/motivoo-external/src/main/java/sopt/org/motivoo/external/firebase/config/FirebaseConfig.java index e3643aed..dac78b86 100644 --- a/motivoo-external/src/main/java/sopt/org/motivoo/external/firebase/config/FirebaseConfig.java +++ b/motivoo-external/src/main/java/sopt/org/motivoo/external/firebase/config/FirebaseConfig.java @@ -51,7 +51,7 @@ public void init() { FirebaseApp.initializeApp(options); log.info("파이어베이스 연결에 성공했습니다."); ref = FirebaseDatabase.getInstance().getReference(COLLECTION_NAME); - log.info("ref = {}", ref.getDatabase()+" "+COLLECTION_NAME); + } catch (IOException e) { log.error("파이어베이스 서버와의 연결에 실패했습니다."); throw new BusinessException(FIREBASE_CONNECTION_ERROR); From fe2eff7774c8b2164f7b4a09968f976a7b93d792 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Mon, 25 Mar 2024 01:06:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20test:=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=88=98=EC=A0=95=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=20=EB=B0=98=EC=98=81=20#148?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/controller/UserMissionControllerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/motivoo-api/src/test/java/controller/UserMissionControllerTest.java b/motivoo-api/src/test/java/controller/UserMissionControllerTest.java index f3032924..3f3608fd 100644 --- a/motivoo-api/src/test/java/controller/UserMissionControllerTest.java +++ b/motivoo-api/src/test/java/controller/UserMissionControllerTest.java @@ -121,6 +121,7 @@ void getMissionHistory() throws Exception { fieldWithPath("success").type(BOOLEAN).description("응답 성공 여부"), fieldWithPath("data").description("응답 데이터"), fieldWithPath("data.user_type").type(STRING).description("유저의 타입(PARENT|CHILD)"), + fieldWithPath("data.opponent_user_type").type(STRING).description("상대 유저의 타입(PARENT|CHILD)"), fieldWithPath("data.today_mission").type(OBJECT).description("오늘의 미션"), fieldWithPath("data.today_mission.mission_content").type(STRING).description("오늘의 미션 내용"), fieldWithPath("data.today_mission.date").type(STRING).description("오늘 날짜"),