From 0a3a45fa179d3ddaa957222df47eb982d0367998 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:46:29 +0900 Subject: [PATCH 01/24] =?UTF-8?q?[#185]=20remove:=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=8B=9C=20add,=20delete,=20update=20=EC=9A=94=EC=B2=AD/?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20DTO=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/update/cast/CastAddRequest.java | 7 ------ .../dto/update/cast/CastAddResponse.java | 12 ---------- .../dto/update/cast/CastDeleteResponse.java | 9 -------- .../dto/update/cast/CastUpdateResponse.java | 12 ---------- .../update/schedule/ScheduleAddRequest.java | 11 --------- .../update/schedule/ScheduleAddResponse.java | 23 ------------------- .../schedule/ScheduleDeleteResponse.java | 9 -------- .../schedule/ScheduleUpdateResponse.java | 17 -------------- .../dto/update/staff/StaffAddRequest.java | 7 ------ .../dto/update/staff/StaffAddResponse.java | 12 ---------- .../dto/update/staff/StaffDeleteResponse.java | 9 -------- .../dto/update/staff/StaffUpdateResponse.java | 12 ---------- 12 files changed, 140 deletions(-) delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateResponse.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddRequest.java deleted file mode 100644 index 32087591..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddRequest.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastAddRequest( - String castName, - String castRole, - String castPhoto -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddResponse.java deleted file mode 100644 index b8360963..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastAddResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastAddResponse( - Long castId, - String castName, - String castRole, - String castPhoto -) { - public static CastAddResponse of(Long castId, String castName, String castRole, String castPhoto) { - return new CastAddResponse(castId, castName, castRole, castPhoto); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteResponse.java deleted file mode 100644 index 67a8648a..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastDeleteResponse( - Long castId -) { - public static CastDeleteResponse from(Long castId) { - return new CastDeleteResponse(castId); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateResponse.java deleted file mode 100644 index 21cabf25..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastUpdateResponse( - Long castId, - String castName, - String castRole, - String castPhoto -) { - public static CastUpdateResponse of(Long castId, String castName, String castRole, String castPhoto) { - return new CastUpdateResponse(castId, castName, castRole, castPhoto); - } -} diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddRequest.java deleted file mode 100644 index a370e492..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -import com.beat.domain.schedule.domain.ScheduleNumber; - -import java.time.LocalDateTime; - -public record ScheduleAddRequest( - LocalDateTime performanceDate, - int totalTicketCount, - ScheduleNumber scheduleNumber -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddResponse.java deleted file mode 100644 index 08a6b13b..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleAddResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -import com.beat.domain.schedule.domain.ScheduleNumber; - -import java.time.LocalDateTime; - -public record ScheduleAddResponse( - Long scheduleId, - LocalDateTime performanceDate, - int totalTicketCount, - int dueDate, - ScheduleNumber scheduleNumber -) { - public static ScheduleAddResponse of( - Long scheduleId, - LocalDateTime performanceDate, - int totalTicketCount, - int dueDate, - ScheduleNumber scheduleNumber - ) { - return new ScheduleAddResponse(scheduleId, performanceDate, totalTicketCount, dueDate, scheduleNumber); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteResponse.java deleted file mode 100644 index 1e75d14c..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -public record ScheduleDeleteResponse( - Long scheduleId -) { - public static ScheduleDeleteResponse from(Long scheduleId) { - return new ScheduleDeleteResponse(scheduleId); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateResponse.java deleted file mode 100644 index 6f12981b..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -import com.beat.domain.schedule.domain.ScheduleNumber; - -import java.time.LocalDateTime; - -public record ScheduleUpdateResponse( - Long scheduleId, - LocalDateTime performanceDate, - int totalTicketCount, - int dueDate, - ScheduleNumber scheduleNumber -) { - public static ScheduleUpdateResponse of(Long scheduleId, LocalDateTime performanceDate, int totalTicketCount, int dueDate, ScheduleNumber scheduleNumber) { - return new ScheduleUpdateResponse(scheduleId, performanceDate, totalTicketCount, dueDate, scheduleNumber); - } -} diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddRequest.java deleted file mode 100644 index a9899c90..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddRequest.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffAddRequest( - String staffName, - String staffRole, - String staffPhoto -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddResponse.java deleted file mode 100644 index 421ba869..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffAddResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffAddResponse( - Long staffId, - String staffName, - String staffRole, - String staffPhoto -) { - public static StaffAddResponse of(Long staffId, String staffName, String staffRole, String staffPhoto) { - return new StaffAddResponse(staffId, staffName, staffRole, staffPhoto); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteResponse.java deleted file mode 100644 index 0714c97f..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffDeleteResponse( - Long staffId -) { - public static StaffDeleteResponse from(Long staffId) { - return new StaffDeleteResponse(staffId); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateResponse.java deleted file mode 100644 index 56833808..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffUpdateResponse( - Long staffId, - String staffName, - String staffRole, - String staffPhoto -) { - public static StaffUpdateResponse of(Long staffId, String staffName, String staffRole, String staffPhoto) { - return new StaffUpdateResponse(staffId, staffName, staffRole, staffPhoto); - } -} \ No newline at end of file From 931395453d7f1fbcc9d0382a5ebcdc7bb9ae1dda Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:50:29 +0900 Subject: [PATCH 02/24] =?UTF-8?q?[#185]=20remove:=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=8B=9C=20add,=20delete,=20update=20=EC=9A=94=EC=B2=AD/?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20DTO=20=EC=82=AD=EC=A0=9C=20=EB=B0=8F=20Per?= =?UTF-8?q?formanceUpdateService=20=ED=81=B4=EB=9E=98=EC=8A=A4=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 --- .../application/PerformanceUpdateService.java | 455 ------------------ .../dto/update/PerformanceUpdateRequest.java | 43 -- .../dto/update/PerformanceUpdateResponse.java | 102 ---- .../dto/update/cast/CastDeleteRequest.java | 5 - .../dto/update/cast/CastUpdateRequest.java | 8 - .../schedule/ScheduleDeleteRequest.java | 5 - .../schedule/ScheduleUpdateRequest.java | 12 - .../dto/update/staff/StaffDeleteRequest.java | 5 - .../dto/update/staff/StaffUpdateRequest.java | 8 - 9 files changed, 643 deletions(-) delete mode 100644 src/main/java/com/beat/domain/performance/application/PerformanceUpdateService.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateResponse.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteRequest.java delete mode 100644 src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateRequest.java diff --git a/src/main/java/com/beat/domain/performance/application/PerformanceUpdateService.java b/src/main/java/com/beat/domain/performance/application/PerformanceUpdateService.java deleted file mode 100644 index 380240b9..00000000 --- a/src/main/java/com/beat/domain/performance/application/PerformanceUpdateService.java +++ /dev/null @@ -1,455 +0,0 @@ -package com.beat.domain.performance.application; - -import com.beat.domain.booking.dao.BookingRepository; -import com.beat.domain.cast.dao.CastRepository; -import com.beat.domain.cast.domain.Cast; -import com.beat.domain.cast.exception.CastErrorCode; -import com.beat.domain.member.dao.MemberRepository; -import com.beat.domain.member.domain.Member; -import com.beat.domain.member.exception.MemberErrorCode; -import com.beat.domain.performance.application.dto.update.*; -import com.beat.domain.performance.application.dto.update.cast.CastAddRequest; -import com.beat.domain.performance.application.dto.update.cast.CastAddResponse; -import com.beat.domain.performance.application.dto.update.cast.CastDeleteRequest; -import com.beat.domain.performance.application.dto.update.cast.CastDeleteResponse; -import com.beat.domain.performance.application.dto.update.cast.CastUpdateRequest; -import com.beat.domain.performance.application.dto.update.cast.CastUpdateResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleAddRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleAddResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleDeleteRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleDeleteResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleUpdateRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleUpdateResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffAddRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffAddResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffDeleteRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffDeleteResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffUpdateRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffUpdateResponse; -import com.beat.domain.performance.dao.PerformanceRepository; -import com.beat.domain.performance.domain.Performance; -import com.beat.domain.performance.exception.PerformanceErrorCode; -import com.beat.domain.schedule.dao.ScheduleRepository; -import com.beat.domain.schedule.domain.Schedule; -import com.beat.domain.schedule.exception.ScheduleErrorCode; -import com.beat.domain.staff.dao.StaffRepository; -import com.beat.domain.staff.domain.Staff; -import com.beat.domain.staff.exception.StaffErrorCode; -import com.beat.global.common.exception.BadRequestException; -import com.beat.global.common.exception.ForbiddenException; -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; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.stream.Collectors; - -@Slf4j -@Service -@RequiredArgsConstructor -public class PerformanceUpdateService { - - private final PerformanceRepository performanceRepository; - private final ScheduleRepository scheduleRepository; - private final MemberRepository memberRepository; - private final CastRepository castRepository; - private final StaffRepository staffRepository; - private final BookingRepository bookingRepository; - - @Transactional - public PerformanceUpdateResponse updatePerformance(Long memberId, PerformanceUpdateRequest request) { - log.info("Starting updatePerformance for memberId: {}, performanceId: {}", memberId, request.performanceId()); - - Member member = validateMember(memberId); - Long userId = member.getUser().getId(); - - Performance performance = findPerformance(request.performanceId()); - - validateOwnership(userId, performance); - - List scheduleIds = scheduleRepository.findIdsByPerformanceId(request.performanceId()); - boolean isBookerExist = bookingRepository.existsByScheduleIdIn(scheduleIds); - - if (isBookerExist && request.ticketPrice() != performance.getTicketPrice()) { - log.error("Ticket price update failed due to existing bookings for performanceId: {}", performance.getId()); - throw new BadRequestException(PerformanceErrorCode.PRICE_UPDATE_NOT_ALLOWED); - } - - updatePerformanceDetails(performance, request, isBookerExist); - - List deletedSchedules = deleteSchedules(request.scheduleDeleteRequests()); - List updatedSchedules = updateSchedules(request.scheduleUpdateRequests()); - List addedSchedules = addSchedules(request.scheduleAddRequests(), performance); - - List deletedCasts = deleteCasts(request.castDeleteRequests()); - List updatedCasts = updateCasts(request.castUpdateRequests()); - List addedCasts = addCasts(request.castAddRequests(), performance); - - List deletedStaffs = deleteStaffs(request.staffDeleteRequests()); - List updatedStaffs = updateStaffs(request.staffUpdateRequests()); - List addedStaffs = addStaffs(request.staffAddRequests(), performance); - - PerformanceUpdateResponse response = completeUpdateResponse(performance, addedSchedules, updatedSchedules, deletedSchedules, - addedCasts, updatedCasts, deletedCasts, - addedStaffs, updatedStaffs, deletedStaffs); - - log.info("Successfully completed updatePerformance for performanceId: {}", request.performanceId()); - return response; - } - - private Member validateMember(Long memberId) { - log.debug("Validating memberId: {}", memberId); - return memberRepository.findById(memberId) - .orElseThrow(() -> { - log.error("Member not found: memberId: {}", memberId); - return new NotFoundException(MemberErrorCode.MEMBER_NOT_FOUND); - }); - } - - private Performance findPerformance(Long performanceId) { - log.debug("Finding performance with performanceId: {}", performanceId); - return performanceRepository.findById(performanceId) - .orElseThrow(() -> { - log.error("Performance not found: performanceId: {}", performanceId); - return new NotFoundException(PerformanceErrorCode.PERFORMANCE_NOT_FOUND); - }); - } - - private void validateOwnership(Long userId, Performance performance) { - if (!performance.getUsers().getId().equals(userId)) { - log.error("User ID {} does not own performance ID {}", userId, performance.getId()); - throw new ForbiddenException(PerformanceErrorCode.NOT_PERFORMANCE_OWNER); - } - } - - private void updatePerformanceDetails(Performance performance, PerformanceUpdateRequest request, boolean isBookerExist) { - log.debug("Updating performance details for performanceId: {}", performance.getId()); - - performance.update( - request.performanceTitle(), - request.genre(), - request.runningTime(), - request.performanceDescription(), - request.performanceAttentionNote(), - request.bankName(), - request.accountNumber(), - request.accountHolder(), - request.posterImage(), - request.performanceTeamName(), - request.performanceVenue(), - request.performanceContact(), - request.performancePeriod(), - request.totalScheduleCount() - ); - - if (!isBookerExist) { - log.debug("Updating ticket price to {}", request.ticketPrice()); - performance.updateTicketPrice(request.ticketPrice()); - } - - performanceRepository.save(performance); - log.debug("Performance details updated for performanceId: {}", performance.getId()); - } - - private List addSchedules(List requests, Performance performance) { - log.debug("Adding schedules for performanceId: {}", performance.getId()); - - long existingSchedulesCount = scheduleRepository.countByPerformanceId(performance.getId()); - - if (requests != null && (existingSchedulesCount + requests.size()) > 3) { - throw new BadRequestException(PerformanceErrorCode.MAX_SCHEDULE_LIMIT_EXCEEDED); - } - - if (requests == null || requests.isEmpty()) { - log.debug("No schedules to add for performanceId: {}", performance.getId()); - return List.of(); - } - - return requests.stream() - .map(request -> { - Schedule schedule = Schedule.create( - request.performanceDate(), - request.totalTicketCount(), - 0, - true, - request.scheduleNumber(), - performance - ); - Schedule savedSchedule = scheduleRepository.save(schedule); - log.debug("Added schedule with scheduleId: {} for performanceId: {}", savedSchedule.getId(), performance.getId()); - return ScheduleAddResponse.of( - savedSchedule.getId(), - savedSchedule.getPerformanceDate(), - savedSchedule.getTotalTicketCount(), - calculateDueDate(savedSchedule.getPerformanceDate()), - savedSchedule.getScheduleNumber() - ); - }) - .collect(Collectors.toList()); - } - - private List updateSchedules(List requests) { - log.debug("Updating schedules"); - if (requests == null || requests.isEmpty()) { - log.debug("No schedules to update"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Schedule schedule = scheduleRepository.findById(request.scheduleId()) - .orElseThrow(() -> { - log.error("Schedule not found: scheduleId: {}", request.scheduleId()); - return new NotFoundException(ScheduleErrorCode.NO_SCHEDULE_FOUND); - }); - schedule.update( - request.performanceDate(), - request.totalTicketCount(), - request.scheduleNumber() - ); - scheduleRepository.save(schedule); - log.debug("Updated schedule with scheduleId: {}", schedule.getId()); - return ScheduleUpdateResponse.of( - schedule.getId(), - schedule.getPerformanceDate(), - schedule.getTotalTicketCount(), - calculateDueDate(schedule.getPerformanceDate()), - schedule.getScheduleNumber() - ); - }) - .collect(Collectors.toList()); - } - - private List deleteSchedules(List requests) { - log.debug("Deleting schedules"); - if (requests == null || requests.isEmpty()) { - log.debug("No schedules to delete"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Schedule schedule = scheduleRepository.findById(request.scheduleId()) - .orElseThrow(() -> { - log.error("Schedule not found: scheduleId: {}", request.scheduleId()); - return new NotFoundException(ScheduleErrorCode.NO_SCHEDULE_FOUND); - }); - scheduleRepository.delete(schedule); - log.debug("Deleted schedule with scheduleId: {}", schedule.getId()); - return ScheduleDeleteResponse.from(schedule.getId()); - }) - .collect(Collectors.toList()); - } - - private List addCasts(List requests, Performance performance) { - log.debug("Adding casts for performanceId: {}", performance.getId()); - if (requests == null || requests.isEmpty()) { - log.debug("No casts to add for performanceId: {}", performance.getId()); - return List.of(); - } - - return requests.stream() - .map(request -> { - Cast cast = Cast.create( - request.castName(), - request.castRole(), - request.castPhoto(), - performance - ); - Cast savedCast = castRepository.save(cast); - log.debug("Added cast with castId: {} for performanceId: {}", savedCast.getId(), performance.getId()); - return CastAddResponse.of( - savedCast.getId(), - savedCast.getCastName(), - savedCast.getCastRole(), - savedCast.getCastPhoto() - ); - }) - .collect(Collectors.toList()); - } - - private List updateCasts(List requests) { - log.debug("Updating casts"); - if (requests == null || requests.isEmpty()) { - log.debug("No casts to update"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Cast cast = castRepository.findById(request.castId()) - .orElseThrow(() -> { - log.error("Cast not found: castId: {}", request.castId()); - return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); - }); - cast.update( - request.castName(), - request.castRole(), - request.castPhoto() - ); - castRepository.save(cast); - log.debug("Updated cast with castId: {}", cast.getId()); - return CastUpdateResponse.of( - cast.getId(), - cast.getCastName(), - cast.getCastRole(), - cast.getCastPhoto() - ); - }) - .collect(Collectors.toList()); - } - - private List deleteCasts(List requests) { - log.debug("Deleting casts"); - if (requests == null || requests.isEmpty()) { - log.debug("No casts to delete"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Cast cast = castRepository.findById(request.castId()) - .orElseThrow(() -> { - log.error("Cast not found: castId: {}", request.castId()); - return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); - }); - castRepository.delete(cast); - log.debug("Deleted cast with castId: {}", cast.getId()); - return CastDeleteResponse.from(cast.getId()); - }) - .collect(Collectors.toList()); - } - - private List addStaffs(List requests, Performance performance) { - log.debug("Adding staffs for performanceId: {}", performance.getId()); - if (requests == null || requests.isEmpty()) { - log.debug("No staffs to add for performanceId: {}", performance.getId()); - return List.of(); - } - - return requests.stream() - .map(request -> { - Staff staff = Staff.create( - request.staffName(), - request.staffRole(), - request.staffPhoto(), - performance - ); - Staff savedStaff = staffRepository.save(staff); - log.debug("Added staff with staffId: {} for performanceId: {}", savedStaff.getId(), performance.getId()); - return StaffAddResponse.of( - savedStaff.getId(), - savedStaff.getStaffName(), - savedStaff.getStaffRole(), - savedStaff.getStaffPhoto() - ); - }) - .collect(Collectors.toList()); - } - - private List updateStaffs(List requests) { - log.debug("Updating staffs"); - if (requests == null || requests.isEmpty()) { - log.debug("No staffs to update"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Staff staff = staffRepository.findById(request.staffId()) - .orElseThrow(() -> { - log.error("Staff not found: staffId: {}", request.staffId()); - return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); - }); - staff.update( - request.staffName(), - request.staffRole(), - request.staffPhoto() - ); - staffRepository.save(staff); - log.debug("Updated staff with staffId: {}", staff.getId()); - return StaffUpdateResponse.of( - staff.getId(), - staff.getStaffName(), - staff.getStaffRole(), - staff.getStaffPhoto() - ); - }) - .collect(Collectors.toList()); - } - - private List deleteStaffs(List requests) { - log.debug("Deleting staffs"); - if (requests == null || requests.isEmpty()) { - log.debug("No staffs to delete"); - return List.of(); - } - - return requests.stream() - .map(request -> { - Staff staff = staffRepository.findById(request.staffId()) - .orElseThrow(() -> { - log.error("Staff not found: staffId: {}", request.staffId()); - return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); - }); - staffRepository.delete(staff); - log.debug("Deleted staff with staffId: {}", staff.getId()); - return StaffDeleteResponse.from(staff.getId()); - }) - .collect(Collectors.toList()); - } - - private int calculateDueDate(LocalDateTime performanceDate) { - return (int) ChronoUnit.DAYS.between(LocalDate.now(), performanceDate.toLocalDate()); - } - - private PerformanceUpdateResponse completeUpdateResponse( - Performance performance, - List addedSchedules, - List updatedSchedules, - List deletedSchedules, - List addedCasts, - List updatedCasts, - List deletedCasts, - List addedStaffs, - List updatedStaffs, - List deletedStaffs - ) { - log.debug("Creating PerformanceUpdateResponse for performanceId: {}", performance.getId()); - PerformanceUpdateResponse response = PerformanceUpdateResponse.of( - performance.getUsers().getId(), - performance.getId(), - performance.getPerformanceTitle(), - performance.getGenre(), - performance.getRunningTime(), - performance.getPerformanceDescription(), - performance.getPerformanceAttentionNote(), - performance.getBankName(), - performance.getAccountNumber(), - performance.getAccountHolder(), - performance.getPosterImage(), - performance.getPerformanceTeamName(), - performance.getPerformanceVenue(), - performance.getPerformanceContact(), - performance.getPerformancePeriod(), - performance.getTicketPrice(), - performance.getTotalScheduleCount(), - addedSchedules, - deletedSchedules, - updatedSchedules, - addedCasts, - deletedCasts, - updatedCasts, - addedStaffs, - deletedStaffs, - updatedStaffs - ); - log.info("PerformanceUpdateResponse 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/dto/update/PerformanceUpdateRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateRequest.java deleted file mode 100644 index 89948cca..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.beat.domain.performance.application.dto.update; - -import com.beat.domain.performance.application.dto.update.cast.CastAddRequest; -import com.beat.domain.performance.application.dto.update.cast.CastDeleteRequest; -import com.beat.domain.performance.application.dto.update.cast.CastUpdateRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleAddRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleDeleteRequest; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleUpdateRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffAddRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffDeleteRequest; -import com.beat.domain.performance.application.dto.update.staff.StaffUpdateRequest; -import com.beat.domain.performance.domain.BankName; -import com.beat.domain.performance.domain.Genre; - -import java.util.List; - -public record PerformanceUpdateRequest( - Long performanceId, - String performanceTitle, - Genre genre, - int runningTime, - String performanceDescription, - String performanceAttentionNote, - BankName bankName, - String accountNumber, - String accountHolder, - String posterImage, - String performanceTeamName, - String performanceVenue, - String performanceContact, - String performancePeriod, - int totalScheduleCount, - int ticketPrice, - List scheduleAddRequests, - List scheduleDeleteRequests, - List scheduleUpdateRequests, - List castAddRequests, - List castDeleteRequests, - List castUpdateRequests, - List staffAddRequests, - List staffDeleteRequests, - List staffUpdateRequests -) {} diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateResponse.java b/src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateResponse.java deleted file mode 100644 index 842d6b10..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/PerformanceUpdateResponse.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.beat.domain.performance.application.dto.update; - -import com.beat.domain.performance.application.dto.update.cast.CastAddResponse; -import com.beat.domain.performance.application.dto.update.cast.CastDeleteResponse; -import com.beat.domain.performance.application.dto.update.cast.CastUpdateResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleAddResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleDeleteResponse; -import com.beat.domain.performance.application.dto.update.schedule.ScheduleUpdateResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffAddResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffDeleteResponse; -import com.beat.domain.performance.application.dto.update.staff.StaffUpdateResponse; -import com.beat.domain.performance.domain.BankName; -import com.beat.domain.performance.domain.Genre; - -import java.util.List; - -public record PerformanceUpdateResponse( - Long userId, - Long performanceId, - String performanceTitle, - Genre genre, - int runningTime, - String performanceDescription, - String performanceAttentionNote, - BankName bankName, - String accountNumber, - String accountHolder, - String posterImage, - String performanceTeamName, - String performanceVenue, - String performanceContact, - String performancePeriod, - int ticketPrice, - int totalScheduleCount, - List addedSchedules, - List deletedSchedules, - List updatedSchedules, - List addedCasts, - List deletedCasts, - List updatedCasts, - List addedStaffs, - List deletedStaffs, - List updatedStaffs -) { - public static PerformanceUpdateResponse of( - Long userId, - Long performanceId, - String performanceTitle, - Genre genre, - int runningTime, - String performanceDescription, - String performanceAttentionNote, - BankName bankName, - String accountNumber, - String accountHolder, - String posterImage, - String performanceTeamName, - String performanceVenue, - String performanceContact, - String performancePeriod, - int ticketPrice, - int totalScheduleCount, - List addedSchedules, - List deletedSchedules, - List updatedSchedules, - List addedCasts, - List deletedCasts, - List updatedCasts, - List addedStaffs, - List deletedStaffs, - List updatedStaffs) { - - return new PerformanceUpdateResponse( - userId, - performanceId, - performanceTitle, - genre, - runningTime, - performanceDescription, - performanceAttentionNote, - bankName, - accountNumber, - accountHolder, - posterImage, - performanceTeamName, - performanceVenue, - performanceContact, - performancePeriod, - ticketPrice, - totalScheduleCount, - addedSchedules, - deletedSchedules, - updatedSchedules, - addedCasts, - deletedCasts, - updatedCasts, - addedStaffs, - deletedStaffs, - updatedStaffs - ); - } -} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteRequest.java deleted file mode 100644 index e8b9e9b8..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastDeleteRequest.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastDeleteRequest( - Long castId -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateRequest.java deleted file mode 100644 index e2a27e17..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/cast/CastUpdateRequest.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.beat.domain.performance.application.dto.update.cast; - -public record CastUpdateRequest( - Long castId, - String castName, - String castRole, - String castPhoto -) {} diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteRequest.java deleted file mode 100644 index 1f7bfde4..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleDeleteRequest.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -public record ScheduleDeleteRequest( - Long scheduleId -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateRequest.java deleted file mode 100644 index 825690df..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/schedule/ScheduleUpdateRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.beat.domain.performance.application.dto.update.schedule; - -import com.beat.domain.schedule.domain.ScheduleNumber; - -import java.time.LocalDateTime; - -public record ScheduleUpdateRequest( - Long scheduleId, - LocalDateTime performanceDate, - int totalTicketCount, - ScheduleNumber scheduleNumber -) {} diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteRequest.java deleted file mode 100644 index f0785c26..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffDeleteRequest.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffDeleteRequest( - Long staffId -) {} \ No newline at end of file diff --git a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateRequest.java b/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateRequest.java deleted file mode 100644 index 9e1b11a7..00000000 --- a/src/main/java/com/beat/domain/performance/application/dto/update/staff/StaffUpdateRequest.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.beat.domain.performance.application.dto.update.staff; - -public record StaffUpdateRequest( - Long staffId, - String staffName, - String staffRole, - String staffPhoto -) {} From f391183bc057ff3358231e1e5fda56fd17ef1d35 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:51:20 +0900 Subject: [PATCH 03/24] =?UTF-8?q?[#185]=20feat(ScheduleModifyRequest):=20?= =?UTF-8?q?=ED=9A=8C=EC=B0=A8=20=EC=88=98=EC=A0=95=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/schedule/ScheduleModifyRequest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyRequest.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyRequest.java b/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyRequest.java new file mode 100644 index 00000000..fcda2a5f --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyRequest.java @@ -0,0 +1,13 @@ +package com.beat.domain.performance.application.dto.modify.schedule; + +import org.jetbrains.annotations.Nullable; + +import java.time.LocalDateTime; + +public record ScheduleModifyRequest( + @Nullable + Long scheduleId, + LocalDateTime performanceDate, + int totalTicketCount +) { +} \ No newline at end of file From f36cab5075e2d7bf4b1d2e58d9d53d9e440ce33d Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:51:30 +0900 Subject: [PATCH 04/24] =?UTF-8?q?[#185]=20feat(ScheduleModifyResponse):=20?= =?UTF-8?q?=ED=9A=8C=EC=B0=A8=20=EC=88=98=EC=A0=95=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modify/schedule/ScheduleModifyResponse.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyResponse.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyResponse.java b/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyResponse.java new file mode 100644 index 00000000..fadf4dc9 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/schedule/ScheduleModifyResponse.java @@ -0,0 +1,16 @@ +package com.beat.domain.performance.application.dto.modify.schedule; + +import com.beat.domain.schedule.domain.ScheduleNumber; + +import java.time.LocalDateTime; + +public record ScheduleModifyResponse(Long scheduleId, + LocalDateTime performanceDate, + int totalTicketCount, + int dueDate, + ScheduleNumber scheduleNumber) { + + public static ScheduleModifyResponse of(Long scheduleId, LocalDateTime performanceDate, int totalTicketCount, int dueDate, ScheduleNumber scheduleNumber) { + return new ScheduleModifyResponse(scheduleId, performanceDate, totalTicketCount, dueDate, scheduleNumber); + } +} \ No newline at end of file From 44b6fe21e049c6e22144ff71cc9e51bb9954d7b8 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:51:50 +0900 Subject: [PATCH 05/24] =?UTF-8?q?[#185]=20feat(CastModifyRequest):=20?= =?UTF-8?q?=EB=93=B1=EC=9E=A5=EC=9D=B8=EB=AC=BC=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/cast/CastModifyRequest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyRequest.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyRequest.java b/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyRequest.java new file mode 100644 index 00000000..3f3b56d2 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyRequest.java @@ -0,0 +1,12 @@ +package com.beat.domain.performance.application.dto.modify.cast; + +import org.jetbrains.annotations.Nullable; + +public record CastModifyRequest( + @Nullable + Long castId, + String castName, + String castRole, + String castPhoto +) { +} \ No newline at end of file From 6e22790ea6fa62f9d4f9435794ffe27cea144b3e Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:52:03 +0900 Subject: [PATCH 06/24] =?UTF-8?q?[#185]=20feat(CastModifyResponse):=20?= =?UTF-8?q?=EB=93=B1=EC=9E=A5=EC=9D=B8=EB=AC=BC=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/cast/CastModifyResponse.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyResponse.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyResponse.java b/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyResponse.java new file mode 100644 index 00000000..bfed8151 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/cast/CastModifyResponse.java @@ -0,0 +1,11 @@ +package com.beat.domain.performance.application.dto.modify.cast; + +public record CastModifyResponse(Long castId, + String castName, + String castRole, + String castPhoto) { + + public static CastModifyResponse of(Long castId, String castName, String castRole, String castPhoto) { + return new CastModifyResponse(castId, castName, castRole, castPhoto); + } +} \ No newline at end of file From dd32ec37c30519db5e9a19e91316f3cf06907e39 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:52:13 +0900 Subject: [PATCH 07/24] =?UTF-8?q?[#185]=20feat(StaffModifyRequest):=20?= =?UTF-8?q?=EC=8A=A4=ED=83=9C=ED=94=84=20=EC=88=98=EC=A0=95=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/staff/StaffModifyRequest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyRequest.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyRequest.java b/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyRequest.java new file mode 100644 index 00000000..67020ed1 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyRequest.java @@ -0,0 +1,12 @@ +package com.beat.domain.performance.application.dto.modify.staff; + +import org.jetbrains.annotations.Nullable; + +public record StaffModifyRequest( + @Nullable + Long staffId, + String staffName, + String staffRole, + String staffPhoto +) { +} \ No newline at end of file From 91d10579f5fdac0000c40434d929f168b0b22db3 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:52:24 +0900 Subject: [PATCH 08/24] =?UTF-8?q?[#185]=20feat(StaffModifyResponse):=20?= =?UTF-8?q?=EC=8A=A4=ED=83=9C=ED=94=84=20=EC=88=98=EC=A0=95=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/staff/StaffModifyResponse.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyResponse.java diff --git a/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyResponse.java b/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyResponse.java new file mode 100644 index 00000000..afe97f49 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/staff/StaffModifyResponse.java @@ -0,0 +1,11 @@ +package com.beat.domain.performance.application.dto.modify.staff; + +public record StaffModifyResponse(Long staffId, + String staffName, + String staffRole, + String staffPhoto) { + + public static StaffModifyResponse of(Long staffId, String staffName, String staffRole, String staffPhoto) { + return new StaffModifyResponse(staffId, staffName, staffRole, staffPhoto); + } +} \ No newline at end of file From 6ef31fcaac1dfdb4a5e9d92f3500618e45ffead3 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:52:46 +0900 Subject: [PATCH 09/24] =?UTF-8?q?[#185]=20feat(PerformanceModifyRequest):?= =?UTF-8?q?=20=EA=B3=B5=EC=97=B0=20=EC=88=98=EC=A0=95=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/PerformanceModifyRequest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java 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 new file mode 100644 index 00000000..89cca1d2 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyRequest.java @@ -0,0 +1,31 @@ +package com.beat.domain.performance.application.dto.modify; + +import com.beat.domain.performance.application.dto.modify.cast.CastModifyRequest; +import com.beat.domain.performance.application.dto.modify.schedule.ScheduleModifyRequest; +import com.beat.domain.performance.application.dto.modify.staff.StaffModifyRequest; +import com.beat.domain.performance.domain.BankName; +import com.beat.domain.performance.domain.Genre; + +import java.util.List; + +public record PerformanceModifyRequest( + Long performanceId, + String performanceTitle, + Genre genre, + int runningTime, + String performanceDescription, + String performanceAttentionNote, + BankName bankName, + String accountNumber, + String accountHolder, + String posterImage, + String performanceTeamName, + String performanceVenue, + String performanceContact, + String performancePeriod, + int totalScheduleCount, + int ticketPrice, + List scheduleModifyRequests, + List castModifyRequests, + List staffModifyRequests +) {} \ No newline at end of file From 228cc0dc6ed78079ae0af255786c5fcc76bcbfa2 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:52:59 +0900 Subject: [PATCH 10/24] =?UTF-8?q?[#185]=20feat(PerformanceModifyResponse):?= =?UTF-8?q?=20=EA=B3=B5=EC=97=B0=20=EC=88=98=EC=A0=95=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=20DTO=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/modify/PerformanceModifyResponse.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java 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 new file mode 100644 index 00000000..734e2086 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/dto/modify/PerformanceModifyResponse.java @@ -0,0 +1,79 @@ +package com.beat.domain.performance.application.dto.modify; + +import com.beat.domain.performance.application.dto.modify.cast.CastModifyResponse; +import com.beat.domain.performance.application.dto.modify.schedule.ScheduleModifyResponse; +import com.beat.domain.performance.application.dto.modify.staff.StaffModifyResponse; +import com.beat.domain.performance.domain.BankName; +import com.beat.domain.performance.domain.Genre; + +import java.util.List; + +public record PerformanceModifyResponse( + Long userId, + Long performanceId, + String performanceTitle, + Genre genre, + int runningTime, + String performanceDescription, + String performanceAttentionNote, + BankName bankName, + String accountNumber, + String accountHolder, + String posterImage, + String performanceTeamName, + String performanceVenue, + String performanceContact, + String performancePeriod, + int ticketPrice, + int totalScheduleCount, + List scheduleModifyResponses, + List castModifyResponses, + List staffModifyResponses +) { + public static PerformanceModifyResponse of( + Long userId, + Long performanceId, + String performanceTitle, + Genre genre, + int runningTime, + String performanceDescription, + String performanceAttentionNote, + BankName bankName, + String accountNumber, + String accountHolder, + String posterImage, + String performanceTeamName, + String performanceVenue, + String performanceContact, + String performancePeriod, + int ticketPrice, + int totalScheduleCount, + List scheduleModifyRespons, + List castModifyRespons, + List staffModifyRespons) + { + + return new PerformanceModifyResponse( + userId, + performanceId, + performanceTitle, + genre, + runningTime, + performanceDescription, + performanceAttentionNote, + bankName, + accountNumber, + accountHolder, + posterImage, + performanceTeamName, + performanceVenue, + performanceContact, + performancePeriod, + ticketPrice, + totalScheduleCount, + scheduleModifyRespons, + castModifyRespons, + staffModifyRespons + ); + } +} \ No newline at end of file From 3a077d6eedc4846b6d0cb734445eec8c417cae5f Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:53:28 +0900 Subject: [PATCH 11/24] =?UTF-8?q?[#185]=20refactor(Schedule):=20scheduleNu?= =?UTF-8?q?mber=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/beat/domain/schedule/domain/Schedule.java | 3 +++ 1 file changed, 3 insertions(+) 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 d3e33df4..b3f17cc6 100644 --- a/src/main/java/com/beat/domain/schedule/domain/Schedule.java +++ b/src/main/java/com/beat/domain/schedule/domain/Schedule.java @@ -89,4 +89,7 @@ public void decreaseSoldTicketCount(int count) { } } + public void updateScheduleNumber(ScheduleNumber scheduleNumber) { + this.scheduleNumber = scheduleNumber; + } } \ No newline at end of file From 389e06b6c7998c61621c34382ce9b541c29c07b3 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:54:39 +0900 Subject: [PATCH 12/24] =?UTF-8?q?[#185]=20refactor(StaffRepository):=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=20id=EB=A5=BC=20?= =?UTF-8?q?=EC=99=B8=EB=9E=98=ED=82=A4=EB=A1=9C=20=EA=B0=80=EC=A7=80?= =?UTF-8?q?=EB=8A=94=20=ED=9A=8C=EC=B0=A8=20id=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20JPA?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/beat/domain/staff/dao/StaffRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/beat/domain/staff/dao/StaffRepository.java b/src/main/java/com/beat/domain/staff/dao/StaffRepository.java index d3af9518..f32801ea 100644 --- a/src/main/java/com/beat/domain/staff/dao/StaffRepository.java +++ b/src/main/java/com/beat/domain/staff/dao/StaffRepository.java @@ -2,6 +2,7 @@ import com.beat.domain.staff.domain.Staff; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; @@ -9,4 +10,7 @@ public interface StaffRepository extends JpaRepository { List findByPerformanceId(Long performanceId); List findAllByPerformanceId(Long performanceId); + + @Query("SELECT s.id FROM Staff s WHERE s.performance.id = :performanceId") + List findIdsByPerformanceId(Long performanceId); } From 41b68d9cd2dc57a7def5a8b1dfaf09d8072017f4 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:55:51 +0900 Subject: [PATCH 13/24] =?UTF-8?q?[#185]=20refactor(CastRepository):=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=20id=EB=A5=BC=20?= =?UTF-8?q?=EC=99=B8=EB=9E=98=ED=82=A4=EB=A1=9C=20=EA=B0=80=EC=A7=80?= =?UTF-8?q?=EB=8A=94=20=EB=93=B1=EC=9E=A5=EC=9D=B8=EB=AC=BC=20id=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8A=94=20JPA=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/beat/domain/cast/dao/CastRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/beat/domain/cast/dao/CastRepository.java b/src/main/java/com/beat/domain/cast/dao/CastRepository.java index 37eb520b..98e6214b 100644 --- a/src/main/java/com/beat/domain/cast/dao/CastRepository.java +++ b/src/main/java/com/beat/domain/cast/dao/CastRepository.java @@ -2,6 +2,7 @@ import com.beat.domain.cast.domain.Cast; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.List; @@ -9,4 +10,7 @@ public interface CastRepository extends JpaRepository { List findByPerformanceId(Long performanceId); List findAllByPerformanceId(Long performanceId); + + @Query("SELECT c.id FROM Cast c WHERE c.performance.id = :performanceId") + List findIdsByPerformanceId(Long performanceId); } From 590224fe6daf53e09a3e53e9c17862506e57d523 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 01:56:50 +0900 Subject: [PATCH 14/24] =?UTF-8?q?[#185]=20refactor(PerformanceController):?= =?UTF-8?q?=20DTO=20=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/api/PerformanceController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/beat/domain/performance/api/PerformanceController.java b/src/main/java/com/beat/domain/performance/api/PerformanceController.java index ecabf3d6..6ff5dd28 100644 --- a/src/main/java/com/beat/domain/performance/api/PerformanceController.java +++ b/src/main/java/com/beat/domain/performance/api/PerformanceController.java @@ -1,15 +1,15 @@ package com.beat.domain.performance.api; import com.beat.domain.performance.application.PerformanceManagementService; -import com.beat.domain.performance.application.PerformanceUpdateService; +import com.beat.domain.performance.application.PerformanceModifyService; import com.beat.domain.performance.application.dto.BookingPerformanceDetailResponse; import com.beat.domain.performance.application.dto.MakerPerformanceResponse; import com.beat.domain.performance.application.dto.PerformanceDetailResponse; import com.beat.domain.performance.application.dto.PerformanceEditResponse; import com.beat.domain.performance.application.dto.create.PerformanceRequest; import com.beat.domain.performance.application.dto.create.PerformanceResponse; -import com.beat.domain.performance.application.dto.update.PerformanceUpdateRequest; -import com.beat.domain.performance.application.dto.update.PerformanceUpdateResponse; +import com.beat.domain.performance.application.dto.modify.PerformanceModifyRequest; +import com.beat.domain.performance.application.dto.modify.PerformanceModifyResponse; import com.beat.domain.performance.exception.PerformanceSuccessCode; import com.beat.domain.performance.application.PerformanceService; import com.beat.global.auth.annotation.CurrentMember; @@ -36,7 +36,7 @@ public class PerformanceController { private final PerformanceService performanceService; private final PerformanceManagementService performanceManagementService; - private final PerformanceUpdateService performanceUpdateService; + private final PerformanceModifyService performanceModifyService; @Operation(summary = "공연 생성 API", description = "공연을 생성하는 POST API입니다.") @PostMapping @@ -63,10 +63,10 @@ public ResponseEntity> createPerformance( @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) @PutMapping - public ResponseEntity> updatePerformance( + public ResponseEntity> updatePerformance( @CurrentMember Long memberId, - @RequestBody PerformanceUpdateRequest performanceUpdateRequest) { - PerformanceUpdateResponse response = performanceUpdateService.updatePerformance(memberId, performanceUpdateRequest); + @RequestBody PerformanceModifyRequest performanceModifyRequest) { + PerformanceModifyResponse response = performanceModifyService.updatePerformance(memberId, performanceModifyRequest); return ResponseEntity.status(HttpStatus.OK) .body(SuccessResponse.of(PerformanceSuccessCode.PERFORMANCE_UPDATE_SUCCESS, response)); } From f9bf26717c401c7b929651203f30e79f25a7c186 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:04:47 +0900 Subject: [PATCH 15/24] =?UTF-8?q?[#185]=20feat(PerformanceModifyService):?= =?UTF-8?q?=20PerformanceModifyService=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20?= =?UTF-8?q?=EA=B3=B5=EC=97=B0=20=EC=88=98=EC=A0=95=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/PerformanceModifyService.java | 437 ++++++++++++++++++ 1 file changed, 437 insertions(+) create mode 100644 src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java diff --git a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java new file mode 100644 index 00000000..69e17cc4 --- /dev/null +++ b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java @@ -0,0 +1,437 @@ +package com.beat.domain.performance.application; + +import com.beat.domain.booking.dao.BookingRepository; +import com.beat.domain.cast.dao.CastRepository; +import com.beat.domain.cast.domain.Cast; +import com.beat.domain.cast.exception.CastErrorCode; +import com.beat.domain.member.dao.MemberRepository; +import com.beat.domain.member.domain.Member; +import com.beat.domain.member.exception.MemberErrorCode; +import com.beat.domain.performance.application.dto.modify.*; +import com.beat.domain.performance.application.dto.modify.cast.CastModifyRequest; +import com.beat.domain.performance.application.dto.modify.cast.CastModifyResponse; +import com.beat.domain.performance.application.dto.modify.schedule.ScheduleModifyRequest; +import com.beat.domain.performance.application.dto.modify.schedule.ScheduleModifyResponse; +import com.beat.domain.performance.application.dto.modify.staff.StaffModifyRequest; +import com.beat.domain.performance.application.dto.modify.staff.StaffModifyResponse; +import com.beat.domain.performance.dao.PerformanceRepository; +import com.beat.domain.performance.domain.Performance; +import com.beat.domain.performance.exception.PerformanceErrorCode; +import com.beat.domain.schedule.dao.ScheduleRepository; +import com.beat.domain.schedule.domain.Schedule; +import com.beat.domain.schedule.domain.ScheduleNumber; +import com.beat.domain.schedule.exception.ScheduleErrorCode; +import com.beat.domain.staff.dao.StaffRepository; +import com.beat.domain.staff.domain.Staff; +import com.beat.domain.staff.exception.StaffErrorCode; +import com.beat.global.common.exception.BadRequestException; +import com.beat.global.common.exception.ForbiddenException; +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; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +@Service +@RequiredArgsConstructor +public class PerformanceModifyService { + + private final PerformanceRepository performanceRepository; + private final ScheduleRepository scheduleRepository; + private final MemberRepository memberRepository; + private final CastRepository castRepository; + private final StaffRepository staffRepository; + private final BookingRepository bookingRepository; + + @Transactional + public PerformanceModifyResponse modifyPerformance(Long memberId, PerformanceModifyRequest request) { + log.info("Starting updatePerformance for memberId: {}, performanceId: {}", memberId, request.performanceId()); + + Member member = validateMember(memberId); + Long userId = member.getUser().getId(); + + Performance performance = findPerformance(request.performanceId()); + + validateOwnership(userId, performance); + + List scheduleIds = scheduleRepository.findIdsByPerformanceId(request.performanceId()); + boolean isBookerExist = bookingRepository.existsByScheduleIdIn(scheduleIds); + + if (isBookerExist && request.ticketPrice() != performance.getTicketPrice()) { + log.error("Ticket price update failed due to existing bookings for performanceId: {}", performance.getId()); + throw new BadRequestException(PerformanceErrorCode.PRICE_UPDATE_NOT_ALLOWED); + } + + updatePerformanceDetails(performance, request, isBookerExist); + + List modifiedSchedules = processSchedules(request.scheduleModifyRequests(), performance); + List modifiedCasts = processCasts(request.castModifyRequests(), performance); + List modifiedStaffs = processStaffs(request.staffModifyRequests(), performance); + + PerformanceModifyResponse response = completeModifyResponse(performance, modifiedSchedules, modifiedCasts, modifiedStaffs); + + log.info("Successfully completed updatePerformance for performanceId: {}", request.performanceId()); + return response; + } + + private Member validateMember(Long memberId) { + log.debug("Validating memberId: {}", memberId); + return memberRepository.findById(memberId) + .orElseThrow(() -> { + log.error("Member not found: memberId: {}", memberId); + return new NotFoundException(MemberErrorCode.MEMBER_NOT_FOUND); + }); + } + + private Performance findPerformance(Long performanceId) { + log.debug("Finding performance with performanceId: {}", performanceId); + return performanceRepository.findById(performanceId) + .orElseThrow(() -> { + log.error("Performance not found: performanceId: {}", performanceId); + return new NotFoundException(PerformanceErrorCode.PERFORMANCE_NOT_FOUND); + }); + } + + private void validateOwnership(Long userId, Performance performance) { + if (!performance.getUsers().getId().equals(userId)) { + log.error("User ID {} does not own performance ID {}", userId, performance.getId()); + throw new ForbiddenException(PerformanceErrorCode.NOT_PERFORMANCE_OWNER); + } + } + + private void updatePerformanceDetails(Performance performance, PerformanceModifyRequest request, boolean isBookerExist) { + log.debug("Updating performance details for performanceId: {}", performance.getId()); + + performance.update( + request.performanceTitle(), + request.genre(), + request.runningTime(), + request.performanceDescription(), + request.performanceAttentionNote(), + request.bankName(), + request.accountNumber(), + request.accountHolder(), + request.posterImage(), + request.performanceTeamName(), + request.performanceVenue(), + request.performanceContact(), + request.performancePeriod(), + request.totalScheduleCount() + ); + + if (!isBookerExist) { + log.debug("Updating ticket price to {}", request.ticketPrice()); + performance.updateTicketPrice(request.ticketPrice()); + } + + performanceRepository.save(performance); + log.debug("Performance details updated for performanceId: {}", performance.getId()); + } + + private List processSchedules(List scheduleRequests, Performance performance) { + // 현재 존재하는 스케줄 ID를 가져옵니다. + List existingScheduleIds = scheduleRepository.findIdsByPerformanceId(performance.getId()); + + // 스케줄 요청에 따라 추가 또는 업데이트된 스케줄 객체를 생성합니다. + List schedules = scheduleRequests.stream() + .map(request -> { + if (request.scheduleId() == null) { + return addSchedule(request, performance); + } else { + existingScheduleIds.remove(request.scheduleId()); + return updateSchedule(request); + } + }) + .collect(Collectors.toList()); + + // 요청에 포함되지 않은 기존 스케줄은 삭제합니다. + deleteRemainingSchedules(existingScheduleIds); + + // 스케줄 번호를 할당합니다. + assignScheduleNumbers(schedules); + + // Schedule 리스트를 ScheduleModifyResponse 리스트로 변환하여 반환합니다. + return schedules.stream() + .map(schedule -> ScheduleModifyResponse.of( + schedule.getId(), + schedule.getPerformanceDate(), + schedule.getTotalTicketCount(), + calculateDueDate(schedule.getPerformanceDate()), + schedule.getScheduleNumber() + )) + .collect(Collectors.toList()); + } + + private void assignScheduleNumbers(List schedules) { + // 스케줄을 날짜 순서대로 정렬합니다. + schedules.sort(Comparator.comparing(Schedule::getPerformanceDate)); + + // 각 스케줄에 번호를 부여합니다. + for (int i = 0; i < schedules.size(); i++) { + ScheduleNumber scheduleNumber = ScheduleNumber.values()[i]; + schedules.get(i).updateScheduleNumber(scheduleNumber); + } + } + + private Schedule addSchedule(ScheduleModifyRequest request, Performance performance) { + log.debug("Adding schedules for performanceId: {}", performance.getId()); + + long existingSchedulesCount = scheduleRepository.countByPerformanceId(performance.getId()); + + // 스케줄 최대 개수 초과 여부 확인 + if ((existingSchedulesCount + 1) > 3) { + throw new BadRequestException(PerformanceErrorCode.MAX_SCHEDULE_LIMIT_EXCEEDED); + } + + Schedule schedule = Schedule.create( + request.performanceDate(), + request.totalTicketCount(), + 0, + true, + ScheduleNumber.FIRST, // 임시로 1회차 + performance + ); + + Schedule savedSchedule = scheduleRepository.save(schedule); + log.debug("Added schedule with scheduleId: {} for performanceId: {}", savedSchedule.getId(), performance.getId()); + return savedSchedule; + } + + private Schedule updateSchedule(ScheduleModifyRequest request) { + log.debug("Updating schedules for scheduleId: {}", request.scheduleId()); + + Schedule schedule = scheduleRepository.findById(request.scheduleId()) + .orElseThrow(() -> { + log.error("Schedule not found: scheduleId: {}", request.scheduleId()); + return new NotFoundException(ScheduleErrorCode.NO_SCHEDULE_FOUND); + }); + schedule.update( + request.performanceDate(), + request.totalTicketCount(), + schedule.getScheduleNumber() // 기존 scheduleNumber 유지 + ); + return scheduleRepository.save(schedule); + } + + private void deleteRemainingSchedules(List scheduleIds) { + if (scheduleIds == null || scheduleIds.isEmpty()) { + log.debug("No schedules to delete"); + return; + } + + scheduleIds.forEach(scheduleId -> { + Schedule schedule = scheduleRepository.findById(scheduleId) + .orElseThrow(() -> { + log.error("Schedule not found: scheduleId: {}", scheduleId); + return new NotFoundException(ScheduleErrorCode.NO_SCHEDULE_FOUND); + }); + scheduleRepository.delete(schedule); + log.debug("Deleted schedule with scheduleId: {}", scheduleId); + }); + } + + private List processCasts(List castRequests, Performance performance) { + log.debug("Processing casts for performanceId: {}", performance.getId()); + + List existingCastIds = castRepository.findIdsByPerformanceId(performance.getId()); + + List responses = castRequests.stream() + .map(request -> { + if (request.castId() == null) { + return addCast(request, performance); + } else { + existingCastIds.remove(request.castId()); // 요청에 포함된 ID는 삭제 후보에서 제거 + return updateCast(request); + } + }) + .collect(Collectors.toList()); + + deleteRemainingCasts(existingCastIds); + + return responses; + } + + private CastModifyResponse addCast(CastModifyRequest request, Performance performance) { + log.debug("Adding casts for performanceId: {}", performance.getId()); + + Cast cast = Cast.create( + request.castName(), + request.castRole(), + request.castPhoto(), + performance + ); + Cast savedCast = castRepository.save(cast); + log.debug("Added cast with castId: {} for performanceId: {}", savedCast.getId(), performance.getId()); + return CastModifyResponse.of( + savedCast.getId(), + savedCast.getCastName(), + savedCast.getCastRole(), + savedCast.getCastPhoto() + ); + } + + private CastModifyResponse updateCast(CastModifyRequest request) { + log.debug("Updating casts for castId: {}", request.castId()); + + Cast cast = castRepository.findById(request.castId()) + .orElseThrow(() -> { + log.error("Cast not found: castId: {}", request.castId()); + return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); + }); + cast.update( + request.castName(), + request.castRole(), + request.castPhoto() + ); + castRepository.save(cast); + log.debug("Updated cast with castId: {}", cast.getId()); + return CastModifyResponse.of( + cast.getId(), + cast.getCastName(), + cast.getCastRole(), + cast.getCastPhoto() + ); + } + + private void deleteRemainingCasts(List castIds) { + if (castIds == null || castIds.isEmpty()) { + log.debug("No casts to delete"); + return; + } + + castIds.forEach(castId -> { + Cast cast = castRepository.findById(castId) + .orElseThrow(() -> { + log.error("Cast not found: castId: {}", castId); + return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); + }); + castRepository.delete(cast); + log.debug("Deleted cast with castId: {}", castId); + }); + } + + private List processStaffs(List staffRequests, Performance performance) { + log.debug("Processing staffs for performanceId: {}", performance.getId()); + + List existingStaffIds = staffRepository.findIdsByPerformanceId(performance.getId()); + + List responses = staffRequests.stream() + .map(request -> { + if (request.staffId() == null) { + return addStaff(request, performance); + } else { + existingStaffIds.remove(request.staffId()); // 요청에 포함된 ID는 삭제 후보에서 제거 + return updateStaff(request); + } + }) + .collect(Collectors.toList()); + + deleteRemainingStaffs(existingStaffIds); + + return responses; + } + + private StaffModifyResponse addStaff(StaffModifyRequest request, Performance performance) { + log.debug("Adding staffs for performanceId: {}", performance.getId()); + + Staff staff = Staff.create( + request.staffName(), + request.staffRole(), + request.staffPhoto(), + performance + ); + Staff savedStaff = staffRepository.save(staff); + log.debug("Added staff with staffId: {} for performanceId: {}", savedStaff.getId(), performance.getId()); + return StaffModifyResponse.of( + savedStaff.getId(), + savedStaff.getStaffName(), + savedStaff.getStaffRole(), + savedStaff.getStaffPhoto() + ); + } + + private StaffModifyResponse updateStaff(StaffModifyRequest request) { + log.debug("Updating staffs for staffId: {}", request.staffId()); + + Staff staff = staffRepository.findById(request.staffId()) + .orElseThrow(() -> { + log.error("Staff not found: staffId: {}", request.staffId()); + return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); + }); + staff.update( + request.staffName(), + request.staffRole(), + request.staffPhoto() + ); + staffRepository.save(staff); + log.debug("Updated staff with staffId: {}", staff.getId()); + return StaffModifyResponse.of( + staff.getId(), + staff.getStaffName(), + staff.getStaffRole(), + staff.getStaffPhoto() + ); + } + + private void deleteRemainingStaffs(List staffIds) { + if (staffIds == null || staffIds.isEmpty()) { + log.debug("No staffs to delete"); + return; + } + + staffIds.forEach(staffId -> { + Staff staff = staffRepository.findById(staffId) + .orElseThrow(() -> { + log.error("Staff not found: staffId: {}", staffId); + return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); + }); + staffRepository.delete(staff); + log.debug("Deleted staff with staffId: {}", staffId); + }); + } + + private int calculateDueDate(LocalDateTime performanceDate) { + return (int) ChronoUnit.DAYS.between(LocalDate.now(), performanceDate.toLocalDate()); + } + + private PerformanceModifyResponse completeModifyResponse( + Performance performance, + List scheduleModifyResponses, + List castModifyResponses, + List staffModifyResponses + ) { + log.debug("Creating PerformanceModifyResponse for performanceId: {}", performance.getId()); + PerformanceModifyResponse response = PerformanceModifyResponse.of( + performance.getUsers().getId(), + performance.getId(), + performance.getPerformanceTitle(), + performance.getGenre(), + performance.getRunningTime(), + performance.getPerformanceDescription(), + performance.getPerformanceAttentionNote(), + performance.getBankName(), + performance.getAccountNumber(), + performance.getAccountHolder(), + performance.getPosterImage(), + performance.getPerformanceTeamName(), + performance.getPerformanceVenue(), + performance.getPerformanceContact(), + performance.getPerformancePeriod(), + performance.getTicketPrice(), + performance.getTotalScheduleCount(), + scheduleModifyResponses, + castModifyResponses, + staffModifyResponses + ); + log.info("PerformanceModifyResponse created successfully for performanceId: {}", performance.getId()); + return response; + } +} \ No newline at end of file From 57a674f11aefdf264980261723adff5f5badaa6d Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:05:17 +0900 Subject: [PATCH 16/24] =?UTF-8?q?[#185]=20refactor(PerformanceController):?= =?UTF-8?q?=20=EA=B3=B5=EC=97=B0=20=EC=88=98=EC=A0=95=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/beat/domain/performance/api/PerformanceController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/beat/domain/performance/api/PerformanceController.java b/src/main/java/com/beat/domain/performance/api/PerformanceController.java index 6ff5dd28..7af7d46d 100644 --- a/src/main/java/com/beat/domain/performance/api/PerformanceController.java +++ b/src/main/java/com/beat/domain/performance/api/PerformanceController.java @@ -66,7 +66,7 @@ public ResponseEntity> createPerformance( public ResponseEntity> updatePerformance( @CurrentMember Long memberId, @RequestBody PerformanceModifyRequest performanceModifyRequest) { - PerformanceModifyResponse response = performanceModifyService.updatePerformance(memberId, performanceModifyRequest); + PerformanceModifyResponse response = performanceModifyService.modifyPerformance(memberId, performanceModifyRequest); return ResponseEntity.status(HttpStatus.OK) .body(SuccessResponse.of(PerformanceSuccessCode.PERFORMANCE_UPDATE_SUCCESS, response)); } From 516db488d015619c1d71c9d88ff0ddfbf372bac9 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:52:53 +0900 Subject: [PATCH 17/24] =?UTF-8?q?[#185]=20refactor(CastErrorCode):=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=EC=97=90=20=EC=86=8D?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EB=93=B1=EC=9E=A5?= =?UTF-8?q?=EC=9D=B8=EB=AC=BC=EC=9D=84=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EB=A0=A4=EA=B3=A0=20=ED=95=A0=20=EB=95=8C=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=97=90=EB=9F=AC=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/beat/domain/cast/exception/CastErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/beat/domain/cast/exception/CastErrorCode.java b/src/main/java/com/beat/domain/cast/exception/CastErrorCode.java index 9658d8ab..15189c27 100644 --- a/src/main/java/com/beat/domain/cast/exception/CastErrorCode.java +++ b/src/main/java/com/beat/domain/cast/exception/CastErrorCode.java @@ -7,6 +7,7 @@ @Getter @RequiredArgsConstructor public enum CastErrorCode implements BaseErrorCode { + CAST_NOT_BELONG_TO_PERFORMANCE(403,"해당 등장인물은 해당 공연에 속해 있지 않습니다."), CAST_NOT_FOUND(404, "등장인물이 존재하지 않습니다.") ; From ad3953a7d793b974690612357bc905a1fe42e8c1 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:53:12 +0900 Subject: [PATCH 18/24] =?UTF-8?q?[#185]=20refactor(ScheduleErrorCode):=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=EC=97=90=20=EC=86=8D?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=ED=9A=8C=EC=B0=A8?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=98=EB=A0=A4=EA=B3=A0=20?= =?UTF-8?q?=ED=95=A0=20=EB=95=8C=20=EB=B0=9C=EC=83=9D=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EB=A9=94=EC=8B=9C=EC=A7=80=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 --- .../com/beat/domain/schedule/exception/ScheduleErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/beat/domain/schedule/exception/ScheduleErrorCode.java b/src/main/java/com/beat/domain/schedule/exception/ScheduleErrorCode.java index e9af170a..98e02ad1 100644 --- a/src/main/java/com/beat/domain/schedule/exception/ScheduleErrorCode.java +++ b/src/main/java/com/beat/domain/schedule/exception/ScheduleErrorCode.java @@ -8,6 +8,7 @@ @RequiredArgsConstructor public enum ScheduleErrorCode implements BaseErrorCode { INVALID_DATA_FORMAT(400, "잘못된 데이터 형식입니다."), + SCHEDULE_NOT_BELONG_TO_PERFORMANCE(403,"해당 스케줄은 해당 공연에 속해 있지 않습니다."), NO_SCHEDULE_FOUND(404, "해당 회차를 찾을 수 없습니다."), INSUFFICIENT_TICKETS(409, "요청한 티켓 수량이 잔여 티켓 수를 초과했습니다. 다른 수량을 선택해 주세요."), EXCESS_TICKET_DELETE(409, "예매된 티켓 수 이상을 삭제할 수 없습니다.") From f1f3aa25236d05756e77dde401e8db782bf66873 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:53:23 +0900 Subject: [PATCH 19/24] =?UTF-8?q?[#185]=20refactor(StaffErrorCode):=20?= =?UTF-8?q?=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=EC=97=90=20=EC=86=8D?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=8A=A4=ED=83=9C?= =?UTF-8?q?=ED=94=84=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=98=EB=A0=A4?= =?UTF-8?q?=EA=B3=A0=20=ED=95=A0=20=EB=95=8C=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=97=90=EB=9F=AC=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/beat/domain/staff/exception/StaffErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/beat/domain/staff/exception/StaffErrorCode.java b/src/main/java/com/beat/domain/staff/exception/StaffErrorCode.java index 706e50d8..495ee148 100644 --- a/src/main/java/com/beat/domain/staff/exception/StaffErrorCode.java +++ b/src/main/java/com/beat/domain/staff/exception/StaffErrorCode.java @@ -7,6 +7,7 @@ @Getter @RequiredArgsConstructor public enum StaffErrorCode implements BaseErrorCode { + STAFF_NOT_BELONG_TO_PERFORMANCE(403, "해당 스태프는 해당 공연에 속해있지 않습니다."), STAFF_NOT_FOUND(404, "스태프가 존재하지 않습니다.") ; From ebc506219fdb3c19b8c2dfed10adec3f969abf41 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 02:53:54 +0900 Subject: [PATCH 20/24] =?UTF-8?q?[#185]=20refactor(PerformanceModifyServic?= =?UTF-8?q?e):=20=ED=95=B4=EB=8B=B9=20=EA=B3=B5=EC=97=B0=EC=97=90=20?= =?UTF-8?q?=EC=86=8D=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=ED=9A=8C?= =?UTF-8?q?=EC=B0=A8,=20=EB=93=B1=EC=9E=A5=EC=9D=B8=EB=AC=BC,=20=EC=8A=A4?= =?UTF-8?q?=ED=83=9C=ED=94=84=EB=A5=BC=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EB=A0=A4=EA=B3=A0=20=ED=95=A0=20=EB=95=8C=20=EC=97=90=EB=9F=AC?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/PerformanceModifyService.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) 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 69e17cc4..07157fbd 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java @@ -147,7 +147,7 @@ private List processSchedules(List processCasts(List castReques return addCast(request, performance); } else { existingCastIds.remove(request.castId()); // 요청에 포함된 ID는 삭제 후보에서 제거 - return updateCast(request); + return updateCast(request, performance); } }) .collect(Collectors.toList()); @@ -278,7 +284,7 @@ private CastModifyResponse addCast(CastModifyRequest request, Performance perfor ); } - private CastModifyResponse updateCast(CastModifyRequest request) { + private CastModifyResponse updateCast(CastModifyRequest request, Performance performance) { log.debug("Updating casts for castId: {}", request.castId()); Cast cast = castRepository.findById(request.castId()) @@ -286,6 +292,12 @@ private CastModifyResponse updateCast(CastModifyRequest request) { log.error("Cast not found: castId: {}", request.castId()); return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); }); + + // 공연에 속해 있는지 검증 + if (!cast.getPerformance().equals(performance)) { + throw new ForbiddenException(CastErrorCode.CAST_NOT_BELONG_TO_PERFORMANCE); + } + cast.update( request.castName(), request.castRole(), @@ -329,7 +341,7 @@ private List processStaffs(List staffRe return addStaff(request, performance); } else { existingStaffIds.remove(request.staffId()); // 요청에 포함된 ID는 삭제 후보에서 제거 - return updateStaff(request); + return updateStaff(request, performance); } }) .collect(Collectors.toList()); @@ -358,7 +370,7 @@ private StaffModifyResponse addStaff(StaffModifyRequest request, Performance per ); } - private StaffModifyResponse updateStaff(StaffModifyRequest request) { + private StaffModifyResponse updateStaff(StaffModifyRequest request, Performance performance) { log.debug("Updating staffs for staffId: {}", request.staffId()); Staff staff = staffRepository.findById(request.staffId()) @@ -366,6 +378,12 @@ private StaffModifyResponse updateStaff(StaffModifyRequest request) { log.error("Staff not found: staffId: {}", request.staffId()); return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); }); + + // 공연에 속해 있는지 검증 + if (!staff.getPerformance().equals(performance)) { + throw new ForbiddenException(StaffErrorCode.STAFF_NOT_BELONG_TO_PERFORMANCE); + } + staff.update( request.staffName(), request.staffRole(), From 7e03e799d172f8140ca31558ac7051b392a864e8 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 04:26:40 +0900 Subject: [PATCH 21/24] =?UTF-8?q?[#185]=20refactor(PerformanceModifyServic?= =?UTF-8?q?e):=20=EC=82=AD=EC=A0=9C=20=EC=9E=91=EC=97=85=EC=9D=84=20?= =?UTF-8?q?=EB=A8=BC=EC=A0=80=20=EC=88=98=ED=96=89=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/PerformanceModifyService.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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 07157fbd..7098177a 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java @@ -37,6 +37,7 @@ import java.time.temporal.ChronoUnit; import java.util.Comparator; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @Slf4j @@ -140,21 +141,31 @@ private List processSchedules(List existingScheduleIds = scheduleRepository.findIdsByPerformanceId(performance.getId()); + // 요청에 포함된 스케줄 ID만 남기고 나머지는 삭제합니다. + List requestScheduleIds = scheduleRequests.stream() + .map(ScheduleModifyRequest::scheduleId) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + // 삭제할 스케줄 ID를 결정합니다. + List schedulesToDelete = existingScheduleIds.stream() + .filter(id -> !requestScheduleIds.contains(id)) + .collect(Collectors.toList()); + + // 요청에 포함되지 않은 기존 스케줄은 삭제합니다. + deleteRemainingSchedules(schedulesToDelete); + // 스케줄 요청에 따라 추가 또는 업데이트된 스케줄 객체를 생성합니다. List schedules = scheduleRequests.stream() .map(request -> { if (request.scheduleId() == null) { return addSchedule(request, performance); } else { - existingScheduleIds.remove(request.scheduleId()); return updateSchedule(request, performance); } }) .collect(Collectors.toList()); - // 요청에 포함되지 않은 기존 스케줄은 삭제합니다. - deleteRemainingSchedules(existingScheduleIds); - // 스케줄 번호를 할당합니다. assignScheduleNumbers(schedules); @@ -258,7 +269,7 @@ private List processCasts(List castReques return updateCast(request, performance); } }) - .collect(Collectors.toList()); + .toList(); deleteRemainingCasts(existingCastIds); From 13565352d1431ea0abbbaab4b4b8e62977aebb7a Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 04:27:09 +0900 Subject: [PATCH 22/24] =?UTF-8?q?[#185]=20comment(GuestBookingService):=20?= =?UTF-8?q?totalPaymentAmout=20=EA=B4=80=EB=A0=A8=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beat/domain/booking/application/GuestBookingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/beat/domain/booking/application/GuestBookingService.java b/src/main/java/com/beat/domain/booking/application/GuestBookingService.java index f15601c8..d67befe3 100644 --- a/src/main/java/com/beat/domain/booking/application/GuestBookingService.java +++ b/src/main/java/com/beat/domain/booking/application/GuestBookingService.java @@ -79,7 +79,7 @@ public GuestBookingResponse createGuestBooking(GuestBookingRequest guestBookingR booking.isPaymentCompleted(), schedule.getPerformance().getBankName(), schedule.getPerformance().getAccountNumber(), - totalPaymentAmount, + totalPaymentAmount, // 회원 예매랑 다른 부분 확인하기 booking.getCreatedAt() ); } From a4854098dca413cc0eaec098a318eb52dd771dac Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 04:27:16 +0900 Subject: [PATCH 23/24] =?UTF-8?q?[#185]=20comment(MemberBookingService):?= =?UTF-8?q?=20totalPaymentAmout=20=EA=B4=80=EB=A0=A8=20=EC=A3=BC=EC=84=9D?= =?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 --- .../beat/domain/booking/application/MemberBookingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/beat/domain/booking/application/MemberBookingService.java b/src/main/java/com/beat/domain/booking/application/MemberBookingService.java index 2d6d9ccb..58019edf 100644 --- a/src/main/java/com/beat/domain/booking/application/MemberBookingService.java +++ b/src/main/java/com/beat/domain/booking/application/MemberBookingService.java @@ -70,7 +70,7 @@ public MemberBookingResponse createMemberBooking(Long memberId, MemberBookingReq booking.isPaymentCompleted(), schedule.getPerformance().getBankName(), schedule.getPerformance().getAccountNumber(), - memberBookingRequest.totalPaymentAmount(), + memberBookingRequest.totalPaymentAmount(), // 비회원 예매처럼 int totalPaymentAmount = ticketPrice * guestBookingRequest.purchaseTicketCount();로 계산해서 반영하기 + 요청한 총 가격 == 티켓 가격 * 수 같은지 검증하는 로직 추가하기 booking.getCreatedAt() ); } From a2abe75050ff8ac7882964afa193f17884d5f46d Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Fri, 23 Aug 2024 04:32:28 +0900 Subject: [PATCH 24/24] =?UTF-8?q?[#185]=20comment(PerformanceModifyService?= =?UTF-8?q?):=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/PerformanceModifyService.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) 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 7098177a..40aa7eef 100644 --- a/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java +++ b/src/main/java/com/beat/domain/performance/application/PerformanceModifyService.java @@ -138,24 +138,19 @@ private void updatePerformanceDetails(Performance performance, PerformanceModify } private List processSchedules(List scheduleRequests, Performance performance) { - // 현재 존재하는 스케줄 ID를 가져옵니다. List existingScheduleIds = scheduleRepository.findIdsByPerformanceId(performance.getId()); - // 요청에 포함된 스케줄 ID만 남기고 나머지는 삭제합니다. List requestScheduleIds = scheduleRequests.stream() .map(ScheduleModifyRequest::scheduleId) .filter(Objects::nonNull) .collect(Collectors.toList()); - // 삭제할 스케줄 ID를 결정합니다. List schedulesToDelete = existingScheduleIds.stream() .filter(id -> !requestScheduleIds.contains(id)) .collect(Collectors.toList()); - // 요청에 포함되지 않은 기존 스케줄은 삭제합니다. deleteRemainingSchedules(schedulesToDelete); - // 스케줄 요청에 따라 추가 또는 업데이트된 스케줄 객체를 생성합니다. List schedules = scheduleRequests.stream() .map(request -> { if (request.scheduleId() == null) { @@ -166,10 +161,8 @@ private List processSchedules(List ScheduleModifyResponse.of( schedule.getId(), @@ -182,10 +175,8 @@ private List processSchedules(List schedules) { - // 스케줄을 날짜 순서대로 정렬합니다. schedules.sort(Comparator.comparing(Schedule::getPerformanceDate)); - // 각 스케줄에 번호를 부여합니다. for (int i = 0; i < schedules.size(); i++) { ScheduleNumber scheduleNumber = ScheduleNumber.values()[i]; schedules.get(i).updateScheduleNumber(scheduleNumber); @@ -197,7 +188,6 @@ private Schedule addSchedule(ScheduleModifyRequest request, Performance performa long existingSchedulesCount = scheduleRepository.countByPerformanceId(performance.getId()); - // 스케줄 최대 개수 초과 여부 확인 if ((existingSchedulesCount + 1) > 3) { throw new BadRequestException(PerformanceErrorCode.MAX_SCHEDULE_LIMIT_EXCEEDED); } @@ -225,7 +215,6 @@ private Schedule updateSchedule(ScheduleModifyRequest request, Performance perfo return new NotFoundException(ScheduleErrorCode.NO_SCHEDULE_FOUND); }); - // 공연에 속해 있는지 검증 if (!schedule.getPerformance().equals(performance)) { throw new ForbiddenException(ScheduleErrorCode.SCHEDULE_NOT_BELONG_TO_PERFORMANCE); } @@ -265,7 +254,7 @@ private List processCasts(List castReques if (request.castId() == null) { return addCast(request, performance); } else { - existingCastIds.remove(request.castId()); // 요청에 포함된 ID는 삭제 후보에서 제거 + existingCastIds.remove(request.castId()); return updateCast(request, performance); } }) @@ -304,7 +293,6 @@ private CastModifyResponse updateCast(CastModifyRequest request, Performance per return new NotFoundException(CastErrorCode.CAST_NOT_FOUND); }); - // 공연에 속해 있는지 검증 if (!cast.getPerformance().equals(performance)) { throw new ForbiddenException(CastErrorCode.CAST_NOT_BELONG_TO_PERFORMANCE); } @@ -390,7 +378,6 @@ private StaffModifyResponse updateStaff(StaffModifyRequest request, Performance return new NotFoundException(StaffErrorCode.STAFF_NOT_FOUND); }); - // 공연에 속해 있는지 검증 if (!staff.getPerformance().equals(performance)) { throw new ForbiddenException(StaffErrorCode.STAFF_NOT_BELONG_TO_PERFORMANCE); }