diff --git a/backend/src/docs/plan.adoc b/backend/src/docs/plan.adoc index 1a3d5474..53bd841f 100644 --- a/backend/src/docs/plan.adoc +++ b/backend/src/docs/plan.adoc @@ -37,3 +37,6 @@ operation::post update plan[snippets='http-request,http-response'] === 계획 날짜 수정 operation::post update plan day[snippets='http-request,http-response'] + +=== 그룹 내부의 계획 전체 조회 +operation::get all plans by group[snippets='http-request,http-response'] diff --git a/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java b/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java index af0de0cc..42cdc739 100644 --- a/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java +++ b/backend/src/main/java/com/twtw/backend/domain/notification/messagequeue/FcmConsumer.java @@ -4,9 +4,11 @@ import com.google.firebase.messaging.FirebaseMessagingException; import com.twtw.backend.domain.notification.dto.NotificationRequest; +import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; +@Slf4j @Component public class FcmConsumer { private final FirebaseMessaging firebaseMessaging; @@ -16,8 +18,11 @@ public FcmConsumer(FirebaseMessaging firebaseMessaging) { } @RabbitListener(queues = "notification.queue") - public void sendNotification(final NotificationRequest request) - throws FirebaseMessagingException { - firebaseMessaging.send(request.toMessage()); + public void sendNotification(final NotificationRequest request) { + try { + firebaseMessaging.send(request.toMessage()); + } catch (FirebaseMessagingException e) { + log.error(e.getMessage()); + } } } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java b/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java index 62eb5acb..53889083 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/controller/PlanController.java @@ -87,6 +87,11 @@ public ResponseEntity> getPlans() { return ResponseEntity.ok(planService.getPlans()); } + @GetMapping("group/{groupId}") + public ResponseEntity> getPlansByGroupId(@PathVariable final UUID groupId) { + return ResponseEntity.ok(planService.getPlansByGroupId(groupId)); + } + @PostMapping("update") public ResponseEntity updatePlan(@RequestBody final UpdatePlanRequest updatePlanRequest) { planService.updatePlan(updatePlanRequest); diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java index c1706458..434d5c1b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java @@ -211,4 +211,10 @@ public void deleteInvite(final PlanMemberRequest request) { Plan plan = getPlanEntity(request.getPlanId()); plan.deleteInvite(member); } + + public List getPlansByGroupId(final UUID groupId) { + final Group group = groupService.getGroupEntity(groupId); + final List plans = group.getGroupPlans(); + return plans.stream().map(this::getPlanInfoResponse).toList(); + } } diff --git a/backend/src/test/java/com/twtw/backend/domain/place/service/PlaceServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/place/service/PlaceServiceTest.java index 6b670a37..48adcddd 100644 --- a/backend/src/test/java/com/twtw/backend/domain/place/service/PlaceServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/place/service/PlaceServiceTest.java @@ -1,20 +1,14 @@ package com.twtw.backend.domain.place.service; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; - import com.twtw.backend.domain.place.dto.client.SurroundPlaceRequest; import com.twtw.backend.domain.place.dto.client.SurroundPlaceResponse; import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.dto.client.MetaDetails; -import com.twtw.backend.domain.plan.dto.client.PlaceClientDetails; import com.twtw.backend.domain.plan.dto.response.PlaceDetails; import com.twtw.backend.fixture.place.PlaceDetailsFixture; import com.twtw.backend.fixture.place.PlaceEntityFixture; import com.twtw.backend.global.client.KakaoMapClient; import com.twtw.backend.support.service.LoginTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +16,10 @@ import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; + @DisplayName("PlaceService의") class PlaceServiceTest extends LoginTest { @@ -56,7 +54,7 @@ void getPlaceDetails() { final Place place = PlaceEntityFixture.FIRST_PLACE.toEntity(); // when - final PlaceClientDetails placeDetails = placeService.getPlaceDetails(place); + final PlaceDetails placeDetails = placeService.getPlaceDetails(place); // then assertThat(placeDetails.getPlaceName()).isEqualTo(place.getPlaceName()); diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java index 818716ec..07ada73a 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java @@ -1,17 +1,5 @@ package com.twtw.backend.domain.plan.controller; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.domain.place.entity.CategoryGroupCode; @@ -25,7 +13,6 @@ import com.twtw.backend.domain.plan.dto.response.PlanResponse; import com.twtw.backend.domain.plan.service.PlanService; import com.twtw.backend.support.docs.RestDocsTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -38,6 +25,17 @@ import java.util.List; import java.util.UUID; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @DisplayName("PlanController의") @WebMvcTest(PlanController.class) class PlanControllerTest extends RestDocsTest { @@ -465,4 +463,99 @@ void updatePlan() throws Exception { perform.andDo(print()) .andDo(document("post update plan", getDocumentRequest(), getDocumentResponse())); } + + @Test + @DisplayName("계획 전체 조회 API가 수행되는가") + void getPlansByGroupId() throws Exception { + // given + final List expected = + List.of( + PlanInfoResponse.builder() + .planId(UUID.randomUUID()) + .planMakerId(UUID.randomUUID()) + .placeId(UUID.randomUUID()) + .name("약속1") + .planDay("2023-12-25 15:30") + .placeDetails( + new PlaceDetails( + "카페 온마이마인드", + "https://place.map.kakao.com/1625295668", + "경기 안성시 죽산면 죽산초교길 36-4", + 127.420430538256, + 37.0766874564297)) + .groupInfo( + new GroupInfoResponse( + UUID.randomUUID(), + UUID.randomUUID(), + "홍담진", + "http://someUrlToS3", + List.of( + new MemberResponse( + UUID.randomUUID(), + "카즈하", + "http://HJ39GOAT"), + new MemberResponse( + UUID.randomUUID(), + "사쿠라", + "http://HJ39")))) + .members( + List.of( + new MemberResponse( + UUID.randomUUID(), + "진호정", + "http://HoJin39"))) + .build(), + PlanInfoResponse.builder() + .planId(UUID.randomUUID()) + .planMakerId(UUID.randomUUID()) + .placeId(UUID.randomUUID()) + .name("약속2") + .planDay("2023-12-25 15:30") + .placeDetails( + new PlaceDetails( + "카페 온마이마인드", + "https://place.map.kakao.com/1625295668", + "경기 안성시 죽산면 죽산초교길 36-4", + 127.420430538256, + 37.0766874564297)) + .groupInfo( + new GroupInfoResponse( + UUID.randomUUID(), + UUID.randomUUID(), + "HongDamJin", + "http://someUrlToS3", + List.of( + new MemberResponse( + UUID.randomUUID(), + "카즈하", + "http://HJ39"), + new MemberResponse( + UUID.randomUUID(), + "사쿠라", + "http://HJ39")))) + .members( + List.of( + new MemberResponse( + UUID.randomUUID(), + "JinHoJeong", + "http://HJ39"))) + .build()); + + given(planService.getPlansByGroupId(any())).willReturn(expected); + + // when + final ResultActions perform = + mockMvc.perform( + get("/plans/group/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + // then + perform.andExpect(status().isOk()); + + // docs + perform.andDo(print()) + .andDo(document("get all plans by group", getDocumentRequest(), getDocumentResponse())); + } }