-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 이탈된 예매에 대한 좌석 상태 변경 배치 * chore --------- Co-authored-by: byulcode <[email protected]>
- Loading branch information
Showing
17 changed files
with
264 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
### 세션 아이디 발급 | ||
POST http://localhost:8082/api/v1/bookings/issue-session-id | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
|
||
### 대기열 진입 | ||
POST http://localhost:8082/api/v1/bookings/enter-queue | ||
Content-Type: application/json | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
Booking-Session-Id: {세션아이디} | ||
|
||
{ | ||
"eventId": 1 | ||
} | ||
|
||
### 대기열 조회 | ||
GET http://localhost:8082/api/v1/bookings/order-in-queue?eventId=1 | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
Booking-Session-Id: {세션아이디} | ||
|
||
|
||
### 예매 토큰 발급 | ||
POST http://localhost:8082/api/v1/bookings/issue-token | ||
Content-Type: application/json | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
Booking-Session-Id: {세션아이디} | ||
|
||
{ | ||
"eventId": 1 | ||
} | ||
|
||
### 좌석 목록 조회 | ||
GET http://localhost:8082/api/v1/seats?eventTimeId=1 | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
Booking-Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NjkzNDQ4LCJleHAiOjE3MDQ2OTUyNDgsInNlc3Npb25JZCI6Ins_Pz8_P30ifQ.IFqm66RBlLw6ZVbogZdTvClpH2arxAfWTZ1-DNFtT-H7EH0OSYUoICgnpMjbI2aSObsdl1h3oVSQPw28XlmJzg | ||
|
||
### 예매 | ||
POST http://localhost:8082/api/v1/bookings | ||
Content-Type: application/json | ||
#Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJpYXQiOjE3MDQ2OTE0OTEsImV4cCI6MTgwNDY4MzI5MSwiYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn0.wFNSz2uwRa35jP1KihNlTOewVLgMMeg3ADQ5Kztl3QQ | ||
Booking-Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJib29raW5nIiwiaWF0IjoxNzA0NjkzNDQ4LCJleHAiOjE3MDQ2OTUyNDgsInNlc3Npb25JZCI6Ins_Pz8_P30ifQ.IFqm66RBlLw6ZVbogZdTvClpH2arxAfWTZ1-DNFtT-H7EH0OSYUoICgnpMjbI2aSObsdl1h3oVSQPw28XlmJzg | ||
|
||
{ | ||
"timeId": 1, | ||
"seatIds": [3, 4], | ||
"receiptType": "배송", | ||
"buyerName": "이한나", | ||
"buyerPhoneNumber": "010-1234-5678", | ||
"deliveryAddress": { | ||
"recipientName": "이한나", | ||
"recipientPhoneNumber": "010-1234-5678", | ||
"streetAddress": "서울시 강남구 테헤란로", | ||
"detailAddress": "000동 000호", | ||
"zipCode": "00000" | ||
}, | ||
"method": "카드" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 실행가능한 jar로 생성하는 옵션, main이 없는 라이브러리에서는 false로 비활성화함 | ||
// 스프링 부트 2.0 이상이라면 bootRepackage.enabled를 사용해야 함 | ||
bootJar { enabled = true } | ||
|
||
// 외부에서 의존하기 위한 jar로 생성하는 옵션, main이 없는 라이브러리에서는 true로 비활성화함 | ||
jar { enabled = false } | ||
|
||
dependencies { | ||
implementation project(':core:core-domain'); | ||
implementation project(':core:core-infra'); | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-batch' | ||
} | ||
|
||
tasks.register("prepareKotlinBuildScriptModel") {} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
15 changes: 15 additions & 0 deletions
15
batch/batch-booking/src/main/java/com/pgms/batchbooking/BatchBookingApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.pgms.batchbooking; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
@SpringBootApplication | ||
@ComponentScan("com.pgms") | ||
public class BatchBookingApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(BatchBookingApplication.class, args); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
batch/batch-booking/src/main/java/com/pgms/batchbooking/seat/SeatReleaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.pgms.batchbooking.seat; | ||
|
||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.job.builder.JobBuilder; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.step.builder.StepBuilder; | ||
import org.springframework.batch.core.step.tasklet.Tasklet; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import com.pgms.coredomain.domain.booking.repository.TicketRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class SeatReleaseConfig { | ||
|
||
private final JobRepository jobRepository; | ||
private final PlatformTransactionManager transactionManager; | ||
private final TicketRepository ticketRepository; | ||
|
||
@Bean | ||
public Job seatReleaseJob() { | ||
return new JobBuilder("seatReleaseJob", jobRepository) | ||
.start(seatReleaseStep()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Step seatReleaseStep(){ | ||
return new StepBuilder("seatReleaseStep", jobRepository) | ||
.tasklet(seatReleaseTasklet(), transactionManager) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Tasklet seatReleaseTasklet(){ | ||
return new SeatReleaseTasklet(ticketRepository); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
batch/batch-booking/src/main/java/com/pgms/batchbooking/seat/SeatReleaseScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.pgms.batchbooking.seat; | ||
|
||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.JobExecutionException; | ||
import org.springframework.batch.core.JobParameters; | ||
import org.springframework.batch.core.JobParametersBuilder; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/* | ||
* 테스트를 위한 스케줄러 | ||
*/ | ||
@Component | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class SeatReleaseScheduler { | ||
|
||
private final JobLauncher jobLauncher; | ||
private final Job lockAdminJob; | ||
|
||
@Scheduled(cron = "0 0 0 * * ?") | ||
public void runJob() { | ||
try { | ||
JobParameters jobParameters = new JobParametersBuilder() | ||
.addLong("executedTime", System.currentTimeMillis()) | ||
.toJobParameters(); | ||
|
||
jobLauncher.run(lockAdminJob, jobParameters); | ||
} catch (JobExecutionException e) { | ||
log.error("SeatReleaseScheduler error : ", e); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
batch/batch-booking/src/main/java/com/pgms/batchbooking/seat/SeatReleaseTasklet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.pgms.batchbooking.seat; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import org.springframework.batch.core.StepContribution; | ||
import org.springframework.batch.core.scope.context.ChunkContext; | ||
import org.springframework.batch.core.step.tasklet.Tasklet; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.pgms.coredomain.domain.booking.BookingStatus; | ||
import com.pgms.coredomain.domain.booking.Ticket; | ||
import com.pgms.coredomain.domain.booking.repository.TicketRepository; | ||
import com.pgms.coredomain.domain.event.EventSeatStatus; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class SeatReleaseTasklet implements Tasklet{ | ||
|
||
private final TicketRepository ticketRepository; | ||
|
||
@Transactional | ||
@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)); | ||
return RepeatStatus.FINISHED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
server: | ||
port: 8086 | ||
|
||
spring: | ||
profiles: | ||
include: infra | ||
active: dev | ||
batch: | ||
jdbc: | ||
initialize-schema: always |
13 changes: 13 additions & 0 deletions
13
batch/batch-booking/src/test/java/com/pgms/batchbooking/BatchBookingApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.pgms.batchbooking; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class BatchBookingApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
Oops, something went wrong.