Skip to content

Commit

Permalink
fix: 배치 좌석 업데이트 쿼리 bulk 업데이트로 수정 (#254)
Browse files Browse the repository at this point in the history
* chore: 오타 수정

* fix: batch bulk 업데이트로 수정
  • Loading branch information
annahxxl authored Jan 23, 2024
1 parent cbbb87a commit d8dd4c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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);
}

0 comments on commit d8dd4c0

Please sign in to comment.