Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] #198 - isBooking update 안되는 이슈 해결 #199

Merged
merged 18 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
afed125
[#198] fix(Schedule): updateIsBooking 로직 추가
hyerinhwang-sailin Aug 29, 2024
29fb7a9
[#198] fix(ScheduleService): IsBooking update 로직 변경 및 불필요한 주석 제거
hyerinhwang-sailin Aug 29, 2024
3021685
[#198] fix(PerformanceService): getPerformanceDetail readOnly 설정 변경 및…
hyerinhwang-sailin Aug 29, 2024
bffb8c9
[#198] feat(BeatApplication): EnableAsync 어노테이션 추가
hyerinhwang-sailin Sep 21, 2024
a20f239
[#198] feat(SchedulerConfig): TaskScheduler 스레드 풀 크기 설정
hyerinhwang-sailin Sep 21, 2024
9ecc7d7
[#198] feat(JobSchedulerService): TaskScheduler 서비스 구현
hyerinhwang-sailin Sep 21, 2024
40a083b
[#198] feat(PerformanceManagementService): 공연 생성, 삭제에 따른 스케쥴링 리스트 변화 구현
hyerinhwang-sailin Sep 21, 2024
9fff946
[#198] feat(PerformanceModifyService): 공연 수정에 따른 스케쥴링 리스트 변화 구현
hyerinhwang-sailin Sep 21, 2024
9c18adf
[#198] feat(ScheduleRepository): isBooking true인 공연 조회 로직 추가
hyerinhwang-sailin Sep 21, 2024
9504e15
[#198] fix(ScheduleService): isBooking 관련 불필요한 로직 삭제
hyerinhwang-sailin Sep 21, 2024
07ab48c
[#198] fix(PerformanceService): 조회 메소드 annotation @Transactional(read…
hyerinhwang-sailin Sep 21, 2024
50a0abe
[#198] refactor(GuestBookingService): 매진 여부 확인 메소드 분리 및 log 수정
hyerinhwang-sailin Sep 21, 2024
451930a
[#198] refactor(MemberBookingService): 매진 여부 확인 메소드 분리 및 log 수정
hyerinhwang-sailin Sep 21, 2024
96af323
[#198] feat(TicketService): 예매취소 시 isBooking update 구현
hyerinhwang-sailin Sep 21, 2024
bb9de14
[#198] chore(PerformanceService): 코드 포맷터 적용
hyerinhwang-sailin Sep 25, 2024
e05b587
Merge branch 'develop' into fix/#198
hyerinhwang-sailin Sep 25, 2024
e38d731
[#198] remove(SchedulerConfig): SchedulerConfig 삭제
hyerinhwang-sailin Sep 25, 2024
9fc6fb9
[#198] refactor(TicketService): isBooking update 검증 추가 및 코드 포맷팅 적용
hyerinhwang-sailin Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/beat/BeatApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableFeignClients
@EnableScheduling
@EnableAsync
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분에 대해서 저도 공부를 해보았습니다!

이렇게 어플리케이션 클래스 위에 EnableAsync 어노테이션을 사용하면, 기본적으로 SimpleAsyncTaskExecutor가 사용된다고 합니다.
이는 비동기 작업마다 새로운 스레드를 생성하는 스레드풀이라서 리소스 낭비, 성능 저하, 스케일링 문제 등이 발생할 수 있다고 합니다!

그래서 SimpleAsyncTaskExecutor 보다는 ThreadPoolTaskExecutor 같은 제한된 리소스를 사용하는 스레드풀을 사용하는것을 권장한다고 하네요

일단 해당 부분에 대한 고도화는 prod 서버에 공연이 없기도 할 뿐더러, QA시 dev에 예매중인 공연을 대상으로 했을 때, 성능 저하가 크게 없다면 지금 당장 개선해야 될 문제는 아니라고 생각이 듭니다!! (추후 개선하면 좋을 것 같음)

참고 블로그!
https://skydevilk.tistory.com/121
https://dkswnkk.tistory.com/706

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공유 감사합니다! 다음 스프린트에서 개선해보겠습니다 :)

@ImportAutoConfiguration({FeignAutoConfiguration.class})
public class BeatApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
import com.beat.global.common.exception.BadRequestException;
import com.beat.global.common.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@RequiredArgsConstructor
public class GuestBookingService {

private static final Logger logger = LoggerFactory.getLogger(GuestBookingService.class);

private final ScheduleRepository scheduleRepository;
private final BookingRepository bookingRepository;
private final UserRepository userRepository;
Expand All @@ -37,7 +35,7 @@ public GuestBookingResponse createGuestBooking(GuestBookingRequest guestBookingR
throw new BadRequestException(ScheduleErrorCode.INSUFFICIENT_TICKETS);
}

schedule.setSoldTicketCount(schedule.getSoldTicketCount() + guestBookingRequest.purchaseTicketCount());
updateSoldTicketCountAndIsBooking(schedule, guestBookingRequest.purchaseTicketCount());

Users users = bookingRepository.findFirstByBookerNameAndBookerPhoneNumberAndBirthDateAndPassword(
guestBookingRequest.bookerName(),
Expand Down Expand Up @@ -66,7 +64,7 @@ public GuestBookingResponse createGuestBooking(GuestBookingRequest guestBookingR
);
bookingRepository.save(booking);

logger.info("Booking created: {}", booking);
log.info("Guest Booking created: {}", booking);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디테일 감사합니다!


return GuestBookingResponse.of(
booking.getId(),
Expand All @@ -79,8 +77,16 @@ public GuestBookingResponse createGuestBooking(GuestBookingRequest guestBookingR
booking.getBookingStatus(),
schedule.getPerformance().getBankName(),
schedule.getPerformance().getAccountNumber(),
totalPaymentAmount, // 회원 예매랑 다른 부분 확인하기
totalPaymentAmount,
booking.getCreatedAt()
);
}

private void updateSoldTicketCountAndIsBooking(Schedule schedule, int purchaseTicketCount) {
schedule.setSoldTicketCount(schedule.getSoldTicketCount() + purchaseTicketCount);

if (schedule.getTotalTicketCount() == schedule.getSoldTicketCount()) {
schedule.updateIsBooking(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도메인 메서드 사용 좋습니다!

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import com.beat.global.common.exception.BadRequestException;
import com.beat.global.common.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@RequiredArgsConstructor
public class MemberBookingService {
Expand All @@ -38,7 +40,7 @@ public MemberBookingResponse createMemberBooking(Long memberId, MemberBookingReq
throw new BadRequestException(ScheduleErrorCode.INSUFFICIENT_TICKETS);
}

schedule.setSoldTicketCount(schedule.getSoldTicketCount() + memberBookingRequest.purchaseTicketCount());
updateSoldTicketCountAndIsBooking(schedule, memberBookingRequest.purchaseTicketCount());

Member member = memberRepository.findById(memberId).orElseThrow(
() -> new NotFoundException(MemberErrorCode.MEMBER_NOT_FOUND));
Expand All @@ -59,6 +61,8 @@ public MemberBookingResponse createMemberBooking(Long memberId, MemberBookingReq
bookingRepository.save(booking);
scheduleRepository.save(schedule);

log.info("Member Booking created: {}", booking);

return MemberBookingResponse.of(
booking.getId(),
schedule.getId(),
Expand All @@ -74,4 +78,12 @@ public MemberBookingResponse createMemberBooking(Long memberId, MemberBookingReq
booking.getCreatedAt()
);
}

private void updateSoldTicketCountAndIsBooking(Schedule schedule, int purchaseTicketCount) {
schedule.setSoldTicketCount(schedule.getSoldTicketCount() + purchaseTicketCount);

if (schedule.getTotalTicketCount() == schedule.getSoldTicketCount()) {
schedule.updateIsBooking(false);
}
}
}
Loading
Loading