From a5ec184bdcde84152648075efe5d22ccd29cae1d Mon Sep 17 00:00:00 2001 From: DongHoon Lee <125895298+hoonyworld@users.noreply.github.com> Date: Sun, 1 Dec 2024 01:41:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[feat]=20#265=20-=20Enum=20Custom=20Convert?= =?UTF-8?q?er=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EA=B8=B0=ED=83=80=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EC=99=84=EB=A3=8C=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [#256] refactor: 생성자 private로 변경 * [#256] fix: 오탈자 수정 * [#256] test(GuestBookingServiceConcurrencyTest): 변경된 필드 테스트에 반영 * [#256] feat: enum custom converter 구현 * [#256] fix(PerformanceImage): 테이블명과 겹치지 않게 공연이미지 변수명 수정 * [#256] feat(GlobalExceptionHandler): MethodArgumentTypeMismatchException handler 등록 * [#256] fix(Performance): 자료형을 tinytext에서 longtext로 수정 --- .../beat/domain/booking/domain/Booking.java | 4 ++-- .../com/beat/domain/cast/domain/Cast.java | 4 ++-- .../com/beat/domain/member/domain/Member.java | 2 +- .../PerformanceManagementService.java | 8 +++---- .../application/PerformanceModifyService.java | 10 ++++---- .../application/PerformanceService.java | 8 +++---- .../dto/create/PerformanceRequest.java | 4 ++-- .../dto/create/PerformanceResponse.java | 6 ++--- .../PerformanceModifyDetailResponse.java | 6 ++--- .../dto/modify/PerformanceModifyRequest.java | 4 ++-- .../dto/modify/PerformanceModifyResponse.java | 8 +++---- .../performance/domain/Performance.java | 21 ++++++++-------- .../performance/domain/PerformanceImage.java | 14 +++++------ .../domain/promotion/domain/Promotion.java | 4 ++-- .../beat/domain/schedule/domain/Schedule.java | 4 ++-- .../com/beat/domain/staff/domain/Staff.java | 2 +- .../com/beat/domain/user/domain/Users.java | 4 ++-- .../beat/global/common/config/WebConfig.java | 10 +++++++- .../StringToEnumCustomConverterFactory.java | 24 +++++++++++++++++++ .../handler/GlobalExceptionHandler.java | 16 ++++++++++++- .../GuestBookingServiceConcurrencyTest.java | 12 ++++++---- 21 files changed, 113 insertions(+), 62 deletions(-) create mode 100644 src/main/java/com/beat/global/common/converter/StringToEnumCustomConverterFactory.java diff --git a/src/main/java/com/beat/domain/booking/domain/Booking.java b/src/main/java/com/beat/domain/booking/domain/Booking.java index 810da8f9..c497e17e 100644 --- a/src/main/java/com/beat/domain/booking/domain/Booking.java +++ b/src/main/java/com/beat/domain/booking/domain/Booking.java @@ -79,7 +79,7 @@ public class Booking { private Users users; @Builder - public Booking(int purchaseTicketCount, String bookerName, String bookerPhoneNumber, BookingStatus bookingStatus, + private Booking(int purchaseTicketCount, String bookerName, String bookerPhoneNumber, BookingStatus bookingStatus, String birthDate, String password, BankName bankName, String accountNumber, String accountHolder, Schedule schedule, Users users) { this.purchaseTicketCount = purchaseTicketCount; @@ -126,4 +126,4 @@ public void updateRefundInfo(BankName bankName, String accountNumber, String acc this.accountHolder = accountHolder; this.bookingStatus = BookingStatus.REFUND_REQUESTED; } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/cast/domain/Cast.java b/src/main/java/com/beat/domain/cast/domain/Cast.java index 016ad85f..2a127d54 100644 --- a/src/main/java/com/beat/domain/cast/domain/Cast.java +++ b/src/main/java/com/beat/domain/cast/domain/Cast.java @@ -42,7 +42,7 @@ public class Cast { private Performance performance; @Builder - public Cast(String castName, String castRole, String castPhoto, Performance performance) { + private Cast(String castName, String castRole, String castPhoto, Performance performance) { this.castName = castName; this.castRole = castRole; this.castPhoto = castPhoto; @@ -63,4 +63,4 @@ public void update(String castName, String castRole, String castPhoto) { this.castRole = castRole; this.castPhoto = castPhoto; } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/member/domain/Member.java b/src/main/java/com/beat/domain/member/domain/Member.java index bfa51193..e9de56e1 100644 --- a/src/main/java/com/beat/domain/member/domain/Member.java +++ b/src/main/java/com/beat/domain/member/domain/Member.java @@ -53,7 +53,7 @@ public class Member extends BaseTimeEntity { private SocialType socialType; @Builder - public Member(String nickname, String email, LocalDateTime deletedAt, Users user, Long socialId, + private Member(String nickname, String email, LocalDateTime deletedAt, Users user, Long socialId, SocialType socialType) { this.nickname = nickname; this.email = email; diff --git a/src/main/java/com/beat/domain/performance/application/PerformanceManagementService.java b/src/main/java/com/beat/domain/performance/application/PerformanceManagementService.java index b78fd679..e0231321 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceManagementService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceManagementService.java @@ -73,7 +73,7 @@ public PerformanceResponse createPerformance(Long memberId, PerformanceRequest r request.roadAddressName(), request.placeDetailAddress(), request.latitude(), - request.longtitude(), + request.longitude(), request.performanceContact(), " ", // 이후 dto performancePeriod 제외 필요 request.ticketPrice(), @@ -173,7 +173,7 @@ private PerformanceResponse mapToPerformanceResponse(Performance performance, Li List performanceImageResponses = performanceImages.stream() .map(image -> PerformanceImageResponse.of( image.getId(), - image.getPerformanceImage() + image.getPerformanceImageUrl() )) .collect(Collectors.toList()); @@ -194,7 +194,7 @@ private PerformanceResponse mapToPerformanceResponse(Performance performance, Li performance.getRoadAddressName(), performance.getPlaceDetailAddress(), performance.getLatitude(), - performance.getLongtitude(), + performance.getLongitude(), performance.getPerformanceContact(), performance.getPerformancePeriod(), performance.getTicketPrice(), @@ -240,4 +240,4 @@ public void deletePerformance(Long memberId, Long performanceId) { performanceRepository.delete(performance); } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java index b1aac97a..93b6e51c 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java @@ -140,7 +140,7 @@ private void updatePerformanceDetails(Performance performance, PerformanceModify request.roadAddressName(), request.placeDetailAddress(), request.latitude(), - request.longtitude(), + request.longitude(), request.performanceContact(), request.performancePeriod(), request.totalScheduleCount() @@ -518,7 +518,7 @@ private PerformanceImageModifyResponse addPerformanceImage(PerformanceImageModif log.debug("Added performanceImage: {}", savedPerformanceImage.getId()); return PerformanceImageModifyResponse.of( savedPerformanceImage.getId(), - savedPerformanceImage.getPerformanceImage() + savedPerformanceImage.getPerformanceImageUrl() ); } @@ -543,7 +543,7 @@ private PerformanceImageModifyResponse updatePerformanceImage(PerformanceImageMo log.debug("Updated performanceImage: {}", performanceImage.getId()); return PerformanceImageModifyResponse.of( performanceImage.getId(), - performanceImage.getPerformanceImage() + performanceImage.getPerformanceImageUrl() ); } @@ -589,7 +589,7 @@ private PerformanceModifyResponse completeModifyResponse( performance.getRoadAddressName(), performance.getPlaceDetailAddress(), performance.getLatitude(), - performance.getLongtitude(), + performance.getLongitude(), performance.getPerformanceContact(), performance.getPerformancePeriod(), performance.getTicketPrice(), @@ -602,4 +602,4 @@ private PerformanceModifyResponse completeModifyResponse( log.info("PerformanceModifyResponse created successfully for performanceId: {}", performance.getId()); return response; } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/application/PerformanceService.java b/src/main/java/com/beat/domain/performance/application/PerformanceService.java index 0b1c3c51..588a2774 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceService.java @@ -95,7 +95,7 @@ public PerformanceDetailResponse getPerformanceDetail(Long performanceId) { List performanceImageList = performanceImageRepository.findAllByPerformanceId( performanceId) .stream() - .map(image -> PerformanceDetailImageResponse.of(image.getId(), image.getPerformanceImage())) + .map(image -> PerformanceDetailImageResponse.of(image.getId(), image.getPerformanceImageUrl())) .collect(Collectors.toList()); log.info("Successfully completed getPerformanceDetail for performanceId: {}", performanceId); @@ -103,7 +103,7 @@ public PerformanceDetailResponse getPerformanceDetail(Long performanceId) { performance.getPerformancePeriod(), scheduleList, performance.getTicketPrice(), performance.getGenre().name(), performance.getPosterImage(), performance.getRunningTime(), performance.getPerformanceVenue(), performance.getRoadAddressName(), performance.getPlaceDetailAddress(), - performance.getLatitude(), performance.getLongtitude(), performance.getPerformanceDescription(), + performance.getLatitude(), performance.getLongitude(), performance.getPerformanceDescription(), performance.getPerformanceAttentionNote(), performance.getPerformanceContact(), performance.getPerformanceTeamName(), castList, staffList, minDueDate, performanceImageList); } @@ -216,7 +216,7 @@ private PerformanceModifyDetailResponse mapToPerformanceEditResponse(Performance List performanceImageResponses = performanceImages.stream() .map(performanceImage -> PerformanceImageResponse.of(performanceImage.getId(), - performanceImage.getPerformanceImage())) + performanceImage.getPerformanceImageUrl())) .collect(Collectors.toList()); return PerformanceModifyDetailResponse.of(performance.getUsers().getId(), performance.getId(), @@ -225,7 +225,7 @@ private PerformanceModifyDetailResponse mapToPerformanceEditResponse(Performance performance.getBankName(), performance.getAccountNumber(), performance.getAccountHolder(), performance.getPosterImage(), performance.getPerformanceTeamName(), performance.getPerformanceVenue(), performance.getRoadAddressName(), performance.getPlaceDetailAddress(), performance.getLatitude(), - performance.getLongtitude(), + performance.getLongitude(), performance.getPerformanceContact(), performance.getPerformancePeriod(), performance.getTicketPrice(), performance.getTotalScheduleCount(), isBookerExist, scheduleResponses, castResponses, staffResponses, performanceImageResponses); diff --git a/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceRequest.java b/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceRequest.java index 4c4ce548..483828ac 100644 --- a/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceRequest.java +++ b/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceRequest.java @@ -23,7 +23,7 @@ public record PerformanceRequest( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -33,4 +33,4 @@ public record PerformanceRequest( List staffList, List performanceImageList ) { -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceResponse.java b/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceResponse.java index ade659c8..c3aeddea 100644 --- a/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceResponse.java +++ b/src/main/java/com/beat/domain/performance/application/dto/create/PerformanceResponse.java @@ -22,7 +22,7 @@ public record PerformanceResponse( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -49,7 +49,7 @@ public static PerformanceResponse of( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -76,7 +76,7 @@ public static PerformanceResponse of( roadAddressName, placeDetailAddress, latitude, - longtitude, + longitude, performanceContact, performancePeriod, ticketPrice, diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyDetailResponse.java b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyDetailResponse.java index 69cf6192..b28e5de8 100644 --- a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyDetailResponse.java +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyDetailResponse.java @@ -26,7 +26,7 @@ public record PerformanceModifyDetailResponse( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -54,7 +54,7 @@ public static PerformanceModifyDetailResponse of( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -82,7 +82,7 @@ public static PerformanceModifyDetailResponse of( roadAddressName, placeDetailAddress, latitude, - longtitude, + longitude, performanceContact, performancePeriod, ticketPrice, diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java index c186f6d0..b731d2fc 100644 --- a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java @@ -29,7 +29,7 @@ public record PerformanceModifyRequest( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int totalScheduleCount, @@ -39,4 +39,4 @@ public record PerformanceModifyRequest( List staffModifyRequests, List performanceImageModifyRequests ) { -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java index 8c9fdeeb..b9aa2c08 100644 --- a/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java @@ -26,7 +26,7 @@ public record PerformanceModifyResponse( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -53,7 +53,7 @@ public static PerformanceModifyResponse of( String roadAddressName, String placeDetailAddress, String latitude, - String longtitude, + String longitude, String performanceContact, String performancePeriod, int ticketPrice, @@ -80,7 +80,7 @@ public static PerformanceModifyResponse of( roadAddressName, placeDetailAddress, latitude, - longtitude, + longitude, performanceContact, performancePeriod, ticketPrice, @@ -91,4 +91,4 @@ public static PerformanceModifyResponse of( performanceImageModifyResponses ); } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/domain/Performance.java b/src/main/java/com/beat/domain/performance/domain/Performance.java index 261da7cd..efd302c1 100644 --- a/src/main/java/com/beat/domain/performance/domain/Performance.java +++ b/src/main/java/com/beat/domain/performance/domain/Performance.java @@ -27,6 +27,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; +import jakarta.persistence.Lob; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import lombok.AccessLevel; @@ -75,7 +76,7 @@ public class Performance extends BaseTimeEntity { @Column(nullable = false) private String performanceTeamName; - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "longtext") private String performanceVenue; @Column(nullable = false) @@ -88,7 +89,7 @@ public class Performance extends BaseTimeEntity { private String latitude; @Column(nullable = false) - private String longtitude; + private String longitude; @Column(nullable = false) private String performanceContact; @@ -114,10 +115,10 @@ public class Performance extends BaseTimeEntity { private List performanceImageList = new ArrayList<>(); @Builder - public Performance(String performanceTitle, Genre genre, int runningTime, String performanceDescription, + private Performance(String performanceTitle, Genre genre, int runningTime, String performanceDescription, String performanceAttentionNote, BankName bankName, String accountNumber, String accountHolder, String posterImage, String performanceTeamName, - String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longtitude, + String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longitude, String performanceContact, String performancePeriod, int ticketPrice, int totalScheduleCount, Users users) { this.performanceTitle = performanceTitle; this.genre = genre; @@ -133,7 +134,7 @@ public Performance(String performanceTitle, Genre genre, int runningTime, String this.roadAddressName = roadAddressName; this.placeDetailAddress = placeDetailAddress; this.latitude = latitude; - this.longtitude = longtitude; + this.longitude = longitude; this.performanceContact = performanceContact; this.performancePeriod = performancePeriod; this.ticketPrice = ticketPrice; @@ -145,7 +146,7 @@ public static Performance create( String performanceTitle, Genre genre, int runningTime, String performanceDescription, String performanceAttentionNote, BankName bankName, String accountNumber, String accountHolder, String posterImage, String performanceTeamName, - String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longtitude, + String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longitude, String performanceContact, String performancePeriod, int ticketPrice, int totalScheduleCount, Users users) { return Performance.builder() .performanceTitle(performanceTitle) @@ -162,7 +163,7 @@ public static Performance create( .roadAddressName(roadAddressName) .placeDetailAddress(placeDetailAddress) .latitude(latitude) - .longtitude(longtitude) + .longitude(longitude) .performanceContact(performanceContact) .performancePeriod(performancePeriod) .ticketPrice(ticketPrice) @@ -175,7 +176,7 @@ public void update( String performanceTitle, Genre genre, int runningTime, String performanceDescription, String performanceAttentionNote, BankName bankName, String accountNumber, String accountHolder, String posterImage, String performanceTeamName, - String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longtitude, + String performanceVenue, String roadAddressName, String placeDetailAddress, String latitude, String longitude, String performanceContact, String performancePeriod, int totalScheduleCount) { this.performanceTitle = performanceTitle; this.genre = genre; @@ -191,7 +192,7 @@ public void update( this.roadAddressName = roadAddressName; this.placeDetailAddress = placeDetailAddress; this.latitude = latitude; - this.longtitude = longtitude; + this.longitude = longitude; this.performanceContact = performanceContact; this.performancePeriod = performancePeriod; this.totalScheduleCount = totalScheduleCount; @@ -240,4 +241,4 @@ public void validatePerformanceOwnership(Long userId) { } } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/performance/domain/PerformanceImage.java b/src/main/java/com/beat/domain/performance/domain/PerformanceImage.java index 46769714..bbc8479f 100644 --- a/src/main/java/com/beat/domain/performance/domain/PerformanceImage.java +++ b/src/main/java/com/beat/domain/performance/domain/PerformanceImage.java @@ -16,26 +16,26 @@ public class PerformanceImage { private Long id; @Column(nullable = false) - private String performanceImage; + private String performanceImageUrl; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "performance_id", nullable = false) private Performance performance; @Builder - public PerformanceImage(String performanceImage, Performance performance) { - this.performanceImage = performanceImage; + private PerformanceImage(String performanceImageUrl, Performance performance) { + this.performanceImageUrl = performanceImageUrl; this.performance = performance; } - public static PerformanceImage create(String perforemanceImage, Performance performance) { + public static PerformanceImage create(String performanceImageUrl, Performance performance) { return PerformanceImage.builder() - .performanceImage(perforemanceImage) + .performanceImageUrl(performanceImageUrl) .performance(performance) .build(); } - public void update(String performanceImage) { - this.performanceImage = performanceImage; + public void update(String performanceImageUrl) { + this.performanceImageUrl = performanceImageUrl; } } diff --git a/src/main/java/com/beat/domain/promotion/domain/Promotion.java b/src/main/java/com/beat/domain/promotion/domain/Promotion.java index fa0240a3..73fabb6c 100644 --- a/src/main/java/com/beat/domain/promotion/domain/Promotion.java +++ b/src/main/java/com/beat/domain/promotion/domain/Promotion.java @@ -44,7 +44,7 @@ public class Promotion { private CarouselNumber carouselNumber; @Builder - public Promotion(String promotionPhoto, Performance performance, String redirectUrl, boolean isExternal, + private Promotion(String promotionPhoto, Performance performance, String redirectUrl, boolean isExternal, CarouselNumber carouselNumber) { this.promotionPhoto = promotionPhoto; this.performance = performance; @@ -75,4 +75,4 @@ public void updatePromotionDetails(CarouselNumber carouselNumber, String newImag this.redirectUrl = redirectUrl; this.performance = performance; } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/schedule/domain/Schedule.java b/src/main/java/com/beat/domain/schedule/domain/Schedule.java index 0dbd9ccd..d3cc963c 100644 --- a/src/main/java/com/beat/domain/schedule/domain/Schedule.java +++ b/src/main/java/com/beat/domain/schedule/domain/Schedule.java @@ -57,7 +57,7 @@ public class Schedule { private Performance performance; @Builder - public Schedule(LocalDateTime performanceDate, int totalTicketCount, int soldTicketCount, boolean isBooking, + private Schedule(LocalDateTime performanceDate, int totalTicketCount, int soldTicketCount, boolean isBooking, ScheduleNumber scheduleNumber, Performance performance) { this.performanceDate = performanceDate; this.totalTicketCount = totalTicketCount; @@ -100,4 +100,4 @@ public void updateScheduleNumber(ScheduleNumber scheduleNumber) { public void updateIsBooking(boolean isBooking) { this.isBooking = isBooking; } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/domain/staff/domain/Staff.java b/src/main/java/com/beat/domain/staff/domain/Staff.java index 4cbb1bc3..64974870 100644 --- a/src/main/java/com/beat/domain/staff/domain/Staff.java +++ b/src/main/java/com/beat/domain/staff/domain/Staff.java @@ -35,7 +35,7 @@ public class Staff { private Performance performance; @Builder - public Staff(String staffName, String staffRole, String staffPhoto, Performance performance) { + private Staff(String staffName, String staffRole, String staffPhoto, Performance performance) { this.staffName = staffName; this.staffRole = staffRole; this.staffPhoto = staffPhoto; diff --git a/src/main/java/com/beat/domain/user/domain/Users.java b/src/main/java/com/beat/domain/user/domain/Users.java index 14b6c74e..8ba04404 100644 --- a/src/main/java/com/beat/domain/user/domain/Users.java +++ b/src/main/java/com/beat/domain/user/domain/Users.java @@ -28,7 +28,7 @@ public class Users { private Role role; @Builder - public Users(Role role) { + private Users(Role role) { this.role = role; } @@ -43,4 +43,4 @@ public static Users createWithRole(Role role) { .role(role) .build(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/global/common/config/WebConfig.java b/src/main/java/com/beat/global/common/config/WebConfig.java index 341035ab..1426b340 100644 --- a/src/main/java/com/beat/global/common/config/WebConfig.java +++ b/src/main/java/com/beat/global/common/config/WebConfig.java @@ -1,11 +1,13 @@ package com.beat.global.common.config; import com.beat.global.auth.resolver.CurrentMemberArgumentResolver; +import com.beat.global.common.converter.StringToEnumCustomConverterFactory; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -26,6 +28,12 @@ public void addArgumentResolvers(List resolvers) resolvers.add(currentMemberArgumentResolver); } + @Override + public void addFormatters(final FormatterRegistry registry) { + final StringToEnumCustomConverterFactory converterFactory = new StringToEnumCustomConverterFactory(); + registry.addConverterFactory(converterFactory); + } + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") @@ -34,4 +42,4 @@ public void addCorsMappings(CorsRegistry registry) { .allowedHeaders("*") .allowCredentials(true); } -} \ No newline at end of file +} diff --git a/src/main/java/com/beat/global/common/converter/StringToEnumCustomConverterFactory.java b/src/main/java/com/beat/global/common/converter/StringToEnumCustomConverterFactory.java new file mode 100644 index 00000000..c2dfcdd9 --- /dev/null +++ b/src/main/java/com/beat/global/common/converter/StringToEnumCustomConverterFactory.java @@ -0,0 +1,24 @@ +package com.beat.global.common.converter; + +import java.util.Arrays; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.core.convert.converter.ConverterFactory; + +public class StringToEnumCustomConverterFactory implements ConverterFactory> { + + public > Converter getConverter(final Class targetType) { + return new StringToEnumCustomConverter<>(targetType); + } + + private record StringToEnumCustomConverter>(Class targetType) implements Converter { + + @Override + public T convert(String source) { + return Arrays.stream(targetType.getEnumConstants()) + .filter(enumConstant -> enumConstant.name().equalsIgnoreCase(source.trim())) + .findAny() + .orElseThrow(() -> new IllegalArgumentException("Invalid value")); // 이 예외는 스프링이 MethodArgumentTypeMismatchException으로 감싼다. + } + } +} diff --git a/src/main/java/com/beat/global/common/handler/GlobalExceptionHandler.java b/src/main/java/com/beat/global/common/handler/GlobalExceptionHandler.java index 9852604b..fc31f7cc 100644 --- a/src/main/java/com/beat/global/common/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/beat/global/common/handler/GlobalExceptionHandler.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import com.beat.global.common.dto.ErrorResponse; import com.beat.global.common.exception.BadRequestException; @@ -53,6 +54,19 @@ public ResponseEntity handleMissingServletRequestParameterExcepti .body(ErrorResponse.of(HttpStatus.BAD_REQUEST.value(), message)); } + @ExceptionHandler(MethodArgumentTypeMismatchException.class) + public ResponseEntity handleMethodArgumentTypeMismatchException( + MethodArgumentTypeMismatchException e) { + log.warn("MethodArgumentTypeMismatchException: {}", e.getMessage()); + String errorMessage = "Invalid value for parameter: " + e.getName(); + String requiredType = "Unknown Type"; + if (e.getRequiredType() != null) { + requiredType = e.getRequiredType().getSimpleName(); + } + return ResponseEntity.status(HttpStatus.BAD_REQUEST) + .body(ErrorResponse.of(HttpStatus.BAD_REQUEST.value(), errorMessage + " (Expected: " + requiredType + ")")); + } + /** * 401 UNAUTHORIZED */ @@ -107,4 +121,4 @@ public ResponseEntity handleBeatException(final BeatException e) log.warn("BeatException occurred: ", e); return ResponseEntity.status(e.getBaseErrorCode().getStatus()).body(ErrorResponse.from(e.getBaseErrorCode())); } -} \ No newline at end of file +} diff --git a/src/test/java/com/beat/domain/booking/GuestBookingServiceConcurrencyTest.java b/src/test/java/com/beat/domain/booking/GuestBookingServiceConcurrencyTest.java index ca1a66c5..1ada2904 100644 --- a/src/test/java/com/beat/domain/booking/GuestBookingServiceConcurrencyTest.java +++ b/src/test/java/com/beat/domain/booking/GuestBookingServiceConcurrencyTest.java @@ -78,10 +78,14 @@ public void setup() { "poster.jpg", "Performance Team", "Performance Venue", - "010-1234-5678", + "도로명 주소", + "상세 주소", + "123.1111", + "12.1234", + "010-1111-1111", "2024-01-01 to 2024-12-31", - 35000, - 1, + 10000, + 30, initialUser ); performanceRepository.save(performance); @@ -205,4 +209,4 @@ private String generateRandomPassword() { int randomNum = ThreadLocalRandom.current().nextInt(1000, 10000); return String.format("%04d", randomNum); } -} \ No newline at end of file +} From 59f2c0d094e39a96ce27f59fec2d577bc5e78060 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Sun, 1 Dec 2024 03:21:03 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[#268]=20fix:=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=EC=9D=98=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9D=84=20FQN=20=ED=98=95=EC=8B=9D=EC=9C=BC=EB=A1=9C=20API=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=EC=97=90=20=ED=91=9C=EC=8B=9C=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.yml | 5 ++++- src/main/resources/application-prod.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index e9d0c438..60bdfff1 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -80,4 +80,7 @@ cors: app: server: - url: ${DEV_SERVER_URL} \ No newline at end of file + url: ${DEV_SERVER_URL} + +springdoc: + use-fqn: true diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index c9689bd2..d9fadb2a 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -80,4 +80,7 @@ cors: app: server: - url: ${PROD_SERVER_URL} \ No newline at end of file + url: ${PROD_SERVER_URL} + +springdoc: + use-fqn: true From a9ceea65d582723252e9ee4899b94dee5506be58 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Sun, 1 Dec 2024 19:56:07 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[#268]=20chore(Performance):=20=EC=93=B0?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=EB=AC=B8=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/beat/domain/performance/domain/Performance.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/beat/domain/performance/domain/Performance.java b/src/main/java/com/beat/domain/performance/domain/Performance.java index 0d52059e..cbb18799 100644 --- a/src/main/java/com/beat/domain/performance/domain/Performance.java +++ b/src/main/java/com/beat/domain/performance/domain/Performance.java @@ -27,7 +27,6 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; -import jakarta.persistence.Lob; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import lombok.AccessLevel;