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 46e89f6..080df57 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/controller/UserMissionControllerTest.java b/motivoo-api/src/test/java/controller/UserMissionControllerTest.java index f303292..3f3608f 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("오늘 날짜"), diff --git a/motivoo-api/src/test/java/fixture/UserMissionFixture.java b/motivoo-api/src/test/java/fixture/UserMissionFixture.java index 02fbb2d..78921fa 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 1279a4d..8823edc 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 4a3a502..1809d9a 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 e3643ae..dac78b8 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);