Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: 배치 좌석 업데이트 쿼리 bulk 업데이트로 수정 #254

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SeatReleaseTasklet implements Tasklet{
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
List<Ticket> tickets = ticketRepository.findAll(LocalDateTime.now(), BookingStatus.WAITING_FOR_PAYMENT);
tickets.forEach(ticket -> ticket.getSeat().updateStatus(EventSeatStatus.AVAILABLE));
ticketRepository.updateSeatStatusBulk(EventSeatStatus.AVAILABLE, tickets.stream().map(Ticket::getId).toList());
return RepeatStatus.FINISHED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class BookingCancel extends BaseEntity {
private Booking booking;

@Enumerated(EnumType.STRING)
@Column(name = "refund_ bank_code")
@Column(name = "refund_bank_code")
private BankCode refundBankCode;

@Column(name = "refund_ account_number")
@Column(name = "refund_account_number")
private String refundAccountNumber;

@Column(name = "refund_ holder_name")
@Column(name = "refund_holder_name")
private String refundHolderName;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.pgms.coredomain.domain.booking.BookingStatus;
import com.pgms.coredomain.domain.booking.Ticket;
import com.pgms.coredomain.domain.event.EventSeatStatus;

public interface TicketRepository extends JpaRepository<Ticket, Long> {

Expand All @@ -23,4 +25,8 @@ public interface TicketRepository extends JpaRepository<Ticket, Long> {
+ "AND b.status = :bookingStatus ")
List<Ticket> findAll(@Param("datetime") LocalDateTime dateTime,
@Param("bookingStatus") BookingStatus bookingStatus);

@Modifying
@Query("UPDATE Ticket t SET t.seat.status = :status WHERE t IN :ticketIds")
void updateSeatStatusBulk(@Param("status") EventSeatStatus status, @Param("ticketIds") List<Long> ticketIds);
}