diff --git a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java index c9e6e347..1194134a 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java @@ -2,8 +2,8 @@ import com.twtw.backend.domain.group.dto.request.*; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; +import com.twtw.backend.domain.group.dto.response.GroupResponse; import com.twtw.backend.domain.group.service.GroupService; - import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -62,7 +62,7 @@ public ResponseEntity unShareLocation(@PathVariable UUID id) { } @GetMapping - public ResponseEntity> getMyGroups() { + public ResponseEntity> getMyGroups() { return ResponseEntity.ok(groupService.getMyGroups()); } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/dto/response/GroupResponse.java b/backend/src/main/java/com/twtw/backend/domain/group/dto/response/GroupResponse.java new file mode 100644 index 00000000..7df6b1b1 --- /dev/null +++ b/backend/src/main/java/com/twtw/backend/domain/group/dto/response/GroupResponse.java @@ -0,0 +1,19 @@ +package com.twtw.backend.domain.group.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class GroupResponse { + private UUID groupId; + private UUID leaderId; + private String name; + private String groupImage; +} diff --git a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java index 7f656e10..949f39b9 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java @@ -3,10 +3,10 @@ import com.twtw.backend.domain.group.dto.request.MakeGroupRequest; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.group.dto.response.GroupMemberResponse; +import com.twtw.backend.domain.group.dto.response.GroupResponse; import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.member.entity.Member; - import org.mapstruct.*; import java.util.List; @@ -30,13 +30,13 @@ public interface GroupMapper { @Mapping(target = "groupMembers", source = "groupMembers") GroupInfoResponse toGroupInfo(Group group, List groupMembers); - @Named("groupMemberToGroupInfoResponse") + @Named("groupMemberToGroupResponse") @Mapping(target = "groupId", source = "groupMember.group.id") @Mapping(target = "leaderId", source = "groupMember.group.leaderId") @Mapping(target = "name", source = "groupMember.group.name") @Mapping(target = "groupImage", source = "groupMember.group.groupImage") - GroupInfoResponse toGroupInfoResponse(GroupMember groupMember); + GroupResponse toGroupResponse(GroupMember groupMember); - @IterableMapping(qualifiedByName = "groupMemberToGroupInfoResponse") - List toMyGroupsInfo(List groupMembers); + @IterableMapping(qualifiedByName = "groupMemberToGroupResponse") + List toGroupResponses(List groupMembers); } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index 6f22e88f..fb20b085 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -3,6 +3,7 @@ import com.twtw.backend.domain.group.dto.request.*; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.group.dto.response.GroupMemberResponse; +import com.twtw.backend.domain.group.dto.response.GroupResponse; import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.group.mapper.GroupMapper; @@ -15,7 +16,6 @@ import com.twtw.backend.global.constant.NotificationBody; import com.twtw.backend.global.constant.NotificationTitle; import com.twtw.backend.global.exception.EntityNotFoundException; - import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -127,14 +127,14 @@ public GroupInfoResponse getGroupInfoResponse(Group group) { } @Transactional(readOnly = true) - public List getMyGroups() { + public List getMyGroups() { Member loginMember = authService.getMemberByJwt(); if (loginMember.hasNoGroupMember()) { return List.of(); } - return groupMapper.toMyGroupsInfo(loginMember.getGroupMembers()); + return groupMapper.toGroupResponses(loginMember.getGroupMembers()); } @Transactional diff --git a/backend/src/main/java/com/twtw/backend/domain/place/entity/Place.java b/backend/src/main/java/com/twtw/backend/domain/place/entity/Place.java index 83c7fce3..1eb9c37b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/place/entity/Place.java +++ b/backend/src/main/java/com/twtw/backend/domain/place/entity/Place.java @@ -37,8 +37,6 @@ public class Place implements Auditable { private String placeUrl; - private CategoryGroupCode categoryGroupCode; - private String roadAddressName; @Embedded private Coordinate coordinate; @@ -52,13 +50,11 @@ public class Place implements Auditable { public Place( final String placeName, final String placeUrl, - final CategoryGroupCode categoryGroupCode, final String roadAddressName, final Double longitude, final Double latitude) { this.placeName = placeName; this.placeUrl = placeUrl; - this.categoryGroupCode = categoryGroupCode; this.roadAddressName = roadAddressName; this.coordinate = new Coordinate(longitude, latitude); } @@ -66,13 +62,11 @@ public Place( public void update( final String placeName, final String placeUrl, - final CategoryGroupCode categoryGroupCode, final String roadAddressName, final Double longitude, final Double latitude) { this.placeName = placeName; this.placeUrl = placeUrl; - this.categoryGroupCode = categoryGroupCode; this.roadAddressName = roadAddressName; this.coordinate = new Coordinate(longitude, latitude); } 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 cff5137a..0b6ff44e 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 @@ -3,24 +3,14 @@ import com.twtw.backend.domain.plan.dto.client.SearchDestinationRequest; import com.twtw.backend.domain.plan.dto.request.PlanMemberRequest; import com.twtw.backend.domain.plan.dto.request.SavePlanRequest; -import com.twtw.backend.domain.plan.dto.request.UpdatePlanDayRequest; import com.twtw.backend.domain.plan.dto.request.UpdatePlanRequest; import com.twtw.backend.domain.plan.dto.response.PlanDestinationResponse; import com.twtw.backend.domain.plan.dto.response.PlanInfoResponse; import com.twtw.backend.domain.plan.dto.response.PlanResponse; import com.twtw.backend.domain.plan.service.PlanService; - import lombok.RequiredArgsConstructor; - import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.UUID; @@ -76,12 +66,6 @@ public ResponseEntity outPlan(@RequestBody PlanMemberRequest request) { return ResponseEntity.noContent().build(); } - @PostMapping("/day") - public ResponseEntity updatePlanDay(@RequestBody final UpdatePlanDayRequest request) { - planService.updatePlanDay(request); - return ResponseEntity.noContent().build(); - } - @GetMapping public ResponseEntity> getPlans() { return ResponseEntity.ok(planService.getPlans()); diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java b/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java index 4c44bad8..1f1642bf 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java @@ -3,17 +3,13 @@ import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.member.entity.Member; -import com.twtw.backend.domain.place.entity.CategoryGroupCode; import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.exception.PlanMakerNotExistsException; import com.twtw.backend.global.audit.AuditListener; import com.twtw.backend.global.audit.Auditable; import com.twtw.backend.global.audit.BaseTime; - import jakarta.persistence.*; - import lombok.*; - import org.hibernate.annotations.Where; import java.time.LocalDateTime; @@ -104,14 +100,13 @@ public void updatePlace( final LocalDateTime planDay, final String placeName, final String placeUrl, - final CategoryGroupCode categoryGroupCode, final String roadAddressName, final Double longitude, final Double latitude) { this.name = name; this.planDay = planDay; this.place.update( - placeName, placeUrl, categoryGroupCode, roadAddressName, longitude, latitude); + placeName, placeUrl, roadAddressName, longitude, latitude); } public void updateMemberLocation( 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 660c5749..50730b0e 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 @@ -16,7 +16,6 @@ import com.twtw.backend.domain.plan.dto.client.SearchDestinationResponse; import com.twtw.backend.domain.plan.dto.request.PlanMemberRequest; import com.twtw.backend.domain.plan.dto.request.SavePlanRequest; -import com.twtw.backend.domain.plan.dto.request.UpdatePlanDayRequest; import com.twtw.backend.domain.plan.dto.request.UpdatePlanRequest; import com.twtw.backend.domain.plan.dto.response.PlaceDetails; import com.twtw.backend.domain.plan.dto.response.PlanDestinationResponse; @@ -29,9 +28,7 @@ import com.twtw.backend.global.constant.NotificationBody; import com.twtw.backend.global.constant.NotificationTitle; import com.twtw.backend.global.exception.EntityNotFoundException; - import lombok.RequiredArgsConstructor; - import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -167,7 +164,6 @@ public void updatePlan(final UpdatePlanRequest updatePlanRequest) { updatePlanRequest.getPlanDay(), placeName, updatePlanRequest.getPlaceUrl(), - updatePlanRequest.getCategoryGroupCode(), updatePlanRequest.getRoadAddressName(), updatePlanRequest.getLongitude(), updatePlanRequest.getLatitude()); @@ -192,12 +188,6 @@ private void sendDestinationNotification( id.toString())); } - @Transactional - public void updatePlanDay(final UpdatePlanDayRequest request) { - final Plan plan = getPlanEntity(request.getPlanId()); - plan.updatePlanDay(request.getChangeDay()); - } - @Transactional public void joinPlan(final PlanMemberRequest request) { Member member = authService.getMemberByJwt(); diff --git a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java index aed4557d..ef163cab 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java @@ -1,23 +1,11 @@ package com.twtw.backend.domain.group.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.request.*; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.group.dto.response.GroupMemberResponse; +import com.twtw.backend.domain.group.dto.response.GroupResponse; import com.twtw.backend.domain.group.service.GroupService; 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; @@ -29,6 +17,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("GroupController의") @WebMvcTest(GroupController.class) class GroupControllerTest extends RestDocsTest { @@ -259,36 +258,20 @@ void getMyGroups() throws Exception { // given final UUID leaderId = UUID.randomUUID(); - List responseList = new ArrayList<>(); + List responseList = new ArrayList<>(); - GroupInfoResponse response1 = - new GroupInfoResponse( + GroupResponse response1 = + new GroupResponse( UUID.randomUUID(), leaderId, "BLACK_PINK", - "I_LOVE_YOU_LOSE", - List.of( - new GroupMemberResponse( - UUID.randomUUID(), "DEAN", "http://hojiniSelfie", true), - new GroupMemberResponse( - UUID.randomUUID(), - "ZION-T", - "http://hojiniSelfie", - false))); - GroupInfoResponse response2 = - new GroupInfoResponse( + "I_LOVE_YOU_LOSE"); + GroupResponse response2 = + new GroupResponse( UUID.randomUUID(), leaderId, "LE_SSERAFIM", - "I_LOVE_YOU_채원", - List.of( - new GroupMemberResponse( - UUID.randomUUID(), "DEAN", "http://hojiniSelfie", true), - new GroupMemberResponse( - UUID.randomUUID(), - "ZION-T", - "http://hojiniSelfie", - false))); + "I_LOVE_YOU_채원"); responseList.add(response1); responseList.add(response2); diff --git a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java index 23bb23e2..b6ed3740 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java @@ -1,11 +1,10 @@ package com.twtw.backend.domain.group.service; -import static org.assertj.core.api.Assertions.assertThat; - import com.twtw.backend.domain.group.dto.request.InviteGroupRequest; import com.twtw.backend.domain.group.dto.request.JoinGroupRequest; import com.twtw.backend.domain.group.dto.request.MakeGroupRequest; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; +import com.twtw.backend.domain.group.dto.response.GroupResponse; import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.group.repository.GroupMemberRepository; @@ -13,13 +12,14 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.fixture.member.MemberEntityFixture; 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; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + @DisplayName("GroupService의") class GroupServiceTest extends LoginTest { @Autowired private GroupService groupService; @@ -124,11 +124,11 @@ void getMyGroups() { groupMember1.acceptInvite(); groupMember2.acceptInvite(); - Group saveGroup1 = groupRepository.save(group1); - Group saveGroup2 = groupRepository.save(group2); + groupRepository.save(group1); + groupRepository.save(group2); // when - List responses = groupService.getMyGroups(); + List responses = groupService.getMyGroups(); // then assertThat(responses).hasSize(2); 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 41fdb938..2826979d 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,24 +1,11 @@ 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.group.dto.response.GroupMemberResponse; import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.domain.place.entity.CategoryGroupCode; import com.twtw.backend.domain.plan.dto.request.PlanMemberRequest; import com.twtw.backend.domain.plan.dto.request.SavePlanRequest; -import com.twtw.backend.domain.plan.dto.request.UpdatePlanDayRequest; import com.twtw.backend.domain.plan.dto.request.UpdatePlanRequest; import com.twtw.backend.domain.plan.dto.response.PlaceDetails; import com.twtw.backend.domain.plan.dto.response.PlanDestinationResponse; @@ -26,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; @@ -39,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 { @@ -405,37 +402,6 @@ void getPlans() throws Exception { .andDo(document("get all plans", getDocumentRequest(), getDocumentResponse())); } - @Test - @DisplayName("계획 날짜 업데이트 API가 수행되는가") - void updatePlanDay() throws Exception { - // given - willDoNothing().given(planService).updatePlanDay(any()); - - // when - final ResultActions perform = - mockMvc.perform( - post("/plans/day") - .contentType(MediaType.APPLICATION_JSON) - .content( - toRequestBody( - new UpdatePlanDayRequest( - UUID.randomUUID(), - LocalDateTime.of(2023, 12, 25, 13, 30)))) - .header( - "Authorization", - "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); - // then - perform.andExpect(status().isNoContent()); - - // docs - perform.andDo(print()) - .andDo( - document( - "post update plan day", - getDocumentRequest(), - getDocumentResponse())); - } - @Test @DisplayName("계획 장소 업데이트 API가 수행되는가") void updatePlan() throws Exception { diff --git a/backend/src/test/java/com/twtw/backend/fixture/place/PlaceEntityFixture.java b/backend/src/test/java/com/twtw/backend/fixture/place/PlaceEntityFixture.java index 4e56fcd2..e2052cfb 100644 --- a/backend/src/test/java/com/twtw/backend/fixture/place/PlaceEntityFixture.java +++ b/backend/src/test/java/com/twtw/backend/fixture/place/PlaceEntityFixture.java @@ -1,24 +1,21 @@ package com.twtw.backend.fixture.place; -import com.twtw.backend.domain.place.entity.CategoryGroupCode; import com.twtw.backend.domain.place.entity.Place; - import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public enum PlaceEntityFixture { - FIRST_PLACE("다미네집", "http://everywhereIsMyHome", CategoryGroupCode.AT4, "도로명주소", 12.1, 21.2), - SECOND_PLACE("호진이네집", "http://IDontKnow", CategoryGroupCode.AD5, "도로명주소!", 123.123, 77.7); + FIRST_PLACE("다미네집", "http://everywhereIsMyHome", "도로명주소", 12.1, 21.2), + SECOND_PLACE("호진이네집", "http://IDontKnow", "도로명주소!", 123.123, 77.7); private final String placeName; private final String placeUrl; - private final CategoryGroupCode categoryGroupCode; private final String roadAddressName; private final Double longitude; private final Double latitude; public Place toEntity() { return new Place( - placeName, placeUrl, categoryGroupCode, roadAddressName, longitude, latitude); + placeName, placeUrl, roadAddressName, longitude, latitude); } }