diff --git a/src/main/java/com/teami/domain/friend/controller/FriendController.java b/src/main/java/com/teami/domain/friend/controller/FriendController.java index 8e76776..94b041f 100644 --- a/src/main/java/com/teami/domain/friend/controller/FriendController.java +++ b/src/main/java/com/teami/domain/friend/controller/FriendController.java @@ -2,6 +2,7 @@ import com.teami.domain.friend.controller.dto.response.FriendCalendarInfo; import com.teami.domain.friend.controller.dto.response.FriendListResponse; +import com.teami.domain.friend.controller.dto.response.FriendMissionInfo; import com.teami.domain.friend.service.FriendService; import com.teami.global.apiPayload.ApiResponse; import lombok.RequiredArgsConstructor; @@ -40,4 +41,11 @@ public ApiResponse getFriendCalendarInfo(@RequestParam Long FriendCalendarInfo response = friendService.getCalendarInfo(memberId, friendMemberId); return ApiResponse.onSuccess(response); } + + // 친구 미션 조회 + @GetMapping("/{friendMemberId}/mission") + public ApiResponse getFriendMissionList(@RequestParam Long memberId, @PathVariable Long friendMemberId) { + FriendMissionInfo response = friendService.getMissionInfo(memberId, friendMemberId); + return ApiResponse.onSuccess(response); + } } \ No newline at end of file diff --git a/src/main/java/com/teami/domain/friend/controller/dto/response/FriendMissionInfo.java b/src/main/java/com/teami/domain/friend/controller/dto/response/FriendMissionInfo.java new file mode 100644 index 0000000..1ceebf1 --- /dev/null +++ b/src/main/java/com/teami/domain/friend/controller/dto/response/FriendMissionInfo.java @@ -0,0 +1,14 @@ +package com.teami.domain.friend.controller.dto.response; + +import com.teami.domain.calendar.entitty.CalendarMission; +import lombok.Builder; + +import java.util.List; + +@Builder +public record FriendMissionInfo( + Long memberId, + Long friendMemberId, + List missionContentList +) { +} diff --git a/src/main/java/com/teami/domain/friend/service/FriendService.java b/src/main/java/com/teami/domain/friend/service/FriendService.java index a309f10..d1fe523 100644 --- a/src/main/java/com/teami/domain/friend/service/FriendService.java +++ b/src/main/java/com/teami/domain/friend/service/FriendService.java @@ -1,8 +1,12 @@ package com.teami.domain.friend.service; +import com.teami.domain.calendar.entitty.Calendar; +import com.teami.domain.calendar.entitty.CalendarMission; +import com.teami.domain.calendar.repository.CalendarMissionRepository; import com.teami.domain.calendar.repository.CalendarRepository; import com.teami.domain.friend.controller.dto.response.FriendCalendarInfo; import com.teami.domain.friend.controller.dto.response.FriendListResponse; +import com.teami.domain.friend.controller.dto.response.FriendMissionInfo; import com.teami.domain.friend.entity.Friend; import com.teami.domain.friend.repository.FriendRepository; import com.teami.domain.member.entitty.Member; @@ -14,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -24,6 +29,7 @@ public class FriendService { private final FriendRepository friendRepository; private final MemberService memberService; private final CalendarRepository calendarRepository; + private final CalendarMissionRepository calendarMissionRepository; @Transactional public Long createFriend(Long member1Id, Long member2Id) { @@ -89,4 +95,15 @@ public FriendCalendarInfo getCalendarInfo(Long memberId, Long friendMemberId) { Long calendarId = calendarRepository.findByMemberAndIsComplete(friendMember, false).get().getId(); return new FriendCalendarInfo(memberId, friendMemberId, calendarId); } + + public FriendMissionInfo getMissionInfo(Long memberId, Long friendMemberId) { + validateFriend(memberId, friendMemberId); + Member friendMember = memberService.findById(friendMemberId); + + Optional calendar = calendarRepository.findByMemberAndIsComplete(friendMember, false); + List friendMissions = calendarMissionRepository.findAllByCalendarOrderByDate(calendar.get()); + + FriendMissionInfo friendMissionInfo = new FriendMissionInfo(memberId, friendMemberId, friendMissions); + return friendMissionInfo; + } }