From a0c9548e4b5004d3f31ae1120a9cadcb7bb29751 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sat, 3 Aug 2024 19:20:16 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20controller=20=EC=95=BD=EC=86=8D=20?= =?UTF-8?q?=EA=B0=9C=EC=84=A4=20v1=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/controller/MeetingController.java | 25 ++++++++++++++ .../controller/MeetingControllerSwagger.java | 21 ++++++++++++ .../dto/request/MeetingSaveV1Request.java | 32 +++++++++++++++++ .../dto/response/MeetingSaveV1Response.java | 34 +++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java create mode 100644 backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java index 558308313..92fe25780 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java @@ -2,14 +2,18 @@ import com.ody.common.annotation.AuthMember; import com.ody.meeting.dto.request.MeetingSaveRequest; +import com.ody.meeting.dto.request.MeetingSaveV1Request; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; +import com.ody.meeting.dto.response.MeetingSaveV1Response; import com.ody.meeting.service.MeetingService; import com.ody.member.domain.Member; import com.ody.notification.domain.Notification; import com.ody.notification.dto.response.NotiLogFindResponses; import com.ody.notification.service.NotificationService; import jakarta.validation.Valid; +import java.time.LocalDate; +import java.time.LocalTime; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -40,6 +44,27 @@ public ResponseEntity save( .body(meetingSaveResponse); } + @Override + @PostMapping("/v1/meetings") + public ResponseEntity saveV1( + @AuthMember Member member, + @Valid @RequestBody MeetingSaveV1Request meetingSaveV1Request + ) { + MeetingSaveV1Response meetingSaveV1Response = new MeetingSaveV1Response( + 1L, + "우테코 16조", + LocalDate.parse("2024-07-15"), + LocalTime.parse("14:00"), + "서울 송파구 올림픽로 35다길 42", + "37.515298", + "127.103113", + "초대코드" + ); + + return ResponseEntity.status(HttpStatus.CREATED) + .body(meetingSaveV1Response); + } + @Override @GetMapping("/meetings/me") public ResponseEntity findMine(@AuthMember Member member) { diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java index c6006649b..e1d49467f 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java @@ -1,8 +1,10 @@ package com.ody.meeting.controller; import com.ody.meeting.dto.request.MeetingSaveRequest; +import com.ody.meeting.dto.request.MeetingSaveV1Request; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; +import com.ody.meeting.dto.response.MeetingSaveV1Response; import com.ody.member.domain.Member; import com.ody.notification.dto.response.NotiLogFindResponses; import com.ody.swagger.annotation.ErrorCode400; @@ -75,6 +77,25 @@ ResponseEntity save( MeetingSaveRequest meetingSaveRequest ); + @Operation( + summary = "약속 개설", + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveV1Request.class))), + responses = { + @ApiResponse( + responseCode = "201", + description = "약속 개설 성공", + content = @Content(schema = @Schema(implementation = MeetingSaveV1Response.class)) + ) + } + ) + @ErrorCode400 + @ErrorCode401 + @ErrorCode500 + ResponseEntity saveV1( + @Parameter(hidden = true) Member member, + MeetingSaveV1Request meetingSaveV1Request + ); + @Operation( summary = "초대코드 유효성 검사", responses = { diff --git a/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java new file mode 100644 index 000000000..a357bce48 --- /dev/null +++ b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java @@ -0,0 +1,32 @@ +package com.ody.meeting.dto.request; + +import com.ody.common.annotation.FutureOrPresentDateTime; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Size; +import java.time.LocalDate; +import java.time.LocalTime; + +@FutureOrPresentDateTime(dateFieldName = "date", timeFieldName = "time") +public record MeetingSaveV1Request( + + @Schema(description = "모임 이름", example = "우테코 16조") + @Size(min = 1, max = 15, message = "약속 이름은 1글자 이상, 16자 미만으로 입력 가능합니다.") + String name, + + @Schema(description = "모임 날짜", type = "string", example = "2024-07-15") + LocalDate date, + + @Schema(description = "모임 시간", type = "string", example = "14:00") + LocalTime time, + + @Schema(description = "도착지 주소", example = "서울 송파구 올림픽로35다길 42") + String targetAddress, + + @Schema(description = "도착지 위도", example = "37.515298") + String targetLatitude, + + @Schema(description = "도착지 경도", example = "127.103113") + String targetLongitude +) { + +} diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java new file mode 100644 index 000000000..3fff7fae0 --- /dev/null +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java @@ -0,0 +1,34 @@ +package com.ody.meeting.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDate; +import java.time.LocalTime; + +public record MeetingSaveV1Response( + + @Schema(description = "모임 ID", example = "1") + Long id, + + @Schema(description = "모임 이름", example = "우테코 16조") + String name, + + @Schema(description = "모임 날짜", type = "string", example = "2024-07-15") + LocalDate date, + + @Schema(description = "모임 시간", type = "string", example = "14:00") + LocalTime time, + + @Schema(description = "도착지 주소", example = "서울 송파구 올림픽로35다길 42") + String targetAddress, + + @Schema(description = "도착지 위도", example = "37.515298") + String targetLatitude, + + @Schema(description = "도착지 경도", example = "127.103113") + String targetLongitude, + + @Schema(description = "초대코드", example = "초대코드") + String inviteCode +) { + +} From a30d0c26a46f534286df9d420a1022ee8d3f2ae4 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sat, 3 Aug 2024 19:57:33 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=EC=95=BD=EC=86=8D=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A4=20v1=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/controller/MeetingController.java | 14 +----- .../dto/request/MeetingSaveV1Request.java | 6 +++ .../dto/response/MeetingSaveV1Response.java | 13 +++++ .../ody/meeting/service/MeetingService.java | 10 ++++ .../controller/MeetingControllerTest.java | 26 ++++++++++ .../meeting/service/MeetingServiceTest.java | 48 +++++++++++++++++++ 6 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java index 92fe25780..c5f50f802 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java @@ -12,8 +12,6 @@ import com.ody.notification.dto.response.NotiLogFindResponses; import com.ody.notification.service.NotificationService; import jakarta.validation.Valid; -import java.time.LocalDate; -import java.time.LocalTime; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -50,17 +48,7 @@ public ResponseEntity saveV1( @AuthMember Member member, @Valid @RequestBody MeetingSaveV1Request meetingSaveV1Request ) { - MeetingSaveV1Response meetingSaveV1Response = new MeetingSaveV1Response( - 1L, - "우테코 16조", - LocalDate.parse("2024-07-15"), - LocalTime.parse("14:00"), - "서울 송파구 올림픽로 35다길 42", - "37.515298", - "127.103113", - "초대코드" - ); - + MeetingSaveV1Response meetingSaveV1Response = meetingService.saveV1(meetingSaveV1Request); return ResponseEntity.status(HttpStatus.CREATED) .body(meetingSaveV1Response); } diff --git a/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java index a357bce48..661ba5f98 100644 --- a/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java +++ b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java @@ -1,6 +1,8 @@ package com.ody.meeting.dto.request; import com.ody.common.annotation.FutureOrPresentDateTime; +import com.ody.meeting.domain.Location; +import com.ody.meeting.domain.Meeting; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Size; import java.time.LocalDate; @@ -29,4 +31,8 @@ public record MeetingSaveV1Request( String targetLongitude ) { + public Meeting toMeeting(String inviteCode) { + Location target = new Location(targetAddress, targetLatitude, targetLongitude); + return new Meeting(name, date, time, target, inviteCode); + } } diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java index 3fff7fae0..fe3946f67 100644 --- a/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java @@ -1,5 +1,6 @@ package com.ody.meeting.dto.response; +import com.ody.meeting.domain.Meeting; import io.swagger.v3.oas.annotations.media.Schema; import java.time.LocalDate; import java.time.LocalTime; @@ -31,4 +32,16 @@ public record MeetingSaveV1Response( String inviteCode ) { + public static MeetingSaveV1Response from(Meeting meeting) { + return new MeetingSaveV1Response( + meeting.getId(), + meeting.getName(), + meeting.getDate(), + meeting.getTime().withNano(0), + meeting.getTarget().getAddress(), + meeting.getTarget().getLatitude(), + meeting.getTarget().getLongitude(), + meeting.getInviteCode() + ); + } } diff --git a/backend/src/main/java/com/ody/meeting/service/MeetingService.java b/backend/src/main/java/com/ody/meeting/service/MeetingService.java index b21ba96b8..3e3c7f80a 100644 --- a/backend/src/main/java/com/ody/meeting/service/MeetingService.java +++ b/backend/src/main/java/com/ody/meeting/service/MeetingService.java @@ -5,8 +5,10 @@ import com.ody.mate.service.MateService; import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.request.MeetingSaveRequest; +import com.ody.meeting.dto.request.MeetingSaveV1Request; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; +import com.ody.meeting.dto.response.MeetingSaveV1Response; import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.Member; import com.ody.util.InviteCodeGenerator; @@ -32,6 +34,14 @@ public MeetingSaveResponse saveAndSendNotifications(MeetingSaveRequest meetingSa return mateService.saveAndSendNotifications(mateSaveRequest, meeting, member); } + @Transactional + public MeetingSaveV1Response saveV1(MeetingSaveV1Request meetingSaveV1Request) { + Meeting meeting = meetingRepository.save(meetingSaveV1Request.toMeeting(DEFAULT_INVITE_CODE)); + String encodedInviteCode = InviteCodeGenerator.encode(meeting.getId()); + meeting.updateInviteCode(encodedInviteCode); + return MeetingSaveV1Response.from(meeting); + } + public Meeting save(MeetingSaveRequest meetingSaveRequest) { Meeting meeting = meetingRepository.save(meetingSaveRequest.toMeeting(DEFAULT_INVITE_CODE)); String encodedInviteCode = InviteCodeGenerator.encode(meeting.getId()); diff --git a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java index 35b619a29..a21cc996f 100644 --- a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java +++ b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java @@ -8,6 +8,7 @@ import com.ody.meeting.domain.Location; import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.request.MeetingSaveRequest; +import com.ody.meeting.dto.request.MeetingSaveV1Request; import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.DeviceToken; import com.ody.member.domain.Member; @@ -66,6 +67,31 @@ void save() { .statusCode(HttpStatus.CREATED.value()); } + @DisplayName("모임 개설 성공 시, 201을 응답한다") + @Test + void saveV1() { + String deviceToken = "Bearer device-token=testToken"; + memberService.save(new DeviceToken(deviceToken)); + + MeetingSaveV1Request meetingRequest = new MeetingSaveV1Request( + "우테코 16조", + LocalDate.now().plusDays(1), + LocalTime.now().plusHours(1), + "서울 송파구 올림픽로35다길 42", + "37.515298", + "127.103113" + ); + + RestAssured.given().log().all() + .contentType(ContentType.JSON) + .header(HttpHeaders.AUTHORIZATION, deviceToken) + .body(meetingRequest) + .when() + .post("/v1/meetings") + .then() + .statusCode(HttpStatus.CREATED.value()); + } + @DisplayName("특정 멤버의 참여 모임 목록 조회에 성공하면 200응답 반환한다") @Test void findMine() { diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java new file mode 100644 index 000000000..d26c81a56 --- /dev/null +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -0,0 +1,48 @@ +package com.ody.meeting.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + +import com.ody.common.BaseServiceTest; +import com.ody.common.Fixture; +import com.ody.meeting.domain.Meeting; +import com.ody.meeting.dto.request.MeetingSaveV1Request; +import com.ody.meeting.dto.response.MeetingSaveV1Response; +import com.ody.util.InviteCodeGenerator; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +class MeetingServiceTest extends BaseServiceTest { + + @Autowired + MeetingService meetingService; + + @DisplayName("약속 저장 및 초대 코드 갱신에 성공한다") + @Test + void saveV1Success() { + Meeting testMeeting = Fixture.ODY_MEETING1; + MeetingSaveV1Request request = new MeetingSaveV1Request( + testMeeting.getName(), + testMeeting.getDate(), + testMeeting.getTime(), + testMeeting.getTarget().getAddress(), + testMeeting.getTarget().getLatitude(), + testMeeting.getTarget().getLongitude() + ); + + MeetingSaveV1Response response = meetingService.saveV1(request); + + assertAll( + () -> assertThat(response.name()).isEqualTo(request.name()), + () -> assertThat(response.date()).isEqualTo(request.date()), + () -> assertThat(response.time()).isEqualTo(request.time()), + () -> assertThat(response.targetAddress()).isEqualTo(request.targetAddress()), + () -> assertThat(response.targetLatitude()).isEqualTo(request.targetLatitude()), + () -> assertThat(response.targetLongitude()).isEqualTo(request.targetLongitude()), + () -> assertThat(InviteCodeGenerator.decode(response.inviteCode())).isEqualTo(response.id()) + ); + } + + +} From 073ac9552037607b59fc02f1a9baa811b729eebc Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sat, 3 Aug 2024 20:01:38 +0900 Subject: [PATCH 3/8] =?UTF-8?q?style:=20=EC=BB=A8=EB=B2=A4=EC=85=98=20?= =?UTF-8?q?=EC=A4=80=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ody/meeting/repository/MeetingRepository.java | 1 - .../ody/notification/repository/NotificationRepository.java | 1 - .../main/java/com/ody/route/mapper/OdsayResponseMapper.java | 4 ++-- .../main/java/com/ody/route/service/OdsayRouteClient.java | 5 ++++- .../com/ody/meeting/repository/MeetingRepositoryTest.java | 1 - 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/ody/meeting/repository/MeetingRepository.java b/backend/src/main/java/com/ody/meeting/repository/MeetingRepository.java index 20a4b6ad6..ca7ebdaf1 100644 --- a/backend/src/main/java/com/ody/meeting/repository/MeetingRepository.java +++ b/backend/src/main/java/com/ody/meeting/repository/MeetingRepository.java @@ -3,7 +3,6 @@ import com.ody.meeting.domain.Meeting; import com.ody.member.domain.Member; import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; diff --git a/backend/src/main/java/com/ody/notification/repository/NotificationRepository.java b/backend/src/main/java/com/ody/notification/repository/NotificationRepository.java index 4fe0ab942..70a2e28bd 100644 --- a/backend/src/main/java/com/ody/notification/repository/NotificationRepository.java +++ b/backend/src/main/java/com/ody/notification/repository/NotificationRepository.java @@ -1,7 +1,6 @@ package com.ody.notification.repository; import com.ody.notification.domain.Notification; -import java.time.LocalDateTime; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; diff --git a/backend/src/main/java/com/ody/route/mapper/OdsayResponseMapper.java b/backend/src/main/java/com/ody/route/mapper/OdsayResponseMapper.java index 9745bbf84..f5b6a9a11 100644 --- a/backend/src/main/java/com/ody/route/mapper/OdsayResponseMapper.java +++ b/backend/src/main/java/com/ody/route/mapper/OdsayResponseMapper.java @@ -26,7 +26,7 @@ public static long mapMinutes(OdsayResponse response) { return ZERO_TIME; } - if(response.code().isPresent()) { + if (response.code().isPresent()) { checkOdsayException(response); } @@ -49,7 +49,7 @@ private static void checkOdsayException(OdsayResponse response) { throw new OdyBadRequestException( response.message() - .orElse(EMPTY_MESSAGE) + .orElse(EMPTY_MESSAGE) ); } diff --git a/backend/src/main/java/com/ody/route/service/OdsayRouteClient.java b/backend/src/main/java/com/ody/route/service/OdsayRouteClient.java index 5b9595ba8..e5c51c595 100644 --- a/backend/src/main/java/com/ody/route/service/OdsayRouteClient.java +++ b/backend/src/main/java/com/ody/route/service/OdsayRouteClient.java @@ -37,7 +37,10 @@ private OdsayResponse getOdsayResponse(Location origin, Location target) { .uri(makeURI(origin, target)) .retrieve() .body(OdsayResponse.class); - return Objects.requireNonNullElseGet(response, () -> {throw new OdyServerErrorException("서버 에러");}); + return Objects.requireNonNullElseGet(response, () -> { + throw new OdyServerErrorException("서버 에러"); + } + ); } private URI makeURI(Location origin, Location target) { diff --git a/backend/src/test/java/com/ody/meeting/repository/MeetingRepositoryTest.java b/backend/src/test/java/com/ody/meeting/repository/MeetingRepositoryTest.java index 3215371cc..53b8ee3b9 100644 --- a/backend/src/test/java/com/ody/meeting/repository/MeetingRepositoryTest.java +++ b/backend/src/test/java/com/ody/meeting/repository/MeetingRepositoryTest.java @@ -11,7 +11,6 @@ import com.ody.member.domain.Member; import com.ody.member.repository.MemberRepository; import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; From 934cfb7188b445c47d8bee7b20586e8b34ce8a0d Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sun, 4 Aug 2024 18:37:52 +0900 Subject: [PATCH 4/8] =?UTF-8?q?refactor=20:=20dto=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ody/meeting/controller/MeetingController.java | 14 ++++++-------- .../controller/MeetingControllerSwagger.java | 12 ++++++------ ...aveV1Request.java => MeetingSaveRequestV1.java} | 2 +- ...eV1Response.java => MeetingSaveResponseV1.java} | 6 +++--- .../com/ody/meeting/service/MeetingService.java | 10 +++++----- .../meeting/controller/MeetingControllerTest.java | 4 ++-- .../ody/meeting/service/MeetingServiceTest.java | 8 ++++---- 7 files changed, 27 insertions(+), 29 deletions(-) rename backend/src/main/java/com/ody/meeting/dto/request/{MeetingSaveV1Request.java => MeetingSaveRequestV1.java} (97%) rename backend/src/main/java/com/ody/meeting/dto/response/{MeetingSaveV1Response.java => MeetingSaveResponseV1.java} (90%) diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java index 22dc02cb2..f076ffbb3 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingController.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingController.java @@ -3,13 +3,11 @@ import com.ody.common.annotation.AuthMember; import com.ody.mate.dto.request.MateEtaRequest; import com.ody.meeting.dto.request.MeetingSaveRequest; -import com.ody.meeting.dto.request.MeetingSaveV1Request; +import com.ody.meeting.dto.request.MeetingSaveRequestV1; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; -import com.ody.meeting.dto.response.MeetingSaveV1Response; +import com.ody.meeting.dto.response.MeetingSaveResponseV1; import com.ody.mate.dto.response.MateEtaResponses; -import com.ody.meeting.dto.response.MeetingSaveResponse; -import com.ody.meeting.dto.response.MeetingSaveResponses; import com.ody.meeting.dto.response.MeetingWithMatesResponse; import com.ody.meeting.service.MeetingService; import com.ody.member.domain.Member; @@ -50,13 +48,13 @@ public ResponseEntity save( @Override @PostMapping("/v1/meetings") - public ResponseEntity saveV1( + public ResponseEntity saveV1( @AuthMember Member member, - @Valid @RequestBody MeetingSaveV1Request meetingSaveV1Request + @Valid @RequestBody MeetingSaveRequestV1 meetingSaveRequestV1 ) { - MeetingSaveV1Response meetingSaveV1Response = meetingService.saveV1(meetingSaveV1Request); + MeetingSaveResponseV1 meetingSaveResponseV1 = meetingService.saveV1(meetingSaveRequestV1); return ResponseEntity.status(HttpStatus.CREATED) - .body(meetingSaveV1Response); + .body(meetingSaveResponseV1); } @GetMapping("/v1/meetings/{meetingId}") diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java index 850919a9c..284221bfd 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java @@ -3,10 +3,10 @@ import com.ody.mate.dto.request.MateEtaRequest; import com.ody.mate.dto.response.MateEtaResponses; import com.ody.meeting.dto.request.MeetingSaveRequest; -import com.ody.meeting.dto.request.MeetingSaveV1Request; +import com.ody.meeting.dto.request.MeetingSaveRequestV1; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; -import com.ody.meeting.dto.response.MeetingSaveV1Response; +import com.ody.meeting.dto.response.MeetingSaveResponseV1; import com.ody.meeting.dto.response.MeetingWithMatesResponse; import com.ody.member.domain.Member; import com.ody.notification.dto.response.NotiLogFindResponses; @@ -117,21 +117,21 @@ ResponseEntity save( @Operation( summary = "약속 개설", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveV1Request.class))), + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveRequestV1.class))), responses = { @ApiResponse( responseCode = "201", description = "약속 개설 성공", - content = @Content(schema = @Schema(implementation = MeetingSaveV1Response.class)) + content = @Content(schema = @Schema(implementation = MeetingSaveResponseV1.class)) ) } ) @ErrorCode400 @ErrorCode401 @ErrorCode500 - ResponseEntity saveV1( + ResponseEntity saveV1( @Parameter(hidden = true) Member member, - MeetingSaveV1Request meetingSaveV1Request + MeetingSaveRequestV1 meetingSaveRequestV1 ); @Operation( diff --git a/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveRequestV1.java similarity index 97% rename from backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java rename to backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveRequestV1.java index 661ba5f98..48339c498 100644 --- a/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveV1Request.java +++ b/backend/src/main/java/com/ody/meeting/dto/request/MeetingSaveRequestV1.java @@ -9,7 +9,7 @@ import java.time.LocalTime; @FutureOrPresentDateTime(dateFieldName = "date", timeFieldName = "time") -public record MeetingSaveV1Request( +public record MeetingSaveRequestV1( @Schema(description = "모임 이름", example = "우테코 16조") @Size(min = 1, max = 15, message = "약속 이름은 1글자 이상, 16자 미만으로 입력 가능합니다.") diff --git a/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveResponseV1.java similarity index 90% rename from backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java rename to backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveResponseV1.java index fe3946f67..154e41f08 100644 --- a/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveV1Response.java +++ b/backend/src/main/java/com/ody/meeting/dto/response/MeetingSaveResponseV1.java @@ -5,7 +5,7 @@ import java.time.LocalDate; import java.time.LocalTime; -public record MeetingSaveV1Response( +public record MeetingSaveResponseV1( @Schema(description = "모임 ID", example = "1") Long id, @@ -32,8 +32,8 @@ public record MeetingSaveV1Response( String inviteCode ) { - public static MeetingSaveV1Response from(Meeting meeting) { - return new MeetingSaveV1Response( + public static MeetingSaveResponseV1 from(Meeting meeting) { + return new MeetingSaveResponseV1( meeting.getId(), meeting.getName(), meeting.getDate(), diff --git a/backend/src/main/java/com/ody/meeting/service/MeetingService.java b/backend/src/main/java/com/ody/meeting/service/MeetingService.java index b4ec5d3e7..04d72a2b5 100644 --- a/backend/src/main/java/com/ody/meeting/service/MeetingService.java +++ b/backend/src/main/java/com/ody/meeting/service/MeetingService.java @@ -10,10 +10,10 @@ import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.response.MateResponse; import com.ody.meeting.dto.request.MeetingSaveRequest; -import com.ody.meeting.dto.request.MeetingSaveV1Request; +import com.ody.meeting.dto.request.MeetingSaveRequestV1; import com.ody.meeting.dto.response.MeetingSaveResponse; import com.ody.meeting.dto.response.MeetingSaveResponses; -import com.ody.meeting.dto.response.MeetingSaveV1Response; +import com.ody.meeting.dto.response.MeetingSaveResponseV1; import com.ody.meeting.dto.response.MeetingWithMatesResponse; import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.Member; @@ -44,11 +44,11 @@ public MeetingSaveResponse saveAndSendNotifications(MeetingSaveRequest meetingSa } @Transactional - public MeetingSaveV1Response saveV1(MeetingSaveV1Request meetingSaveV1Request) { - Meeting meeting = meetingRepository.save(meetingSaveV1Request.toMeeting(DEFAULT_INVITE_CODE)); + public MeetingSaveResponseV1 saveV1(MeetingSaveRequestV1 meetingSaveRequestV1) { + Meeting meeting = meetingRepository.save(meetingSaveRequestV1.toMeeting(DEFAULT_INVITE_CODE)); String encodedInviteCode = InviteCodeGenerator.encode(meeting.getId()); meeting.updateInviteCode(encodedInviteCode); - return MeetingSaveV1Response.from(meeting); + return MeetingSaveResponseV1.from(meeting); } public Meeting save(MeetingSaveRequest meetingSaveRequest) { diff --git a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java index a21cc996f..4898ec93a 100644 --- a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java +++ b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java @@ -8,7 +8,7 @@ import com.ody.meeting.domain.Location; import com.ody.meeting.domain.Meeting; import com.ody.meeting.dto.request.MeetingSaveRequest; -import com.ody.meeting.dto.request.MeetingSaveV1Request; +import com.ody.meeting.dto.request.MeetingSaveRequestV1; import com.ody.meeting.repository.MeetingRepository; import com.ody.member.domain.DeviceToken; import com.ody.member.domain.Member; @@ -73,7 +73,7 @@ void saveV1() { String deviceToken = "Bearer device-token=testToken"; memberService.save(new DeviceToken(deviceToken)); - MeetingSaveV1Request meetingRequest = new MeetingSaveV1Request( + MeetingSaveRequestV1 meetingRequest = new MeetingSaveRequestV1( "우테코 16조", LocalDate.now().plusDays(1), LocalTime.now().plusHours(1), diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java index d26c81a56..6eb391cc7 100644 --- a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -6,8 +6,8 @@ import com.ody.common.BaseServiceTest; import com.ody.common.Fixture; import com.ody.meeting.domain.Meeting; -import com.ody.meeting.dto.request.MeetingSaveV1Request; -import com.ody.meeting.dto.response.MeetingSaveV1Response; +import com.ody.meeting.dto.request.MeetingSaveRequestV1; +import com.ody.meeting.dto.response.MeetingSaveResponseV1; import com.ody.util.InviteCodeGenerator; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -22,7 +22,7 @@ class MeetingServiceTest extends BaseServiceTest { @Test void saveV1Success() { Meeting testMeeting = Fixture.ODY_MEETING1; - MeetingSaveV1Request request = new MeetingSaveV1Request( + MeetingSaveRequestV1 request = new MeetingSaveRequestV1( testMeeting.getName(), testMeeting.getDate(), testMeeting.getTime(), @@ -31,7 +31,7 @@ void saveV1Success() { testMeeting.getTarget().getLongitude() ); - MeetingSaveV1Response response = meetingService.saveV1(request); + MeetingSaveResponseV1 response = meetingService.saveV1(request); assertAll( () -> assertThat(response.name()).isEqualTo(request.name()), From ab2ecfe7229542d4bfe11353c0cfc0e1119952b2 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sun, 4 Aug 2024 18:41:51 +0900 Subject: [PATCH 5/8] =?UTF-8?q?refactor=20:=20=EB=AA=A8=EC=9E=84=20>=20?= =?UTF-8?q?=EC=95=BD=EC=86=8D=20=EC=9A=A9=EC=96=B4=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MateControllerSwagger.java | 4 ++-- .../controller/MeetingControllerSwagger.java | 23 +++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/backend/src/main/java/com/ody/mate/controller/MateControllerSwagger.java b/backend/src/main/java/com/ody/mate/controller/MateControllerSwagger.java index acc318f82..104762267 100644 --- a/backend/src/main/java/com/ody/mate/controller/MateControllerSwagger.java +++ b/backend/src/main/java/com/ody/mate/controller/MateControllerSwagger.java @@ -22,12 +22,12 @@ public interface MateControllerSwagger { @Operation( - summary = "모임 참여", + summary = "약속 참여", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MateSaveRequest.class))), responses = { @ApiResponse( responseCode = "201", - description = "모임 참여 성공", + description = "약속 참여 성공", content = @Content(schema = @Schema(implementation = MeetingSaveResponse.class)) ) } diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java index 284221bfd..6897de589 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java @@ -12,6 +12,7 @@ import com.ody.notification.dto.response.NotiLogFindResponses; import com.ody.swagger.annotation.ErrorCode400; import com.ody.swagger.annotation.ErrorCode401; +import com.ody.swagger.annotation.ErrorCode404; import com.ody.swagger.annotation.ErrorCode500; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -29,12 +30,12 @@ public interface MeetingControllerSwagger { @Operation( - summary = "모임 개설", + summary = "약속 개설", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveRequest.class))), responses = { @ApiResponse( responseCode = "201", - description = "모임 개설 성공", + description = "약속 개설 성공", content = @Content(schema = @Schema(implementation = MeetingSaveResponse.class)) ) } @@ -67,11 +68,11 @@ ResponseEntity save( ResponseEntity findMeetingWithMates(@Parameter(hidden = true) Member member, Long meetingId); @Operation( - summary = "참여중인 모임 목록 조회", + summary = "참여중인 약속 목록 조회", responses = { @ApiResponse( responseCode = "200", - description = "모임 목록 조회 성공", + description = "약속 목록 조회 성공", content = @Content(schema = @Schema(implementation = MeetingSaveResponses.class)) ) } @@ -90,7 +91,7 @@ ResponseEntity save( ), @ApiResponse( responseCode = "404", - description = "존재하지 않은 모임방이거나 모임방 일원이 아닌 경우", + description = "존재하지 않은 약속방이거나 약속방 일원이 아닌 경우", content = @Content(schema = @Schema(implementation = ProblemDetail.class)) ) } @@ -103,15 +104,11 @@ ResponseEntity save( summary = "초대코드 유효성 검사", responses = { @ApiResponse(responseCode = "200", description = "유효한 초대 코드"), - @ApiResponse( - responseCode = "404", - description = "유효하지 않은 초대코드", - content = @Content(schema = @Schema(implementation = ProblemDetail.class)) - ) } ) @ErrorCode400 @ErrorCode401 + @ErrorCode404(description = "유효하지 않은 초대코드") @ErrorCode500 ResponseEntity validateInviteCode(@Parameter(hidden = true) Member member, String inviteCode); @@ -147,15 +144,11 @@ ResponseEntity saveV1( responseCode = "400", description = "클라이언트 입력 오류 또는 약속 시간 30분 전보다 이른 시간에 조회 시도 시", content = @Content(schema = @Schema(implementation = ProblemDetail.class)) - ), - @ApiResponse( - responseCode = "404", - description = "존재하지 않는 모임이거나 해당 모임 참여자가 아닌 경우", - content = @Content(schema = @Schema(implementation = ProblemDetail.class)) ) } ) @ErrorCode401 + @ErrorCode404(description = "존재하지 않는 약속이거나 해당 약속 참여자가 아닌 경우") @ErrorCode500 ResponseEntity findAllMateEtas( @Parameter(hidden = true) Member member, From 3d6b210977e7da80dc23822af85e3e17752a47c6 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sun, 4 Aug 2024 18:42:13 +0900 Subject: [PATCH 6/8] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/com/ody/meeting/service/MeetingServiceTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java index 6eb391cc7..ba7f0da9a 100644 --- a/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java +++ b/backend/src/test/java/com/ody/meeting/service/MeetingServiceTest.java @@ -43,6 +43,4 @@ void saveV1Success() { () -> assertThat(InviteCodeGenerator.decode(response.inviteCode())).isEqualTo(response.id()) ); } - - } From 990111195e750de18485997eecd8a25d82885374 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sun, 4 Aug 2024 18:48:09 +0900 Subject: [PATCH 7/8] =?UTF-8?q?test:=20statusCode=20=EC=88=AB=EC=9E=90?= =?UTF-8?q?=EB=A1=9C=20=ED=91=9C=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ody/meeting/controller/MeetingControllerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java index 4898ec93a..3321307b8 100644 --- a/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java +++ b/backend/src/test/java/com/ody/meeting/controller/MeetingControllerTest.java @@ -64,7 +64,7 @@ void save() { .when() .post("/meetings") .then() - .statusCode(HttpStatus.CREATED.value()); + .statusCode(201); } @DisplayName("모임 개설 성공 시, 201을 응답한다") @@ -89,7 +89,7 @@ void saveV1() { .when() .post("/v1/meetings") .then() - .statusCode(HttpStatus.CREATED.value()); + .statusCode(201); } @DisplayName("특정 멤버의 참여 모임 목록 조회에 성공하면 200응답 반환한다") From 4c2d9ac4b996aa550ee81fe5ae29be0876f61446 Mon Sep 17 00:00:00 2001 From: coli-geonwoo Date: Sun, 4 Aug 2024 18:54:00 +0900 Subject: [PATCH 8/8] =?UTF-8?q?test:=20deprecated=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MeetingControllerSwagger.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java index 495ca8fd5..8111ca80b 100644 --- a/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java +++ b/backend/src/main/java/com/ody/meeting/controller/MeetingControllerSwagger.java @@ -30,6 +30,7 @@ public interface MeetingControllerSwagger { @Operation( + deprecated = true, summary = "약속 개설", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveRequest.class))), responses = { @@ -131,26 +132,6 @@ ResponseEntity saveV1( MeetingSaveRequestV1 meetingSaveRequestV1 ); - @Operation( - deprecated = true, - summary = "약속 개설", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MeetingSaveRequestV1.class))), - responses = { - @ApiResponse( - responseCode = "201", - description = "약속 개설 성공", - content = @Content(schema = @Schema(implementation = MeetingSaveResponseV1.class)) - ) - } - ) - @ErrorCode400 - @ErrorCode401 - @ErrorCode500 - ResponseEntity saveV1( - @Parameter(hidden = true) Member member, - MeetingSaveRequestV1 meetingSaveRequestV1 - ); - @Operation( summary = "약속 참여자 eta 상태 목록 조회", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = MateEtaRequest.class))),