From 3c941f6ae7d1ad337866d5f6656744aca6e05083 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 15:45:18 +0900 Subject: [PATCH 01/37] =?UTF-8?q?#212=20[fix]=20=EB=B0=A9=EC=9E=A5=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=20=EC=8B=9C=EA=B0=84=20=EC=9E=85=EB=A0=A5=20?= =?UTF-8?q?exception=EC=97=90=20data=20=EB=8B=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/dto/SuccessResponse.java | 7 ++++++- .../server/controller/UserController.java | 9 +++++++- .../dto/response/HostLoginStatusDto.java | 14 +++++++++++++ .../com/asap/server/service/UserService.java | 21 ++++++++++++++----- 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java diff --git a/src/main/java/com/asap/server/common/dto/SuccessResponse.java b/src/main/java/com/asap/server/common/dto/SuccessResponse.java index 6b1047f7..0f70f368 100644 --- a/src/main/java/com/asap/server/common/dto/SuccessResponse.java +++ b/src/main/java/com/asap/server/common/dto/SuccessResponse.java @@ -1,5 +1,6 @@ package com.asap.server.common.dto; +import com.asap.server.exception.Error; import com.asap.server.exception.Success; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -10,7 +11,7 @@ @Getter @ToString @RequiredArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class SuccessResponse { private final int code; private final String message; @@ -20,6 +21,10 @@ public static SuccessResponse success(Success success) { return new SuccessResponse<>(success.getHttpStatusCode(), success.getMessage()); } + public static SuccessResponse success(Error error, T data) { + return new SuccessResponse(error.getHttpStatusCode(), error.getMessage(), data); + } + public static SuccessResponse success(Success success, T data) { return new SuccessResponse(success.getHttpStatusCode(), success.getMessage(), data); } diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index cfde973b..8f70cf9b 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -7,6 +7,8 @@ import com.asap.server.controller.dto.request.AvailableTimeRequestDto; import com.asap.server.controller.dto.request.HostLoginRequestDto; import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; +import com.asap.server.controller.dto.response.HostLoginStatusDto; +import com.asap.server.exception.Error; import com.asap.server.exception.Success; import com.asap.server.service.UserService; import io.swagger.v3.oas.annotations.Operation; @@ -19,6 +21,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -97,6 +100,10 @@ public SuccessResponse loginByHost( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final HostLoginRequestDto requestDto ) { - return SuccessResponse.success(Success.LOGIN_SUCCESS, userService.loginByHost(meetingId, requestDto)); + HostLoginStatusDto statusDto = userService.loginByHost(meetingId, requestDto); + if(statusDto.getHttpStatus().equals(HttpStatus.FORBIDDEN)) { + return SuccessResponse.success(Error.HOST_MEETING_TIME_NOT_PROVIDED, statusDto.getHostLoginResponseDto()); + } + return SuccessResponse.success(Success.LOGIN_SUCCESS, statusDto.getHostLoginResponseDto()); } } diff --git a/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java b/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java new file mode 100644 index 00000000..7c5eb55e --- /dev/null +++ b/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java @@ -0,0 +1,14 @@ +package com.asap.server.controller.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@AllArgsConstructor +@Builder +@Getter +public class HostLoginStatusDto { + HttpStatus httpStatus; + HostLoginResponseDto hostLoginResponseDto; +} diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 87bfc717..8e13b4f5 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -6,6 +6,7 @@ import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; import com.asap.server.controller.dto.request.UserRequestDto; import com.asap.server.controller.dto.response.HostLoginResponseDto; +import com.asap.server.controller.dto.response.HostLoginStatusDto; import com.asap.server.controller.dto.response.UserMeetingTimeResponseDto; import com.asap.server.controller.dto.response.UserTimeResponseDto; import com.asap.server.domain.AvailableDate; @@ -22,6 +23,7 @@ import com.asap.server.repository.MeetingRepository; import com.asap.server.repository.UserRepository; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -153,7 +155,7 @@ public int getMeetingUserCount(final Meeting meeting) { } @Transactional - public HostLoginResponseDto loginByHost( + public HostLoginStatusDto loginByHost( final Long meetingId, final HostLoginRequestDto requestDto ) { @@ -166,12 +168,21 @@ public HostLoginResponseDto loginByHost( if (!passwordEncoder.matches(requestDto.getPassword(), meeting.getPassword())) throw new UnauthorizedException(Error.INVALID_HOST_ID_PASSWORD_EXCEPTION); - if (timeBlockUserService.isEmptyHostTimeBlock(meeting.getHost())) - throw new ForbiddenException(Error.HOST_MEETING_TIME_NOT_PROVIDED); - - return HostLoginResponseDto + HostLoginResponseDto responseDto = HostLoginResponseDto .builder() .accessToken(jwtService.issuedToken(meeting.getHost().getId().toString())) .build(); + + if (timeBlockUserService.isEmptyHostTimeBlock(meeting.getHost())) { + return HostLoginStatusDto.builder() + .httpStatus(HttpStatus.FORBIDDEN) + .hostLoginResponseDto(responseDto) + .build(); + } + + return HostLoginStatusDto.builder() + .httpStatus(HttpStatus.OK) + .hostLoginResponseDto(responseDto) + .build(); } } From 9fceaacb38eec135917d31e4da447fb651dbfc1d Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 17:18:40 +0900 Subject: [PATCH 02/37] =?UTF-8?q?#212=20[fix]=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/HostLoginStatusDto.java | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java diff --git a/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java b/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java deleted file mode 100644 index 7c5eb55e..00000000 --- a/src/main/java/com/asap/server/controller/dto/response/HostLoginStatusDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.asap.server.controller.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import org.springframework.http.HttpStatus; - -@AllArgsConstructor -@Builder -@Getter -public class HostLoginStatusDto { - HttpStatus httpStatus; - HostLoginResponseDto hostLoginResponseDto; -} From 6c732fdeae77b2b941ebbf313eff981680c19099 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 17:19:05 +0900 Subject: [PATCH 03/37] =?UTF-8?q?#212=20[fix]=20custom=20exception=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/HostTimeForbiddenException.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/com/asap/server/exception/model/HostTimeForbiddenException.java diff --git a/src/main/java/com/asap/server/exception/model/HostTimeForbiddenException.java b/src/main/java/com/asap/server/exception/model/HostTimeForbiddenException.java new file mode 100644 index 00000000..be8d9f2b --- /dev/null +++ b/src/main/java/com/asap/server/exception/model/HostTimeForbiddenException.java @@ -0,0 +1,15 @@ +package com.asap.server.exception.model; + +import com.asap.server.controller.dto.response.HostLoginResponseDto; +import com.asap.server.exception.Error; +import lombok.Getter; + +@Getter +public class HostTimeForbiddenException extends AsapException { + private final HostLoginResponseDto data; + + public HostTimeForbiddenException(Error error, HostLoginResponseDto data) { + super(error); + this.data = data; + } +} From b18b278ffba5c8ef2e58b99a3c2542cf92d15322 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 17:19:59 +0900 Subject: [PATCH 04/37] =?UTF-8?q?#212=20[fix]=20controllerAdvice=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/advice/ControllerExceptionAdvice.java | 10 ++++++++++ .../java/com/asap/server/common/dto/ErrorResponse.java | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java index 0002f4d9..0f07b597 100644 --- a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java +++ b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java @@ -4,6 +4,7 @@ import com.asap.server.common.utils.SlackUtil; import com.asap.server.exception.Error; import com.asap.server.exception.model.AsapException; +import com.asap.server.exception.model.HostTimeForbiddenException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -94,6 +95,15 @@ protected ErrorResponse handleHttpRequestMethodNotSupportedException( // return ErrorResponse.error(e.getError()); // } + /** + * 403 Forbidden + */ + @ResponseStatus(HttpStatus.FORBIDDEN) + @ExceptionHandler(HostTimeForbiddenException.class) + protected ErrorResponse handleForbiddenException(final HostTimeForbiddenException e) { + return ErrorResponse.error(e.getError(), e.getMessage(), e.getData()); + } + // /** // * 404 Not Found // */ diff --git a/src/main/java/com/asap/server/common/dto/ErrorResponse.java b/src/main/java/com/asap/server/common/dto/ErrorResponse.java index 96b7d4c6..340cec31 100644 --- a/src/main/java/com/asap/server/common/dto/ErrorResponse.java +++ b/src/main/java/com/asap/server/common/dto/ErrorResponse.java @@ -2,6 +2,7 @@ import com.asap.server.exception.Error; import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.ToString; @@ -9,9 +10,11 @@ @Getter @ToString @RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public class ErrorResponse { +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class ErrorResponse { private final int code; private final String message; + private T data; public static ErrorResponse error(Error error) { return new ErrorResponse(error.getHttpStatusCode(), error.getMessage()); @@ -20,4 +23,8 @@ public static ErrorResponse error(Error error) { public static ErrorResponse error(Error error, String message) { return new ErrorResponse(error.getHttpStatusCode(), message); } + + public static ErrorResponse error(Error error, String message, T data) { + return new ErrorResponse<>(error.getHttpStatusCode(), error.getMessage(), data); + } } From 322e82c62d8aa84e1553828c66890d6499d0e8fb Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 17:20:24 +0900 Subject: [PATCH 05/37] =?UTF-8?q?#212=20[fix]=20=EC=9D=B4=EC=A0=84=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/common/dto/SuccessResponse.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/asap/server/common/dto/SuccessResponse.java b/src/main/java/com/asap/server/common/dto/SuccessResponse.java index 0f70f368..ab8a496e 100644 --- a/src/main/java/com/asap/server/common/dto/SuccessResponse.java +++ b/src/main/java/com/asap/server/common/dto/SuccessResponse.java @@ -1,6 +1,5 @@ package com.asap.server.common.dto; -import com.asap.server.exception.Error; import com.asap.server.exception.Success; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -21,9 +20,6 @@ public static SuccessResponse success(Success success) { return new SuccessResponse<>(success.getHttpStatusCode(), success.getMessage()); } - public static SuccessResponse success(Error error, T data) { - return new SuccessResponse(error.getHttpStatusCode(), error.getMessage(), data); - } public static SuccessResponse success(Success success, T data) { return new SuccessResponse(success.getHttpStatusCode(), success.getMessage(), data); From a2cba1810893bc97eef416504c69287c70a6d103 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 17:20:51 +0900 Subject: [PATCH 06/37] =?UTF-8?q?#212=20[fix]=20=EC=9D=B4=EC=A0=84=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asap/server/controller/UserController.java | 9 +-------- .../java/com/asap/server/exception/Success.java | 1 + .../com/asap/server/service/UserService.java | 17 ++++------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 8f70cf9b..cfde973b 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -7,8 +7,6 @@ import com.asap.server.controller.dto.request.AvailableTimeRequestDto; import com.asap.server.controller.dto.request.HostLoginRequestDto; import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; -import com.asap.server.controller.dto.response.HostLoginStatusDto; -import com.asap.server.exception.Error; import com.asap.server.exception.Success; import com.asap.server.service.UserService; import io.swagger.v3.oas.annotations.Operation; @@ -21,7 +19,6 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -100,10 +97,6 @@ public SuccessResponse loginByHost( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final HostLoginRequestDto requestDto ) { - HostLoginStatusDto statusDto = userService.loginByHost(meetingId, requestDto); - if(statusDto.getHttpStatus().equals(HttpStatus.FORBIDDEN)) { - return SuccessResponse.success(Error.HOST_MEETING_TIME_NOT_PROVIDED, statusDto.getHostLoginResponseDto()); - } - return SuccessResponse.success(Success.LOGIN_SUCCESS, statusDto.getHostLoginResponseDto()); + return SuccessResponse.success(Success.LOGIN_SUCCESS, userService.loginByHost(meetingId, requestDto)); } } diff --git a/src/main/java/com/asap/server/exception/Success.java b/src/main/java/com/asap/server/exception/Success.java index b1ca9d4d..70f5e4a5 100644 --- a/src/main/java/com/asap/server/exception/Success.java +++ b/src/main/java/com/asap/server/exception/Success.java @@ -25,6 +25,7 @@ public enum Success { CREATE_MEETING_SUCCESS(HttpStatus.CREATED, "회의가 성공적으로 생성되었습니다."), CREATE_MEETING_TIME_SUCCESS(HttpStatus.CREATED, "참여자 회의 가능 시간 입력을 성공하였습니다."), CREATE_HOST_TIME_SUCCESS(HttpStatus.CREATED, "방장의 회의 가능 시간이 성공적으로 입력되었습니다."); + private final HttpStatus httpStatus; private final String message; diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 8e13b4f5..72b80b0e 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -6,7 +6,6 @@ import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; import com.asap.server.controller.dto.request.UserRequestDto; import com.asap.server.controller.dto.response.HostLoginResponseDto; -import com.asap.server.controller.dto.response.HostLoginStatusDto; import com.asap.server.controller.dto.response.UserMeetingTimeResponseDto; import com.asap.server.controller.dto.response.UserTimeResponseDto; import com.asap.server.domain.AvailableDate; @@ -17,13 +16,12 @@ import com.asap.server.exception.Error; import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.ConflictException; -import com.asap.server.exception.model.ForbiddenException; +import com.asap.server.exception.model.HostTimeForbiddenException; import com.asap.server.exception.model.NotFoundException; import com.asap.server.exception.model.UnauthorizedException; import com.asap.server.repository.MeetingRepository; import com.asap.server.repository.UserRepository; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpStatus; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -155,7 +153,7 @@ public int getMeetingUserCount(final Meeting meeting) { } @Transactional - public HostLoginStatusDto loginByHost( + public HostLoginResponseDto loginByHost( final Long meetingId, final HostLoginRequestDto requestDto ) { @@ -172,17 +170,10 @@ public HostLoginStatusDto loginByHost( .builder() .accessToken(jwtService.issuedToken(meeting.getHost().getId().toString())) .build(); - if (timeBlockUserService.isEmptyHostTimeBlock(meeting.getHost())) { - return HostLoginStatusDto.builder() - .httpStatus(HttpStatus.FORBIDDEN) - .hostLoginResponseDto(responseDto) - .build(); + throw new HostTimeForbiddenException(Error.HOST_MEETING_TIME_NOT_PROVIDED, responseDto); } - return HostLoginStatusDto.builder() - .httpStatus(HttpStatus.OK) - .hostLoginResponseDto(responseDto) - .build(); + return responseDto; } } From e8709f7ff8896ba230166ade686541f3a3207399 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 18:50:16 +0900 Subject: [PATCH 07/37] =?UTF-8?q?#212=20[fix]=20ErrorResponse=20=EC=B6=94?= =?UTF-8?q?=EC=83=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/advice/ControllerExceptionAdvice.java | 6 ++++-- .../server/common/dto/ErrorDataResponse.java | 16 ++++++++++++++++ .../asap/server/common/dto/ErrorResponse.java | 13 +++---------- 3 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/asap/server/common/dto/ErrorDataResponse.java diff --git a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java index 0f07b597..48e38a86 100644 --- a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java +++ b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java @@ -1,7 +1,9 @@ package com.asap.server.common.advice; +import com.asap.server.common.dto.ErrorDataResponse; import com.asap.server.common.dto.ErrorResponse; import com.asap.server.common.utils.SlackUtil; +import com.asap.server.controller.dto.response.HostLoginResponseDto; import com.asap.server.exception.Error; import com.asap.server.exception.model.AsapException; import com.asap.server.exception.model.HostTimeForbiddenException; @@ -100,8 +102,8 @@ protected ErrorResponse handleHttpRequestMethodNotSupportedException( */ @ResponseStatus(HttpStatus.FORBIDDEN) @ExceptionHandler(HostTimeForbiddenException.class) - protected ErrorResponse handleForbiddenException(final HostTimeForbiddenException e) { - return ErrorResponse.error(e.getError(), e.getMessage(), e.getData()); + protected ErrorDataResponse handleForbiddenException(final HostTimeForbiddenException e) { + return ErrorDataResponse.error(e.getError(), e.getMessage(), e.getData()); } // /** diff --git a/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java new file mode 100644 index 00000000..cf60e9cd --- /dev/null +++ b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java @@ -0,0 +1,16 @@ +package com.asap.server.common.dto; + +import com.asap.server.exception.Error; + +public class ErrorDataResponse extends ErrorResponse { + + public T data; + private ErrorDataResponse(int code, String message, T data) { + super(code, message); + this.data = data; + } + + public static ErrorDataResponse error(Error error, String message, T data) { + return new ErrorDataResponse(error.getHttpStatusCode(), message, data); + } +} diff --git a/src/main/java/com/asap/server/common/dto/ErrorResponse.java b/src/main/java/com/asap/server/common/dto/ErrorResponse.java index 340cec31..a78c003c 100644 --- a/src/main/java/com/asap/server/common/dto/ErrorResponse.java +++ b/src/main/java/com/asap/server/common/dto/ErrorResponse.java @@ -1,30 +1,23 @@ package com.asap.server.common.dto; import com.asap.server.exception.Error; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.ToString; @Getter @ToString -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class ErrorResponse { +@RequiredArgsConstructor +public class ErrorResponse { private final int code; private final String message; - private T data; public static ErrorResponse error(Error error) { return new ErrorResponse(error.getHttpStatusCode(), error.getMessage()); } + public static ErrorResponse error(Error error, String message) { return new ErrorResponse(error.getHttpStatusCode(), message); } - - public static ErrorResponse error(Error error, String message, T data) { - return new ErrorResponse<>(error.getHttpStatusCode(), error.getMessage(), data); - } } From 1cc45e10696eaec6e613e9b52db7223ddd73d669 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 19:41:05 +0900 Subject: [PATCH 08/37] =?UTF-8?q?#212=20[fix]=20ErrorDataResponse=20getter?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/common/dto/ErrorDataResponse.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java index cf60e9cd..adc284ad 100644 --- a/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java +++ b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java @@ -1,10 +1,12 @@ package com.asap.server.common.dto; import com.asap.server.exception.Error; +import lombok.Getter; +@Getter public class ErrorDataResponse extends ErrorResponse { - public T data; + private T data; private ErrorDataResponse(int code, String message, T data) { super(code, message); this.data = data; From dbe609b144b2cdf436bed164abb158998f6b914b Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sat, 30 Sep 2023 20:19:17 +0900 Subject: [PATCH 09/37] =?UTF-8?q?#196=20[fix]=20=EB=B0=A9=EC=9E=A5=20?= =?UTF-8?q?=ED=9A=8C=EC=9D=98=20=EA=B0=80=EB=8A=A5=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EB=84=98=EC=96=B4=EC=98=A4=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EC=95=98=EC=9D=84=20=EB=95=8C=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/controller/UserController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index cfde973b..32cf5133 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.util.List; @Tag(name = "사용자", description = "사용자 관련 로그인 및 가능 시간 입력 API 입니다.") @@ -57,7 +58,7 @@ public class UserController { @PostMapping("/host/{meetingId}/time") public SuccessResponse createHostTime( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, - @RequestBody final List<@Valid UserMeetingTimeSaveRequestDto> requestDtoList, + @RequestBody final List<@Valid @NotNull UserMeetingTimeSaveRequestDto> requestDtoList, @UserId @Parameter(hidden = true) final Long userId ) { return SuccessResponse.success(Success.CREATE_HOST_TIME_SUCCESS, userService.createHostTime(meetingId, userId, requestDtoList)); From f15c11c275a6cd4aee3d47e879a8690a350e073c Mon Sep 17 00:00:00 2001 From: KWY Date: Sun, 1 Oct 2023 20:25:44 +0900 Subject: [PATCH 10/37] =?UTF-8?q?#208=20[feat]=20delete=20jpql=20query=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 --- .../server/repository/AvailableDateRepository.java | 7 +++++++ .../asap/server/repository/PreferTimeRepository.java | 8 ++++++++ .../asap/server/repository/TimeBlockRepository.java | 12 +++++++++++- .../server/repository/TimeBlockUserRepository.java | 7 +++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/repository/AvailableDateRepository.java b/src/main/java/com/asap/server/repository/AvailableDateRepository.java index 4a602612..5bd632e8 100644 --- a/src/main/java/com/asap/server/repository/AvailableDateRepository.java +++ b/src/main/java/com/asap/server/repository/AvailableDateRepository.java @@ -2,7 +2,10 @@ import com.asap.server.domain.AvailableDate; import com.asap.server.domain.Meeting; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import java.time.LocalDate; import java.util.List; @@ -14,4 +17,8 @@ public interface AvailableDateRepository extends Repository List findByMeeting(final Meeting meeting); Optional findByMeetingAndDate(final Meeting meeting, final LocalDate date); + + @Modifying + @Query("delete from AvailableDate a where a.meeting = :meeting") + void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/PreferTimeRepository.java b/src/main/java/com/asap/server/repository/PreferTimeRepository.java index 8961a7de..b6e24e44 100644 --- a/src/main/java/com/asap/server/repository/PreferTimeRepository.java +++ b/src/main/java/com/asap/server/repository/PreferTimeRepository.java @@ -2,7 +2,10 @@ import com.asap.server.domain.Meeting; import com.asap.server.domain.PreferTime; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -11,4 +14,9 @@ public interface PreferTimeRepository extends Repository { PreferTime save(final PreferTime preferTime); List findByMeeting(final Meeting meeting); + + + @Modifying + @Query("delete from PreferTime p where p.meeting = :meeting") + void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockRepository.java b/src/main/java/com/asap/server/repository/TimeBlockRepository.java index f06460c2..1580858b 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockRepository.java @@ -3,15 +3,25 @@ import com.asap.server.domain.AvailableDate; import com.asap.server.domain.TimeBlock; import com.asap.server.domain.enums.TimeSlot; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; -import java.util.Optional; import java.util.List; +import java.util.Optional; public interface TimeBlockRepository extends Repository { void save(final TimeBlock timeBlock); List findByAvailableDate(final AvailableDate availableDate); + Optional findByAvailableDateAndTimeSlot(final AvailableDate availableDate, TimeSlot timeSlot); + + List findByAvailableDateIn(final List availableDates); + + @Modifying + @Query("delete from TimeBlock t where t.availableDate in :availableDates") + void deleteByAvailableDatesIn(@Param("availableDates") final List availableDates); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java index 40495cbc..0743e1a0 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java @@ -3,7 +3,10 @@ import com.asap.server.domain.TimeBlock; import com.asap.server.domain.TimeBlockUser; import com.asap.server.domain.User; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import java.util.List; @@ -14,4 +17,8 @@ public interface TimeBlockUserRepository extends Repository List findAllByUser(final User user); List findByTimeBlock(final TimeBlock timeBlock); + + @Modifying + @Query("delete from TimeBlockUser t where t.timeBlock in :timeblocks") + void deleteByTimeBlocksIn(@Param("timeblocks") final List timeBlocks); } From 92504c8fb66ec81e903fdbe7938bda32052c8e61 Mon Sep 17 00:00:00 2001 From: KWY Date: Sun, 1 Oct 2023 20:26:22 +0900 Subject: [PATCH 11/37] =?UTF-8?q?#208=20[feat]=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=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 --- .../com/asap/server/service/AvailableDateService.java | 10 ++++++++++ .../java/com/asap/server/service/MeetingService.java | 7 +++++++ .../com/asap/server/service/PreferTimeService.java | 4 ++++ .../java/com/asap/server/service/TimeBlockService.java | 8 ++++++++ .../com/asap/server/service/TimeBlockUserService.java | 5 +++++ 5 files changed, 34 insertions(+) diff --git a/src/main/java/com/asap/server/service/AvailableDateService.java b/src/main/java/com/asap/server/service/AvailableDateService.java index fccc13d1..ce66dc8b 100644 --- a/src/main/java/com/asap/server/service/AvailableDateService.java +++ b/src/main/java/com/asap/server/service/AvailableDateService.java @@ -6,6 +6,7 @@ import com.asap.server.controller.dto.response.TimeSlotDto; import com.asap.server.domain.AvailableDate; import com.asap.server.domain.Meeting; +import com.asap.server.domain.TimeBlock; import com.asap.server.exception.Error; import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.NotFoundException; @@ -114,4 +115,13 @@ public void create(final Meeting meeting, final List availableDates) { private boolean isDuplicatedDate(final List availableDates) { return availableDates.size() != availableDates.stream().distinct().count(); } + + public void deleteUserTimes(final Meeting meeting) { + List availableDates = availableDateRepository.findByMeeting(meeting); + List timeBlocks = timeBlockService.findByAvailableDateIn(availableDates); + + timeBlockUserService.deleteTimeBlockUsers(timeBlocks); + timeBlockService.deleteTimeBlocks(availableDates); + availableDateRepository.deleteByMeeting(meeting); + } } diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 665faa14..e4d46025 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -108,6 +108,13 @@ public void confirmMeeting( LocalDateTime fixedEndDateTime = LocalDateTime.of(fixedDate, endTime); meeting.setConfirmedDateTime(fixedStartDateTime, fixedEndDateTime); + + deleteMeetingTimes(meeting); + } + + private void deleteMeetingTimes(final Meeting meeting) { + availableDateService.deleteUserTimes(meeting); + preferTimeService.deletePreferTimes(meeting); } @Transactional(readOnly = true) diff --git a/src/main/java/com/asap/server/service/PreferTimeService.java b/src/main/java/com/asap/server/service/PreferTimeService.java index e8c07e03..5b071126 100644 --- a/src/main/java/com/asap/server/service/PreferTimeService.java +++ b/src/main/java/com/asap/server/service/PreferTimeService.java @@ -42,4 +42,8 @@ public List getPreferTimes(final Meeting meeting) { .build()) .collect(Collectors.toList()); } + + public void deletePreferTimes(final Meeting meeting) { + preferTimeRepository.deleteByMeeting(meeting); + } } diff --git a/src/main/java/com/asap/server/service/TimeBlockService.java b/src/main/java/com/asap/server/service/TimeBlockService.java index 88aa15cb..86dba8b2 100644 --- a/src/main/java/com/asap/server/service/TimeBlockService.java +++ b/src/main/java/com/asap/server/service/TimeBlockService.java @@ -51,4 +51,12 @@ private TimeBlock create(final TimeSlot timeSlot, final AvailableDate availableD public List getTimeBlocksByAvailableDate(final AvailableDate availableDate) { return timeBlockRepository.findByAvailableDate(availableDate); } + + public List findByAvailableDateIn(final List availableDates) { + return timeBlockRepository.findByAvailableDateIn(availableDates); + } + + public void deleteTimeBlocks(final List availableDates) { + timeBlockRepository.deleteByAvailableDatesIn(availableDates); + } } diff --git a/src/main/java/com/asap/server/service/TimeBlockUserService.java b/src/main/java/com/asap/server/service/TimeBlockUserService.java index d64b8cac..46b75745 100644 --- a/src/main/java/com/asap/server/service/TimeBlockUserService.java +++ b/src/main/java/com/asap/server/service/TimeBlockUserService.java @@ -47,4 +47,9 @@ public boolean isEmptyHostTimeBlock(final User user) { List hostTimeBlocks = timeBlockUserRepository.findAllByUser(user); return hostTimeBlocks.isEmpty(); } + + public void deleteTimeBlockUsers(final List timeBlocks) { + timeBlockUserRepository.deleteByTimeBlocksIn(timeBlocks); + } + } \ No newline at end of file From 0476c68ed96fc98121c520ba837b010d1268c8e7 Mon Sep 17 00:00:00 2001 From: KWY Date: Sun, 1 Oct 2023 21:17:07 +0900 Subject: [PATCH 12/37] =?UTF-8?q?#216=20[feat]=20user=20is=5Ffixed=20updat?= =?UTF-8?q?e=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/domain/User.java | 4 ---- .../com/asap/server/repository/UserRepository.java | 9 +++++++++ .../com/asap/server/service/MeetingService.java | 2 +- .../java/com/asap/server/service/UserService.java | 13 ++++++------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/asap/server/domain/User.java b/src/main/java/com/asap/server/domain/User.java index 5a16c21f..d7a674db 100644 --- a/src/main/java/com/asap/server/domain/User.java +++ b/src/main/java/com/asap/server/domain/User.java @@ -42,8 +42,4 @@ public class User extends AuditingTimeEntity { @Column(nullable = false) @Enumerated(value = EnumType.STRING) private Role role; - - public void setIsFixed(final Boolean isFixed) { - this.isFixed = isFixed; - } } diff --git a/src/main/java/com/asap/server/repository/UserRepository.java b/src/main/java/com/asap/server/repository/UserRepository.java index 6e55473b..4ac448f1 100644 --- a/src/main/java/com/asap/server/repository/UserRepository.java +++ b/src/main/java/com/asap/server/repository/UserRepository.java @@ -2,17 +2,26 @@ import com.asap.server.domain.Meeting; import com.asap.server.domain.User; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; public interface UserRepository extends Repository { User save(final User user); + + @Modifying + @Query("update User u set u.isFixed = true where u.meeting = :meeting and u.id in :userIds") + void updateUserIsFixedByMeeting(@Param("meeting") final Meeting meeting, @Param("userIds") final List users); + List findByMeetingAndIsFixed(final Meeting meeting, final boolean isFixed); Optional findById(final Long id); List findByMeeting(final Meeting meeting); + int countByMeeting(final Meeting meeting); } diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 665faa14..0690a30a 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -97,7 +97,7 @@ public void confirmMeeting( if (!meeting.authenticateHost(userId)) throw new UnauthorizedException(INVALID_MEETING_HOST_EXCEPTION); - userService.setFixedUsers(meetingConfirmRequestDto.getUsers()); + userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 87bfc717..92dc7661 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -139,13 +139,12 @@ public List getFixedUsers(final Meeting meeting) { .collect(Collectors.toList()); } - public void setFixedUsers(final List users) { - users.forEach(user -> { - User fixedUser = userRepository - .findById(user.getId()) - .orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); - fixedUser.setIsFixed(true); - }); + public void setFixedUsers(final Meeting meeting, final List users) { + List userIds = users.stream() + .mapToLong(UserRequestDto::getId) + .boxed() + .collect(Collectors.toList()); + userRepository.updateUserIsFixedByMeeting(meeting, userIds); } public int getMeetingUserCount(final Meeting meeting) { From 382b7631df1319c2e544b32859f1bd0650f39e55 Mon Sep 17 00:00:00 2001 From: KWY Date: Sun, 1 Oct 2023 21:32:25 +0900 Subject: [PATCH 13/37] =?UTF-8?q?#216=20[feat]=20clearAutomatically=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/repository/UserRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/repository/UserRepository.java b/src/main/java/com/asap/server/repository/UserRepository.java index 4ac448f1..7d61172f 100644 --- a/src/main/java/com/asap/server/repository/UserRepository.java +++ b/src/main/java/com/asap/server/repository/UserRepository.java @@ -13,7 +13,7 @@ public interface UserRepository extends Repository { User save(final User user); - @Modifying + @Modifying(clearAutomatically = true) @Query("update User u set u.isFixed = true where u.meeting = :meeting and u.id in :userIds") void updateUserIsFixedByMeeting(@Param("meeting") final Meeting meeting, @Param("userIds") final List users); From 5ae49ec21a0d8175e03190369b157693a97651a2 Mon Sep 17 00:00:00 2001 From: KWY Date: Sun, 1 Oct 2023 21:33:43 +0900 Subject: [PATCH 14/37] =?UTF-8?q?#208=20[feat]=20clearAutomatically=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/asap/server/repository/AvailableDateRepository.java | 2 +- .../java/com/asap/server/repository/PreferTimeRepository.java | 2 +- .../java/com/asap/server/repository/TimeBlockRepository.java | 2 +- .../com/asap/server/repository/TimeBlockUserRepository.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/asap/server/repository/AvailableDateRepository.java b/src/main/java/com/asap/server/repository/AvailableDateRepository.java index 5bd632e8..c7cade90 100644 --- a/src/main/java/com/asap/server/repository/AvailableDateRepository.java +++ b/src/main/java/com/asap/server/repository/AvailableDateRepository.java @@ -18,7 +18,7 @@ public interface AvailableDateRepository extends Repository Optional findByMeetingAndDate(final Meeting meeting, final LocalDate date); - @Modifying + @Modifying(clearAutomatically = true) @Query("delete from AvailableDate a where a.meeting = :meeting") void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/PreferTimeRepository.java b/src/main/java/com/asap/server/repository/PreferTimeRepository.java index b6e24e44..44efec4d 100644 --- a/src/main/java/com/asap/server/repository/PreferTimeRepository.java +++ b/src/main/java/com/asap/server/repository/PreferTimeRepository.java @@ -16,7 +16,7 @@ public interface PreferTimeRepository extends Repository { List findByMeeting(final Meeting meeting); - @Modifying + @Modifying(clearAutomatically = true) @Query("delete from PreferTime p where p.meeting = :meeting") void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockRepository.java b/src/main/java/com/asap/server/repository/TimeBlockRepository.java index 1580858b..ac79bc60 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockRepository.java @@ -21,7 +21,7 @@ public interface TimeBlockRepository extends Repository { List findByAvailableDateIn(final List availableDates); - @Modifying + @Modifying(clearAutomatically = true) @Query("delete from TimeBlock t where t.availableDate in :availableDates") void deleteByAvailableDatesIn(@Param("availableDates") final List availableDates); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java index 0743e1a0..acdbde4f 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java @@ -18,7 +18,7 @@ public interface TimeBlockUserRepository extends Repository List findByTimeBlock(final TimeBlock timeBlock); - @Modifying + @Modifying(clearAutomatically = true) @Query("delete from TimeBlockUser t where t.timeBlock in :timeblocks") void deleteByTimeBlocksIn(@Param("timeblocks") final List timeBlocks); } From 90f39749f7acadb3ed1b523fa74b848246620f31 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sun, 1 Oct 2023 22:02:24 +0900 Subject: [PATCH 15/37] =?UTF-8?q?#218=20[fix]=20Error=20Response=20?= =?UTF-8?q?=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/MeetingController.java | 11 ++++++----- .../asap/server/controller/UserController.java | 18 +++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/asap/server/controller/MeetingController.java b/src/main/java/com/asap/server/controller/MeetingController.java index b19e9045..4fc5a601 100644 --- a/src/main/java/com/asap/server/controller/MeetingController.java +++ b/src/main/java/com/asap/server/controller/MeetingController.java @@ -9,6 +9,7 @@ import com.asap.server.controller.dto.response.BestMeetingTimeResponseDto; import com.asap.server.controller.dto.response.FixedMeetingResponseDto; import com.asap.server.controller.dto.response.MeetingSaveResponseDto; +import com.asap.server.controller.dto.response.MeetingScheduleResponseDto; import com.asap.server.controller.dto.response.MeetingTitleResponseDto; import com.asap.server.controller.dto.response.TimeTableResponseDto; import com.asap.server.exception.Success; @@ -66,7 +67,7 @@ public SuccessResponse create( @Operation(summary = "[큐 카드] 큐 카드 확정 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "회의 시간 확정 성공입니다."), @ApiResponse(responseCode = "400", description = "1. 회의 진행 월이 입력되지 않았습니다.\n" + "2. 회의 진행 날짜가 입력되지 않았습니다.\n" @@ -103,7 +104,7 @@ public SuccessResponse confirmMeeting( @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @GetMapping("/{meetingId}/schedule") - public SuccessResponse getMeetingSchedule( + public SuccessResponse getMeetingSchedule( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId ) { return SuccessResponse.success(Success.FIND_MEETING_SCHEDULE_SUCCESS, meetingService.getMeetingSchedule(meetingId)); @@ -111,7 +112,7 @@ public SuccessResponse getMeetingSchedule( @Operation(summary = "[큐 카드] 큐 카드 조회 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "큐카드 조회 성공입니다."), @ApiResponse(responseCode = "400", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "403", description = "확정되지 않은 회의입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = "해당 유저는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @@ -129,7 +130,7 @@ public SuccessResponse getFixedMeetingInformation( @GetMapping("/{meetingId}/timetable") @SecurityRequirement(name = "JWT Auth") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "종합 일정 시간표 조회 성공입니다."), @ApiResponse(responseCode = "401", description = "해당 유저는 해당 방의 방장이 아닙니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = @@ -166,7 +167,7 @@ public SuccessResponse getIsFixedMeeting( @Operation(summary = "[회의 일정 확정 뷰] 최적의 회의 시간 확인 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "최적의 회의시간 조회 성공입니다."), @ApiResponse(responseCode = "401", description = "해당 유저는 해당 방의 방장이 아닙니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = "1. 해당 회의는 존재하지 않습니다.\n" diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 32cf5133..33c16364 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -1,5 +1,6 @@ package com.asap.server.controller; +import com.asap.server.common.dto.ErrorDataResponse; import com.asap.server.common.dto.ErrorResponse; import com.asap.server.common.dto.SuccessResponse; import com.asap.server.config.resolver.meeting.MeetingPathVariable; @@ -7,6 +8,9 @@ import com.asap.server.controller.dto.request.AvailableTimeRequestDto; import com.asap.server.controller.dto.request.HostLoginRequestDto; import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; +import com.asap.server.controller.dto.response.HostLoginResponseDto; +import com.asap.server.controller.dto.response.UserMeetingTimeResponseDto; +import com.asap.server.controller.dto.response.UserTimeResponseDto; import com.asap.server.exception.Success; import com.asap.server.service.UserService; import io.swagger.v3.oas.annotations.Operation; @@ -40,7 +44,7 @@ public class UserController { @Operation(summary = "[회의 가능 시간 입력 뷰 - 방장] 방장 가능 시간 입력 API") @SecurityRequirement(name = "JWT Auth") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유효한 회의 입니다."), + @ApiResponse(responseCode = "200", description = "방장의 회의 가능 시간이 성공적으로 입력되었습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" @@ -56,7 +60,7 @@ public class UserController { @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("/host/{meetingId}/time") - public SuccessResponse createHostTime( + public SuccessResponse createHostTime( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody final List<@Valid @NotNull UserMeetingTimeSaveRequestDto> requestDtoList, @UserId @Parameter(hidden = true) final Long userId @@ -66,7 +70,7 @@ public SuccessResponse createHostTime( @Operation(summary = "[회의 가능 시간 입력 뷰 - 참여자] 참여자 정보 및 가능 시간 입력 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "참여자 회의 가능 시간 입력을 성공하였습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" @@ -75,7 +79,7 @@ public SuccessResponse createHostTime( @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("/{meetingId}/time") - public SuccessResponse createMemberTime( + public SuccessResponse createMemberTime( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final AvailableTimeRequestDto requestDto ) { @@ -84,17 +88,17 @@ public SuccessResponse createMemberTime( @Operation(summary = "[방장 입장 뷰] 방장 로그인 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "로그인 성공입니다"), @ApiResponse(responseCode = "400", description = "1. 방장 이름의 최대 입력 길이(8자)를 초과했습니다.\n" + "2. 비밀번호는 4자리 이상 숫자입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "401", description = "유효하지 않은 사용자 이름 또는 비밀번호입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다.", content = @Content(schema = @Schema(implementation = ErrorDataResponse.class))), @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("{meetingId}/host") - public SuccessResponse loginByHost( + public SuccessResponse loginByHost( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final HostLoginRequestDto requestDto ) { From b9d7c68694a26372b0b93d2f4addd5db33a6bf45 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sun, 1 Oct 2023 22:02:24 +0900 Subject: [PATCH 16/37] =?UTF-8?q?#218=20[fix]=20Error=20Response=20?= =?UTF-8?q?=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/MeetingController.java | 11 ++++++----- .../asap/server/controller/UserController.java | 18 +++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/asap/server/controller/MeetingController.java b/src/main/java/com/asap/server/controller/MeetingController.java index b19e9045..4fc5a601 100644 --- a/src/main/java/com/asap/server/controller/MeetingController.java +++ b/src/main/java/com/asap/server/controller/MeetingController.java @@ -9,6 +9,7 @@ import com.asap.server.controller.dto.response.BestMeetingTimeResponseDto; import com.asap.server.controller.dto.response.FixedMeetingResponseDto; import com.asap.server.controller.dto.response.MeetingSaveResponseDto; +import com.asap.server.controller.dto.response.MeetingScheduleResponseDto; import com.asap.server.controller.dto.response.MeetingTitleResponseDto; import com.asap.server.controller.dto.response.TimeTableResponseDto; import com.asap.server.exception.Success; @@ -66,7 +67,7 @@ public SuccessResponse create( @Operation(summary = "[큐 카드] 큐 카드 확정 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "회의 시간 확정 성공입니다."), @ApiResponse(responseCode = "400", description = "1. 회의 진행 월이 입력되지 않았습니다.\n" + "2. 회의 진행 날짜가 입력되지 않았습니다.\n" @@ -103,7 +104,7 @@ public SuccessResponse confirmMeeting( @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @GetMapping("/{meetingId}/schedule") - public SuccessResponse getMeetingSchedule( + public SuccessResponse getMeetingSchedule( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId ) { return SuccessResponse.success(Success.FIND_MEETING_SCHEDULE_SUCCESS, meetingService.getMeetingSchedule(meetingId)); @@ -111,7 +112,7 @@ public SuccessResponse getMeetingSchedule( @Operation(summary = "[큐 카드] 큐 카드 조회 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "큐카드 조회 성공입니다."), @ApiResponse(responseCode = "400", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "403", description = "확정되지 않은 회의입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = "해당 유저는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @@ -129,7 +130,7 @@ public SuccessResponse getFixedMeetingInformation( @GetMapping("/{meetingId}/timetable") @SecurityRequirement(name = "JWT Auth") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "종합 일정 시간표 조회 성공입니다."), @ApiResponse(responseCode = "401", description = "해당 유저는 해당 방의 방장이 아닙니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = @@ -166,7 +167,7 @@ public SuccessResponse getIsFixedMeeting( @Operation(summary = "[회의 일정 확정 뷰] 최적의 회의 시간 확인 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유저 정보 조회 성공"), + @ApiResponse(responseCode = "200", description = "최적의 회의시간 조회 성공입니다."), @ApiResponse(responseCode = "401", description = "해당 유저는 해당 방의 방장이 아닙니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "404", description = "1. 해당 회의는 존재하지 않습니다.\n" diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 32cf5133..33c16364 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -1,5 +1,6 @@ package com.asap.server.controller; +import com.asap.server.common.dto.ErrorDataResponse; import com.asap.server.common.dto.ErrorResponse; import com.asap.server.common.dto.SuccessResponse; import com.asap.server.config.resolver.meeting.MeetingPathVariable; @@ -7,6 +8,9 @@ import com.asap.server.controller.dto.request.AvailableTimeRequestDto; import com.asap.server.controller.dto.request.HostLoginRequestDto; import com.asap.server.controller.dto.request.UserMeetingTimeSaveRequestDto; +import com.asap.server.controller.dto.response.HostLoginResponseDto; +import com.asap.server.controller.dto.response.UserMeetingTimeResponseDto; +import com.asap.server.controller.dto.response.UserTimeResponseDto; import com.asap.server.exception.Success; import com.asap.server.service.UserService; import io.swagger.v3.oas.annotations.Operation; @@ -40,7 +44,7 @@ public class UserController { @Operation(summary = "[회의 가능 시간 입력 뷰 - 방장] 방장 가능 시간 입력 API") @SecurityRequirement(name = "JWT Auth") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "유효한 회의 입니다."), + @ApiResponse(responseCode = "200", description = "방장의 회의 가능 시간이 성공적으로 입력되었습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" @@ -56,7 +60,7 @@ public class UserController { @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("/host/{meetingId}/time") - public SuccessResponse createHostTime( + public SuccessResponse createHostTime( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody final List<@Valid @NotNull UserMeetingTimeSaveRequestDto> requestDtoList, @UserId @Parameter(hidden = true) final Long userId @@ -66,7 +70,7 @@ public SuccessResponse createHostTime( @Operation(summary = "[회의 가능 시간 입력 뷰 - 참여자] 참여자 정보 및 가능 시간 입력 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "참여자 회의 가능 시간 입력을 성공하였습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" @@ -75,7 +79,7 @@ public SuccessResponse createHostTime( @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("/{meetingId}/time") - public SuccessResponse createMemberTime( + public SuccessResponse createMemberTime( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final AvailableTimeRequestDto requestDto ) { @@ -84,17 +88,17 @@ public SuccessResponse createMemberTime( @Operation(summary = "[방장 입장 뷰] 방장 로그인 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "회의 선택지가 성공적으로 조회되었습니다."), + @ApiResponse(responseCode = "200", description = "로그인 성공입니다"), @ApiResponse(responseCode = "400", description = "1. 방장 이름의 최대 입력 길이(8자)를 초과했습니다.\n" + "2. 비밀번호는 4자리 이상 숫자입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "401", description = "유효하지 않은 사용자 이름 또는 비밀번호입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다.", content = @Content(schema = @Schema(implementation = ErrorDataResponse.class))), @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("{meetingId}/host") - public SuccessResponse loginByHost( + public SuccessResponse loginByHost( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, @RequestBody @Valid final HostLoginRequestDto requestDto ) { From ef6ae73c14e2137c90e9fb027c2138694f30ec6b Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Sun, 1 Oct 2023 22:10:02 +0900 Subject: [PATCH 17/37] =?UTF-8?q?#218=20[fix]=20Error=20Response=20?= =?UTF-8?q?=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/controller/UserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 33c16364..8b24c39d 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -94,7 +94,7 @@ public SuccessResponse createMemberTime( + "2. 비밀번호는 4자리 이상 숫자입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "401", description = "유효하지 않은 사용자 이름 또는 비밀번호입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다.", content = @Content(schema = @Schema(implementation = ErrorDataResponse.class))), + @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다."), @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("{meetingId}/host") From 05361d7eab21b438f0d651aa399ad79b1196f81a Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Mon, 2 Oct 2023 15:20:49 +0900 Subject: [PATCH 18/37] =?UTF-8?q?#201=20[fix]=20=ED=9A=8C=EC=9D=98=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5=20=EC=8B=9C=EA=B0=84=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/asap/server/service/MeetingService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 0eac6a31..803b732d 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -5,6 +5,7 @@ import com.asap.server.config.jwt.JwtService; import com.asap.server.controller.dto.request.MeetingConfirmRequestDto; import com.asap.server.controller.dto.request.MeetingSaveRequestDto; +import com.asap.server.controller.dto.request.PreferTimeSaveRequestDto; import com.asap.server.controller.dto.response.AvailableDatesDto; import com.asap.server.controller.dto.response.BestMeetingTimeResponseDto; import com.asap.server.controller.dto.response.FixedMeetingResponseDto; @@ -17,7 +18,9 @@ import com.asap.server.domain.Place; import com.asap.server.domain.User; import com.asap.server.domain.enums.Role; +import com.asap.server.domain.enums.TimeSlot; import com.asap.server.exception.Error; +import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.ConflictException; import com.asap.server.exception.model.ForbiddenException; import com.asap.server.exception.model.NotFoundException; @@ -54,7 +57,9 @@ public class MeetingService { @Transactional public MeetingSaveResponseDto create(final MeetingSaveRequestDto meetingSaveRequestDto) { String encryptedPassword = passwordEncoder.encode(meetingSaveRequestDto.getPassword()); - + if (isPreferTimesDuplicated(meetingSaveRequestDto.getPreferTimes())) { + throw new BadRequestException(Error.DUPLICATED_TIME_EXCEPTION); + } Meeting meeting = Meeting.builder() .title(meetingSaveRequestDto.getTitle()) .password(encryptedPassword) @@ -206,4 +211,10 @@ public BestMeetingTimeResponseDto getBestMeetingTime(final Long meetingId, final return BestMeetingTimeResponseDto.of(userCount, bestMeetingTimes); } + private boolean isPreferTimesDuplicated(List preferTimeSaveRequestDtos) { + List startTimes = preferTimeSaveRequestDtos.stream() + .map(PreferTimeSaveRequestDto::getStartTime) + .collect(Collectors.toList()); + return startTimes.size() != startTimes.stream().distinct().count(); + } } From 863af7ffedd5abadefa3873adde64edf5067b740 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 3 Oct 2023 00:40:26 +0900 Subject: [PATCH 19/37] =?UTF-8?q?#201=20[fix]=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=8A=A4=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/asap/server/service/MeetingService.java | 4 ---- .../com/asap/server/service/PreferTimeService.java | 13 +++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 803b732d..fa5b0ce8 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -20,7 +20,6 @@ import com.asap.server.domain.enums.Role; import com.asap.server.domain.enums.TimeSlot; import com.asap.server.exception.Error; -import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.ConflictException; import com.asap.server.exception.model.ForbiddenException; import com.asap.server.exception.model.NotFoundException; @@ -57,9 +56,6 @@ public class MeetingService { @Transactional public MeetingSaveResponseDto create(final MeetingSaveRequestDto meetingSaveRequestDto) { String encryptedPassword = passwordEncoder.encode(meetingSaveRequestDto.getPassword()); - if (isPreferTimesDuplicated(meetingSaveRequestDto.getPreferTimes())) { - throw new BadRequestException(Error.DUPLICATED_TIME_EXCEPTION); - } Meeting meeting = Meeting.builder() .title(meetingSaveRequestDto.getTitle()) .password(encryptedPassword) diff --git a/src/main/java/com/asap/server/service/PreferTimeService.java b/src/main/java/com/asap/server/service/PreferTimeService.java index 5b071126..cb18676e 100644 --- a/src/main/java/com/asap/server/service/PreferTimeService.java +++ b/src/main/java/com/asap/server/service/PreferTimeService.java @@ -4,7 +4,9 @@ import com.asap.server.controller.dto.response.PreferTimeResponseDto; import com.asap.server.domain.Meeting; import com.asap.server.domain.PreferTime; +import com.asap.server.domain.enums.TimeSlot; import com.asap.server.exception.Error; +import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.NotFoundException; import com.asap.server.repository.PreferTimeRepository; import lombok.RequiredArgsConstructor; @@ -21,6 +23,9 @@ public class PreferTimeService { public void create(final Meeting meeting, final List saveRequestDtos) { + if(isPreferTimeDuplicated(saveRequestDtos)){ + throw new BadRequestException(Error.DUPLICATED_TIME_EXCEPTION); + } saveRequestDtos.stream() .sorted(Comparator.comparing(preferTime -> preferTime.getStartTime().getTime())) .map(preferTime -> preferTimeRepository.save( @@ -46,4 +51,12 @@ public List getPreferTimes(final Meeting meeting) { public void deletePreferTimes(final Meeting meeting) { preferTimeRepository.deleteByMeeting(meeting); } + + private boolean isPreferTimeDuplicated(List requestDtos) { + List timeSlots = requestDtos.stream() + .flatMap(requestDto -> TimeSlot.getTimeSlots(requestDto.getStartTime().ordinal(), requestDto.getEndTime().ordinal()).stream()) + .collect(Collectors.toList()); + System.out.println(timeSlots); + return timeSlots.size() != timeSlots.stream().distinct().count(); + } } From c3964743488406f05ed6300c8b4aeb417a5597be Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 3 Oct 2023 00:43:17 +0900 Subject: [PATCH 20/37] =?UTF-8?q?#201=20[refactor]=20=EB=AF=B8=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EA=B5=AC=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/MeetingService.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index fa5b0ce8..7ef69222 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -206,11 +206,5 @@ public BestMeetingTimeResponseDto getBestMeetingTime(final Long meetingId, final List bestMeetingTimes = bestMeetingUtil.getBestMeetingTime(availableDates, meeting.getDuration(), userCount); return BestMeetingTimeResponseDto.of(userCount, bestMeetingTimes); } - - private boolean isPreferTimesDuplicated(List preferTimeSaveRequestDtos) { - List startTimes = preferTimeSaveRequestDtos.stream() - .map(PreferTimeSaveRequestDto::getStartTime) - .collect(Collectors.toList()); - return startTimes.size() != startTimes.stream().distinct().count(); - } + } From 439005f13246fa527e0e094b779bc4208c04b498 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 3 Oct 2023 00:47:36 +0900 Subject: [PATCH 21/37] =?UTF-8?q?#201=20[refactor]=20=EB=AF=B8=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EA=B5=AC=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/MeetingService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 7ef69222..037f280f 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -5,7 +5,6 @@ import com.asap.server.config.jwt.JwtService; import com.asap.server.controller.dto.request.MeetingConfirmRequestDto; import com.asap.server.controller.dto.request.MeetingSaveRequestDto; -import com.asap.server.controller.dto.request.PreferTimeSaveRequestDto; import com.asap.server.controller.dto.response.AvailableDatesDto; import com.asap.server.controller.dto.response.BestMeetingTimeResponseDto; import com.asap.server.controller.dto.response.FixedMeetingResponseDto; @@ -18,7 +17,6 @@ import com.asap.server.domain.Place; import com.asap.server.domain.User; import com.asap.server.domain.enums.Role; -import com.asap.server.domain.enums.TimeSlot; import com.asap.server.exception.Error; import com.asap.server.exception.model.ConflictException; import com.asap.server.exception.model.ForbiddenException; @@ -206,5 +204,5 @@ public BestMeetingTimeResponseDto getBestMeetingTime(final Long meetingId, final List bestMeetingTimes = bestMeetingUtil.getBestMeetingTime(availableDates, meeting.getDuration(), userCount); return BestMeetingTimeResponseDto.of(userCount, bestMeetingTimes); } - + } From b1b4f3a1f0f0d087e11c1f299f561562f44d07f3 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Tue, 3 Oct 2023 00:50:10 +0900 Subject: [PATCH 22/37] =?UTF-8?q?#201=20[refactor]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=20=EA=B5=AC=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/PreferTimeService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/asap/server/service/PreferTimeService.java b/src/main/java/com/asap/server/service/PreferTimeService.java index cb18676e..9be80a11 100644 --- a/src/main/java/com/asap/server/service/PreferTimeService.java +++ b/src/main/java/com/asap/server/service/PreferTimeService.java @@ -56,7 +56,6 @@ private boolean isPreferTimeDuplicated(List requestDto List timeSlots = requestDtos.stream() .flatMap(requestDto -> TimeSlot.getTimeSlots(requestDto.getStartTime().ordinal(), requestDto.getEndTime().ordinal()).stream()) .collect(Collectors.toList()); - System.out.println(timeSlots); return timeSlots.size() != timeSlots.stream().distinct().count(); } } From 464d568b3c8b43c1c61a2cbc6c3673c6d84562b9 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Mon, 9 Oct 2023 18:54:14 +0900 Subject: [PATCH 23/37] =?UTF-8?q?#221=20[fix]=20=ED=9A=8C=EC=9D=98=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=84=A0=ED=98=B8=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=EB=8C=80=20=EC=A4=91=EB=B3=B5=20=EC=9E=85=EB=A0=A5=20=EC=83=81?= =?UTF-8?q?=ED=99=A9=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/PreferTimeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/asap/server/service/PreferTimeService.java b/src/main/java/com/asap/server/service/PreferTimeService.java index 9be80a11..5c074f63 100644 --- a/src/main/java/com/asap/server/service/PreferTimeService.java +++ b/src/main/java/com/asap/server/service/PreferTimeService.java @@ -23,7 +23,7 @@ public class PreferTimeService { public void create(final Meeting meeting, final List saveRequestDtos) { - if(isPreferTimeDuplicated(saveRequestDtos)){ + if (isPreferTimeDuplicated(saveRequestDtos)) { throw new BadRequestException(Error.DUPLICATED_TIME_EXCEPTION); } saveRequestDtos.stream() @@ -54,7 +54,7 @@ public void deletePreferTimes(final Meeting meeting) { private boolean isPreferTimeDuplicated(List requestDtos) { List timeSlots = requestDtos.stream() - .flatMap(requestDto -> TimeSlot.getTimeSlots(requestDto.getStartTime().ordinal(), requestDto.getEndTime().ordinal()).stream()) + .flatMap(requestDto -> TimeSlot.getTimeSlots(requestDto.getStartTime().ordinal(), requestDto.getEndTime().ordinal() - 1).stream()) .collect(Collectors.toList()); return timeSlots.size() != timeSlots.stream().distinct().count(); } From 9917e4f5127f193b83f04d688095d4890383a4ce Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 10 Oct 2023 03:15:58 +0900 Subject: [PATCH 24/37] =?UTF-8?q?#233=20[test]=20test=20case=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/MeetingConfirmRequestDto.java | 4 + .../dto/request/UserRequestDto.java | 4 + .../java/com/asap/server/domain/Meeting.java | 2 +- .../java/com/asap/server/domain/User.java | 2 +- .../meeting/ConfirmMeetingMethodTest.java | 83 +++++++++++++++++++ 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java diff --git a/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java b/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java index b082cd56..b5ad3c61 100644 --- a/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java +++ b/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java @@ -4,11 +4,15 @@ import java.util.List; import javax.validation.constraints.NotNull; import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class MeetingConfirmRequestDto { @NotNull(message = "회의 진행 월이 입력되지 않았습니다.") private String month; diff --git a/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java b/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java index d9b5c4cd..c439d096 100644 --- a/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java +++ b/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java @@ -1,11 +1,15 @@ package com.asap.server.controller.dto.request; import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class UserRequestDto { private Long id; private String name; diff --git a/src/main/java/com/asap/server/domain/Meeting.java b/src/main/java/com/asap/server/domain/Meeting.java index cc03ab9c..1d4221be 100644 --- a/src/main/java/com/asap/server/domain/Meeting.java +++ b/src/main/java/com/asap/server/domain/Meeting.java @@ -22,7 +22,7 @@ @Entity @Getter @Builder -@AllArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Meeting extends AuditingTimeEntity { @Id diff --git a/src/main/java/com/asap/server/domain/User.java b/src/main/java/com/asap/server/domain/User.java index d7a674db..aa15491b 100644 --- a/src/main/java/com/asap/server/domain/User.java +++ b/src/main/java/com/asap/server/domain/User.java @@ -23,7 +23,7 @@ @Getter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class User extends AuditingTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java new file mode 100644 index 00000000..16110281 --- /dev/null +++ b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java @@ -0,0 +1,83 @@ +package com.asap.server.service.meeting; + +import com.asap.server.controller.dto.request.MeetingConfirmRequestDto; +import com.asap.server.controller.dto.request.UserRequestDto; +import com.asap.server.domain.Meeting; +import com.asap.server.domain.Place; +import com.asap.server.domain.User; +import com.asap.server.domain.enums.Duration; +import com.asap.server.domain.enums.PlaceType; +import com.asap.server.domain.enums.Role; +import com.asap.server.domain.enums.TimeSlot; +import com.asap.server.repository.MeetingRepository; +import com.asap.server.service.MeetingService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import javax.persistence.EntityManager; +import javax.transaction.Transactional; +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +@SpringBootTest +@Transactional +public class ConfirmMeetingMethodTest { + @Autowired + private MeetingService meetingService; + @Autowired + private MeetingRepository meetingRepository; + @Autowired + private EntityManager em; + + @Test + @DisplayName("회의 확정시 ConfirmedDateTime 은 Update 된다.") + void setConfirmDateTimeTest() { + // given + final Place place = Place.builder() + .placeType(PlaceType.OFFLINE) + .build(); + final Meeting meeting = Meeting.builder() + .title("회의 테스트") + .password("0000") + .additionalInfo("") + .duration(Duration.HALF) + .place(place) + .build(); + final User user = User.builder() + .meeting(meeting) + .name("강원용") + .role(Role.HOST) + .isFixed(false) + .build(); + meeting.setHost(user); + + em.persist(meeting); + em.persist(user); + em.flush(); + em.clear(); + + final UserRequestDto userDto = UserRequestDto.builder() + .id(user.getId()) + .name(user.getName()) + .build(); + final MeetingConfirmRequestDto body = MeetingConfirmRequestDto.builder() + .month("09") + .day("07") + .dayOfWeek("월") + .startTime(TimeSlot.SLOT_6_00) + .endTime(TimeSlot.SLOT_6_30) + .users(List.of(userDto)) + .build(); + + // when + meetingService.confirmMeeting(body, meeting.getId(), user.getId()); + + // then + final Meeting result = meetingRepository.findById(meeting.getId()).get(); + assertThat(result.isConfirmedMeeting()).isTrue(); + } + +} From c411935c31e106b67a101959d1f678524b17f07b Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 10 Oct 2023 03:16:36 +0900 Subject: [PATCH 25/37] =?UTF-8?q?#233=20[feat]=20save=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20=ED=86=B5=ED=95=B4=20update=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/MeetingService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 037f280f..a1a6444e 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -98,17 +98,17 @@ public void confirmMeeting( userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); - LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); + deleteMeetingTimes(meeting); + LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); LocalTime startTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getStartTime().getTime()); LocalTime endTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getEndTime().getTime()); LocalDateTime fixedStartDateTime = LocalDateTime.of(fixedDate, startTime); LocalDateTime fixedEndDateTime = LocalDateTime.of(fixedDate, endTime); - meeting.setConfirmedDateTime(fixedStartDateTime, fixedEndDateTime); - deleteMeetingTimes(meeting); + meetingRepository.save(meeting); } private void deleteMeetingTimes(final Meeting meeting) { From 5f778bfe2e8d11958a2e3c2cfb486c453731e155 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 10 Oct 2023 09:27:30 +0900 Subject: [PATCH 26/37] =?UTF-8?q?#233=20[fix]=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=8B=9C=20entity=20manager=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/service/meeting/ConfirmMeetingMethodTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java index 16110281..c81d1b6d 100644 --- a/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java +++ b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java @@ -9,7 +9,6 @@ import com.asap.server.domain.enums.PlaceType; import com.asap.server.domain.enums.Role; import com.asap.server.domain.enums.TimeSlot; -import com.asap.server.repository.MeetingRepository; import com.asap.server.service.MeetingService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -28,8 +27,6 @@ public class ConfirmMeetingMethodTest { @Autowired private MeetingService meetingService; @Autowired - private MeetingRepository meetingRepository; - @Autowired private EntityManager em; @Test @@ -76,7 +73,7 @@ void setConfirmDateTimeTest() { meetingService.confirmMeeting(body, meeting.getId(), user.getId()); // then - final Meeting result = meetingRepository.findById(meeting.getId()).get(); + final Meeting result = em.find(Meeting.class, meeting.getId()); assertThat(result.isConfirmedMeeting()).isTrue(); } From cf935c238943e389c84f4ece42f42c9d3074770c Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 10 Oct 2023 17:33:19 +0900 Subject: [PATCH 27/37] =?UTF-8?q?#255=20[feat]=20error=20data=20response?= =?UTF-8?q?=20to=20string=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/common/dto/ErrorDataResponse.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java index adc284ad..a708a20b 100644 --- a/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java +++ b/src/main/java/com/asap/server/common/dto/ErrorDataResponse.java @@ -7,6 +7,7 @@ public class ErrorDataResponse extends ErrorResponse { private T data; + private ErrorDataResponse(int code, String message, T data) { super(code, message); this.data = data; @@ -15,4 +16,9 @@ private ErrorDataResponse(int code, String message, T data) { public static ErrorDataResponse error(Error error, String message, T data) { return new ErrorDataResponse(error.getHttpStatusCode(), message, data); } + + @Override + public String toString() { + return "code: " + super.getCode() + " message: " + super.getMessage() + " data: " + this.data; + } } From c913efb339e7f910401c495221f60f223968e483 Mon Sep 17 00:00:00 2001 From: KWY Date: Tue, 10 Oct 2023 17:33:36 +0900 Subject: [PATCH 28/37] =?UTF-8?q?#225=20[feat]=20=EA=B0=80=EB=8F=85?= =?UTF-8?q?=EC=84=B1=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/common/aspect/LoggingAspect.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/asap/server/common/aspect/LoggingAspect.java b/src/main/java/com/asap/server/common/aspect/LoggingAspect.java index 72e06386..71ec3429 100644 --- a/src/main/java/com/asap/server/common/aspect/LoggingAspect.java +++ b/src/main/java/com/asap/server/common/aspect/LoggingAspect.java @@ -34,13 +34,15 @@ public Object requestLogging(ProceedingJoinPoint proceedingJoinPoint) throws Thr long startAt = System.currentTimeMillis(); Object returnValue = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs()); long endAt = System.currentTimeMillis(); - log.info("====> Request: {} {} ({}ms)\n *Header = {}\n", request.getMethod(), request.getRequestURL(), endAt - startAt, getHeaders(request)); + log.info("================================================NEW==============================================="); + log.info("====> Request: {} {} ({}ms)\n *Header = {}", request.getMethod(), request.getRequestURL(), endAt - startAt, getHeaders(request)); if ("POST".equalsIgnoreCase(request.getMethod())) { log.info("====> Body: {}", objectMapper.readTree(cachingRequest.getContentAsByteArray())); } if (returnValue != null) { - log.info("====> Response: {}\n", returnValue); + log.info("====> Response: {}", returnValue); } + log.info("================================================END==============================================="); return returnValue; } From 09549e8cfd4367850658fda72b21ad2f90273956 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 11 Oct 2023 17:24:00 +0900 Subject: [PATCH 29/37] =?UTF-8?q?#227=20[feat]=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=82=B4=EC=97=90=EC=84=9C=20meeting=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20fetch=20join=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/repository/MeetingRepository.java | 7 +++++++ src/main/java/com/asap/server/service/UserService.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/repository/MeetingRepository.java b/src/main/java/com/asap/server/repository/MeetingRepository.java index 3c1735f8..92bc8aa0 100644 --- a/src/main/java/com/asap/server/repository/MeetingRepository.java +++ b/src/main/java/com/asap/server/repository/MeetingRepository.java @@ -1,7 +1,10 @@ package com.asap.server.repository; import com.asap.server.domain.Meeting; +import org.springframework.data.jpa.repository.EntityGraph; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; import java.util.Optional; @@ -9,4 +12,8 @@ public interface MeetingRepository extends Repository { Optional findById(final Long id); Meeting save(final Meeting meeting); + + @EntityGraph(attributePaths = {"host"}) + @Query("select m from Meeting m where m.id = :id") + Optional findByIdWithHost(@Param("id") final Long id); } diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 34b1e27c..143db9f5 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -156,7 +156,7 @@ public HostLoginResponseDto loginByHost( final Long meetingId, final HostLoginRequestDto requestDto ) { - Meeting meeting = meetingRepository.findById(meetingId) + Meeting meeting = meetingRepository.findByIdWithHost(meetingId) .orElseThrow(() -> new NotFoundException(Error.MEETING_NOT_FOUND_EXCEPTION)); if (!meeting.checkHostName(requestDto.getName())) From 25824c55add2f7759bee8ee852f5c28f15aad756 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 11 Oct 2023 17:32:25 +0900 Subject: [PATCH 30/37] =?UTF-8?q?#227=20[feat]=20=ED=9A=8C=EC=9D=98=20?= =?UTF-8?q?=ED=99=95=EC=A0=95=20=ED=9B=84=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/repository/AvailableDateRepository.java | 7 ------- .../asap/server/repository/PreferTimeRepository.java | 8 -------- .../asap/server/repository/TimeBlockRepository.java | 9 --------- .../server/repository/TimeBlockUserRepository.java | 4 ---- .../com/asap/server/service/AvailableDateService.java | 10 ---------- .../java/com/asap/server/service/MeetingService.java | 7 ------- .../com/asap/server/service/PreferTimeService.java | 4 ---- .../java/com/asap/server/service/TimeBlockService.java | 8 -------- .../com/asap/server/service/TimeBlockUserService.java | 4 ---- 9 files changed, 61 deletions(-) diff --git a/src/main/java/com/asap/server/repository/AvailableDateRepository.java b/src/main/java/com/asap/server/repository/AvailableDateRepository.java index c7cade90..4a602612 100644 --- a/src/main/java/com/asap/server/repository/AvailableDateRepository.java +++ b/src/main/java/com/asap/server/repository/AvailableDateRepository.java @@ -2,10 +2,7 @@ import com.asap.server.domain.AvailableDate; import com.asap.server.domain.Meeting; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; import java.time.LocalDate; import java.util.List; @@ -17,8 +14,4 @@ public interface AvailableDateRepository extends Repository List findByMeeting(final Meeting meeting); Optional findByMeetingAndDate(final Meeting meeting, final LocalDate date); - - @Modifying(clearAutomatically = true) - @Query("delete from AvailableDate a where a.meeting = :meeting") - void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/PreferTimeRepository.java b/src/main/java/com/asap/server/repository/PreferTimeRepository.java index 44efec4d..8961a7de 100644 --- a/src/main/java/com/asap/server/repository/PreferTimeRepository.java +++ b/src/main/java/com/asap/server/repository/PreferTimeRepository.java @@ -2,10 +2,7 @@ import com.asap.server.domain.Meeting; import com.asap.server.domain.PreferTime; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; import java.util.List; @@ -14,9 +11,4 @@ public interface PreferTimeRepository extends Repository { PreferTime save(final PreferTime preferTime); List findByMeeting(final Meeting meeting); - - - @Modifying(clearAutomatically = true) - @Query("delete from PreferTime p where p.meeting = :meeting") - void deleteByMeeting(@Param("meeting") final Meeting meeting); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockRepository.java b/src/main/java/com/asap/server/repository/TimeBlockRepository.java index ac79bc60..db127579 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockRepository.java @@ -3,10 +3,7 @@ import com.asap.server.domain.AvailableDate; import com.asap.server.domain.TimeBlock; import com.asap.server.domain.enums.TimeSlot; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; @@ -18,10 +15,4 @@ public interface TimeBlockRepository extends Repository { List findByAvailableDate(final AvailableDate availableDate); Optional findByAvailableDateAndTimeSlot(final AvailableDate availableDate, TimeSlot timeSlot); - - List findByAvailableDateIn(final List availableDates); - - @Modifying(clearAutomatically = true) - @Query("delete from TimeBlock t where t.availableDate in :availableDates") - void deleteByAvailableDatesIn(@Param("availableDates") final List availableDates); } diff --git a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java index acdbde4f..bdfc24c9 100644 --- a/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java +++ b/src/main/java/com/asap/server/repository/TimeBlockUserRepository.java @@ -17,8 +17,4 @@ public interface TimeBlockUserRepository extends Repository List findAllByUser(final User user); List findByTimeBlock(final TimeBlock timeBlock); - - @Modifying(clearAutomatically = true) - @Query("delete from TimeBlockUser t where t.timeBlock in :timeblocks") - void deleteByTimeBlocksIn(@Param("timeblocks") final List timeBlocks); } diff --git a/src/main/java/com/asap/server/service/AvailableDateService.java b/src/main/java/com/asap/server/service/AvailableDateService.java index ce66dc8b..fccc13d1 100644 --- a/src/main/java/com/asap/server/service/AvailableDateService.java +++ b/src/main/java/com/asap/server/service/AvailableDateService.java @@ -6,7 +6,6 @@ import com.asap.server.controller.dto.response.TimeSlotDto; import com.asap.server.domain.AvailableDate; import com.asap.server.domain.Meeting; -import com.asap.server.domain.TimeBlock; import com.asap.server.exception.Error; import com.asap.server.exception.model.BadRequestException; import com.asap.server.exception.model.NotFoundException; @@ -115,13 +114,4 @@ public void create(final Meeting meeting, final List availableDates) { private boolean isDuplicatedDate(final List availableDates) { return availableDates.size() != availableDates.stream().distinct().count(); } - - public void deleteUserTimes(final Meeting meeting) { - List availableDates = availableDateRepository.findByMeeting(meeting); - List timeBlocks = timeBlockService.findByAvailableDateIn(availableDates); - - timeBlockUserService.deleteTimeBlockUsers(timeBlocks); - timeBlockService.deleteTimeBlocks(availableDates); - availableDateRepository.deleteByMeeting(meeting); - } } diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index a1a6444e..5b6bae9d 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -98,8 +98,6 @@ public void confirmMeeting( userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); - deleteMeetingTimes(meeting); - LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); LocalTime startTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getStartTime().getTime()); LocalTime endTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getEndTime().getTime()); @@ -111,11 +109,6 @@ public void confirmMeeting( meetingRepository.save(meeting); } - private void deleteMeetingTimes(final Meeting meeting) { - availableDateService.deleteUserTimes(meeting); - preferTimeService.deletePreferTimes(meeting); - } - @Transactional(readOnly = true) public MeetingScheduleResponseDto getMeetingSchedule(Long meetingId) { Meeting meeting = meetingRepository.findById(meetingId) diff --git a/src/main/java/com/asap/server/service/PreferTimeService.java b/src/main/java/com/asap/server/service/PreferTimeService.java index 5c074f63..6153cdcd 100644 --- a/src/main/java/com/asap/server/service/PreferTimeService.java +++ b/src/main/java/com/asap/server/service/PreferTimeService.java @@ -48,10 +48,6 @@ public List getPreferTimes(final Meeting meeting) { .collect(Collectors.toList()); } - public void deletePreferTimes(final Meeting meeting) { - preferTimeRepository.deleteByMeeting(meeting); - } - private boolean isPreferTimeDuplicated(List requestDtos) { List timeSlots = requestDtos.stream() .flatMap(requestDto -> TimeSlot.getTimeSlots(requestDto.getStartTime().ordinal(), requestDto.getEndTime().ordinal() - 1).stream()) diff --git a/src/main/java/com/asap/server/service/TimeBlockService.java b/src/main/java/com/asap/server/service/TimeBlockService.java index 86dba8b2..88aa15cb 100644 --- a/src/main/java/com/asap/server/service/TimeBlockService.java +++ b/src/main/java/com/asap/server/service/TimeBlockService.java @@ -51,12 +51,4 @@ private TimeBlock create(final TimeSlot timeSlot, final AvailableDate availableD public List getTimeBlocksByAvailableDate(final AvailableDate availableDate) { return timeBlockRepository.findByAvailableDate(availableDate); } - - public List findByAvailableDateIn(final List availableDates) { - return timeBlockRepository.findByAvailableDateIn(availableDates); - } - - public void deleteTimeBlocks(final List availableDates) { - timeBlockRepository.deleteByAvailableDatesIn(availableDates); - } } diff --git a/src/main/java/com/asap/server/service/TimeBlockUserService.java b/src/main/java/com/asap/server/service/TimeBlockUserService.java index 46b75745..e188e4d8 100644 --- a/src/main/java/com/asap/server/service/TimeBlockUserService.java +++ b/src/main/java/com/asap/server/service/TimeBlockUserService.java @@ -48,8 +48,4 @@ public boolean isEmptyHostTimeBlock(final User user) { return hostTimeBlocks.isEmpty(); } - public void deleteTimeBlockUsers(final List timeBlocks) { - timeBlockUserRepository.deleteByTimeBlocksIn(timeBlocks); - } - } \ No newline at end of file From fa89b27695a10a6f208a5b9568c0c504f433e686 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 11 Oct 2023 17:57:04 +0900 Subject: [PATCH 31/37] =?UTF-8?q?#227=20[feat]=20save=20=ED=9B=84=20?= =?UTF-8?q?=EB=B0=94=EB=A1=9C=20flush=20=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/repository/MeetingRepository.java | 2 ++ src/main/java/com/asap/server/service/MeetingService.java | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/asap/server/repository/MeetingRepository.java b/src/main/java/com/asap/server/repository/MeetingRepository.java index 92bc8aa0..7857163e 100644 --- a/src/main/java/com/asap/server/repository/MeetingRepository.java +++ b/src/main/java/com/asap/server/repository/MeetingRepository.java @@ -13,6 +13,8 @@ public interface MeetingRepository extends Repository { Meeting save(final Meeting meeting); + void saveAndFlush(final Meeting meeting); + @EntityGraph(attributePaths = {"host"}) @Query("select m from Meeting m where m.id = :id") Optional findByIdWithHost(@Param("id") final Long id); diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 5b6bae9d..1a32eeff 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -96,8 +96,6 @@ public void confirmMeeting( if (!meeting.authenticateHost(userId)) throw new UnauthorizedException(INVALID_MEETING_HOST_EXCEPTION); - userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); - LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); LocalTime startTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getStartTime().getTime()); LocalTime endTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getEndTime().getTime()); @@ -106,7 +104,9 @@ public void confirmMeeting( LocalDateTime fixedEndDateTime = LocalDateTime.of(fixedDate, endTime); meeting.setConfirmedDateTime(fixedStartDateTime, fixedEndDateTime); - meetingRepository.save(meeting); + meetingRepository.saveAndFlush(meeting); + + userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); } @Transactional(readOnly = true) From e0b077edc85de594f540cba1e33425909e8d6aa2 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 11 Oct 2023 18:00:09 +0900 Subject: [PATCH 32/37] =?UTF-8?q?#227=20[chore]=20swagger=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/controller/UserController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 8b24c39d..5bf47e56 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -44,7 +44,7 @@ public class UserController { @Operation(summary = "[회의 가능 시간 입력 뷰 - 방장] 방장 가능 시간 입력 API") @SecurityRequirement(name = "JWT Auth") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "방장의 회의 가능 시간이 성공적으로 입력되었습니다."), + @ApiResponse(responseCode = "201", description = "방장의 회의 가능 시간이 성공적으로 입력되었습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" @@ -70,7 +70,7 @@ public SuccessResponse createHostTime( @Operation(summary = "[회의 가능 시간 입력 뷰 - 참여자] 참여자 정보 및 가능 시간 입력 API") @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "참여자 회의 가능 시간 입력을 성공하였습니다."), + @ApiResponse(responseCode = "201", description = "참여자 회의 가능 시간 입력을 성공하였습니다."), @ApiResponse(responseCode = "400", description = "1. 시간 형식이 잘못되었습니다. [YYYY/MM/DD HH:MM]\n" + "2. 중복 입력된 시간이 있습니다.\n" From ed3968e90e66e12ebcd48db66db0185a1c56a078 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 12 Oct 2023 01:27:13 +0900 Subject: [PATCH 33/37] =?UTF-8?q?#229=20[fix]=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=EC=9E=90=20=ED=9A=8C=EC=9D=98=20=EA=B0=80=EB=8A=A5=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=A4=91=EB=B3=B5=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/service/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 34b1e27c..f3444664 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -88,7 +88,7 @@ public UserTimeResponseDto createUserTime(final Long meetingId, .orElseThrow(() -> new NotFoundException(Error.MEETING_NOT_FOUND_EXCEPTION)); User user = createUser(meeting, requestDto.getName(), Role.MEMBER); - + isDuplicatedDate(requestDto.getAvailableTimes()); requestDto.getAvailableTimes().forEach(availableTime -> createUserTimeBlock(meeting, user, availableTime)); return UserTimeResponseDto.builder() From 25a1e6192e7c375a172379494072f3075c1f0d57 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 12 Oct 2023 11:32:48 +0900 Subject: [PATCH 34/37] =?UTF-8?q?#150=20[feat]=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=A6=AC=ED=84=B4=20=EA=B0=92=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advice/ControllerExceptionAdvice.java | 97 ++++++++++--------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java index 48e38a86..21e4bbec 100644 --- a/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java +++ b/src/main/java/com/asap/server/common/advice/ControllerExceptionAdvice.java @@ -6,7 +6,12 @@ import com.asap.server.controller.dto.response.HostLoginResponseDto; import com.asap.server.exception.Error; import com.asap.server.exception.model.AsapException; +import com.asap.server.exception.model.BadRequestException; +import com.asap.server.exception.model.ConflictException; +import com.asap.server.exception.model.ForbiddenException; import com.asap.server.exception.model.HostTimeForbiddenException; +import com.asap.server.exception.model.NotFoundException; +import com.asap.server.exception.model.UnauthorizedException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; @@ -50,12 +55,6 @@ protected ErrorResponse handleMethodArgumentNotValidException(final MethodArgume else return ErrorResponse.error(Error.VALIDATION_REQUEST_MISSING_EXCEPTION, fieldError.getDefaultMessage()); } - @ResponseStatus(HttpStatus.NOT_FOUND) - @ExceptionHandler(NoHandlerFoundException.class) - public ErrorResponse handleNotFoundException(NoHandlerFoundException exception) { - return ErrorResponse.error(Error.URI_NOT_FOUND_EXCEPTION); - } - @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(HttpMessageNotReadableException.class) protected ErrorResponse handleJsonParseException(final HttpMessageNotReadableException e) { @@ -68,61 +67,71 @@ protected ErrorResponse handleValidationException(final ConstraintViolationExcep return ErrorResponse.error(Error.VALIDATION_REQUEST_MISSING_EXCEPTION); } + + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ExceptionHandler(BadRequestException.class) + protected ErrorResponse handleBadRequestException(final BadRequestException e) { + return ErrorResponse.error(e.getError()); + } + /** - * 405 Method Not Allowed - * 지원하지 않은 HTTP method 호출 할 경우 발생하는 Exception + * 401 UnAuthorization */ - @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) - @ExceptionHandler(HttpRequestMethodNotSupportedException.class) - protected ErrorResponse handleHttpRequestMethodNotSupportedException( - HttpRequestMethodNotSupportedException exception) { - return ErrorResponse.error(METHOD_NOT_ALLOWED_EXCEPTION); + @ResponseStatus(HttpStatus.UNAUTHORIZED) + @ExceptionHandler(UnauthorizedException.class) + protected ErrorResponse handleUnAuthorizedException(final UnauthorizedException e) { + return ErrorResponse.error(e.getError()); } -// /** -// * 401 UnAuthorization -// */ -// @ResponseStatus(HttpStatus.UNAUTHORIZED) -// @ExceptionHandler(UnauthorizedException.class) -// protected ErrorResponse handleUnAuthorizedException(final UnauthorizedException e) { -// return ErrorResponse.error(e.getError()); -// } -// -// /** -// * 403 Forbidden -// */ -// @ResponseStatus(HttpStatus.FORBIDDEN) -// @ExceptionHandler(ForbiddenException.class) -// protected ErrorResponse handleForbiddenException(final ForbiddenException e) { -// return ErrorResponse.error(e.getError()); -// } - /** * 403 Forbidden */ + @ResponseStatus(HttpStatus.FORBIDDEN) + @ExceptionHandler(ForbiddenException.class) + protected ErrorResponse handleForbiddenException(final ForbiddenException e) { + return ErrorResponse.error(e.getError()); + } + @ResponseStatus(HttpStatus.FORBIDDEN) @ExceptionHandler(HostTimeForbiddenException.class) protected ErrorDataResponse handleForbiddenException(final HostTimeForbiddenException e) { return ErrorDataResponse.error(e.getError(), e.getMessage(), e.getData()); } -// /** -// * 404 Not Found -// */ -// @ResponseStatus(HttpStatus.NOT_FOUND) -// @ExceptionHandler(NotFoundException.class) -// protected ErrorResponse handleNotFoundException(final NotFoundException e) { -// return ErrorResponse.error(e.getError()); -// } + /** + * 404 Not Found + */ + @ResponseStatus(HttpStatus.NOT_FOUND) + @ExceptionHandler(NotFoundException.class) + protected ErrorResponse handleNotFoundException(final NotFoundException e) { + return ErrorResponse.error(e.getError()); + } + + @ResponseStatus(HttpStatus.NOT_FOUND) + @ExceptionHandler(NoHandlerFoundException.class) + public ErrorResponse handleNotFoundException(NoHandlerFoundException exception) { + return ErrorResponse.error(Error.URI_NOT_FOUND_EXCEPTION); + } + + /** + * 405 Method Not Allowed + * 지원하지 않은 HTTP method 호출 할 경우 발생하는 Exception + */ + @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) + @ExceptionHandler(HttpRequestMethodNotSupportedException.class) + protected ErrorResponse handleHttpRequestMethodNotSupportedException( + HttpRequestMethodNotSupportedException exception) { + return ErrorResponse.error(METHOD_NOT_ALLOWED_EXCEPTION); + } /** * 409 Conflict */ -// @ResponseStatus(HttpStatus.CONFLICT) -// @ExceptionHandler(ConflictException.class) -// protected ErrorResponse handleConflictException(final ConflictException e) { -// return ErrorResponse.error(e.getError()); -// } + @ResponseStatus(HttpStatus.CONFLICT) + @ExceptionHandler(ConflictException.class) + protected ErrorResponse handleConflictException(final ConflictException e) { + return ErrorResponse.error(e.getError()); + } /** * 500 Internal Server From 089a7984ff941816d44f3e0d1412e38060044c16 Mon Sep 17 00:00:00 2001 From: KWY Date: Mon, 16 Oct 2023 22:07:23 +0900 Subject: [PATCH 35/37] =?UTF-8?q?#232=20[feat]=20=ED=99=95=EC=A0=95?= =?UTF-8?q?=EB=90=9C=20=ED=9A=8C=EC=9D=98=EB=A5=BC=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=8B=9C=20409=20=EC=97=90=EB=9F=AC=20=EB=B0=98?= =?UTF-8?q?=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/controller/UserController.java | 3 ++- src/main/java/com/asap/server/service/UserService.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/controller/UserController.java b/src/main/java/com/asap/server/controller/UserController.java index 5bf47e56..00cb2a4a 100644 --- a/src/main/java/com/asap/server/controller/UserController.java +++ b/src/main/java/com/asap/server/controller/UserController.java @@ -95,7 +95,8 @@ public SuccessResponse createMemberTime( content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "401", description = "유효하지 않은 사용자 이름 또는 비밀번호입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "403", description = "회의 가능 시간이 입력되지 않았습니다."), - @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + @ApiResponse(responseCode = "404", description = "해당 회의는 존재하지 않습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "409", description = "이미 확정된 회의입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @PostMapping("{meetingId}/host") public SuccessResponse loginByHost( diff --git a/src/main/java/com/asap/server/service/UserService.java b/src/main/java/com/asap/server/service/UserService.java index 83ffc190..bb32297a 100644 --- a/src/main/java/com/asap/server/service/UserService.java +++ b/src/main/java/com/asap/server/service/UserService.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import static com.asap.server.exception.Error.INVALID_MEETING_HOST_EXCEPTION; +import static com.asap.server.exception.Error.MEETING_VALIDATION_FAILED_EXCEPTION; import static com.asap.server.exception.Error.USER_NOT_FOUND_EXCEPTION; @@ -165,6 +166,9 @@ public HostLoginResponseDto loginByHost( if (!passwordEncoder.matches(requestDto.getPassword(), meeting.getPassword())) throw new UnauthorizedException(Error.INVALID_HOST_ID_PASSWORD_EXCEPTION); + if (meeting.isConfirmedMeeting()) + throw new ConflictException(MEETING_VALIDATION_FAILED_EXCEPTION); + HostLoginResponseDto responseDto = HostLoginResponseDto .builder() .accessToken(jwtService.issuedToken(meeting.getHost().getId().toString())) From b48cb545607842c91c6a7f7972957180b94f4991 Mon Sep 17 00:00:00 2001 From: KWY Date: Mon, 16 Oct 2023 22:25:10 +0900 Subject: [PATCH 36/37] =?UTF-8?q?#232=20[feat]=20=ED=99=95=EC=A0=95?= =?UTF-8?q?=EB=90=9C=20=ED=9A=8C=EC=9D=98=EC=9D=98=20=EC=A2=85=ED=95=A9=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=20=EC=8B=9C=EA=B0=84=ED=91=9C=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EC=8B=9C=20409=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/asap/server/controller/MeetingController.java | 4 +++- src/main/java/com/asap/server/service/MeetingService.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/asap/server/controller/MeetingController.java b/src/main/java/com/asap/server/controller/MeetingController.java index 4fc5a601..dd808ee7 100644 --- a/src/main/java/com/asap/server/controller/MeetingController.java +++ b/src/main/java/com/asap/server/controller/MeetingController.java @@ -138,7 +138,9 @@ public SuccessResponse getFixedMeetingInformation( + "2. 해당 유저는 존재하지 않습니다.\n" + "3. 회의 가능 일자가 존재하지 않습니다.\n" + "4. 해당 회의의 가능 시간을 입력한 유저가 없습니다.", - content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "409", description = "이미 확정된 회의입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) public SuccessResponse getTimeTable( @Parameter(schema = @Schema(implementation = String.class), in = ParameterIn.PATH) @MeetingPathVariable final Long meetingId, diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 1a32eeff..67055424 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -160,6 +160,9 @@ public TimeTableResponseDto getTimeTable(final Long userId, final Long meetingId if (!meeting.authenticateHost(userId)) throw new UnauthorizedException(INVALID_MEETING_HOST_EXCEPTION); + if (meeting.isConfirmedMeeting()) + throw new ConflictException(MEETING_VALIDATION_FAILED_EXCEPTION); + List memberNames = userService.findUserNameByMeeting(meeting); List availableDatesDtos = availableDateService.findAvailableDateByMeeting(meeting).stream() From 04f53e34e738a679f0c2e165e32f220a2469c537 Mon Sep 17 00:00:00 2001 From: KWY Date: Mon, 16 Oct 2023 22:25:33 +0900 Subject: [PATCH 37/37] =?UTF-8?q?#232=20[feat]=20=ED=99=95=EC=A0=95?= =?UTF-8?q?=EB=90=9C=20=ED=9A=8C=EC=9D=98=EC=9D=98=20=EC=B5=9C=EC=A0=81?= =?UTF-8?q?=EC=9D=98=20=ED=9A=8C=EC=9D=98=EC=8B=9C=EA=B0=84=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EC=8B=9C=20409=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/asap/server/controller/MeetingController.java | 1 + src/main/java/com/asap/server/service/MeetingService.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/asap/server/controller/MeetingController.java b/src/main/java/com/asap/server/controller/MeetingController.java index dd808ee7..f45ef921 100644 --- a/src/main/java/com/asap/server/controller/MeetingController.java +++ b/src/main/java/com/asap/server/controller/MeetingController.java @@ -175,6 +175,7 @@ public SuccessResponse getIsFixedMeeting( description = "1. 해당 회의는 존재하지 않습니다.\n" + "2. 회의 가능 일자가 존재하지 않습니다." , content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "409", description = "이미 확정된 회의입니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) @GetMapping("/{meetingId}/details") diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 67055424..6634b9dd 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -193,6 +193,7 @@ public BestMeetingTimeResponseDto getBestMeetingTime(final Long meetingId, final .orElseThrow(() -> new NotFoundException(Error.MEETING_NOT_FOUND_EXCEPTION)); if (!meeting.authenticateHost(userId)) throw new UnauthorizedException(Error.INVALID_MEETING_HOST_EXCEPTION); + if (meeting.isConfirmedMeeting()) throw new ConflictException(MEETING_VALIDATION_FAILED_EXCEPTION); int userCount = userService.getMeetingUserCount(meeting); List availableDates = availableDateService.getAvailableDateVos(meeting);