-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat : 웨이팅 스케줄러 구현
- Loading branch information
Showing
20 changed files
with
325 additions
and
155 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
[[waiting-create]] | ||
=== 웨이팅 등록 | ||
|
||
==== HTTP Request | ||
|
||
include::{snippets}/member-waiting-controller-docs-test/create-waiting/http-request.adoc[] | ||
include::{snippets}/member-waiting-controller-docs-test/create-waiting/request-fields.adoc[] | ||
|
||
==== HTTP Response | ||
|
||
include::{snippets}/member-waiting-controller-docs-test/create-waiting/http-response.adoc[] | ||
include::{snippets}/member-waiting-controller-docs-test/create-waiting/response-fields.adoc[] |
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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/prgrms/catchtable/waiting/schedular/WaitingScheduler.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,37 @@ | ||
package com.prgrms.catchtable.waiting.schedular; | ||
|
||
import static com.prgrms.catchtable.waiting.domain.WaitingStatus.CANCELED; | ||
import static com.prgrms.catchtable.waiting.domain.WaitingStatus.PROGRESS; | ||
|
||
import com.prgrms.catchtable.waiting.repository.WaitingRepository; | ||
import java.util.Set; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.redis.core.StringRedisTemplate; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
public class WaitingScheduler { | ||
|
||
private final StringRedisTemplate redisTemplate; | ||
|
||
private final WaitingRepository waitingRepository; | ||
|
||
//매일 자정 레디스 데이터 비우기 | ||
@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") | ||
public void clearRedis() { | ||
Set<String> keys = redisTemplate.keys("s*"); | ||
redisTemplate.delete(keys); | ||
} | ||
|
||
//매일 자정 대기 상태 바꾸기 | ||
@Scheduled(cron = "0 0 0 * * *", zone = "Asia/Seoul") | ||
public void changeProgressStatus() { | ||
waitingRepository.updateWaitingStatus(CANCELED, PROGRESS); | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/test/java/com/prgrms/catchtable/common/restdocs/RestDocsConfig.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,20 @@ | ||
package com.prgrms.catchtable.common.restdocs; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation; | ||
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; | ||
import org.springframework.restdocs.operation.preprocess.Preprocessors; | ||
|
||
@TestConfiguration | ||
public class RestDocsConfig { | ||
|
||
@Bean | ||
public RestDocumentationResultHandler write() { | ||
return MockMvcRestDocumentation.document( | ||
"{class-name}/{method-name}", | ||
Preprocessors.preprocessRequest(Preprocessors.prettyPrint()), | ||
Preprocessors.preprocessResponse(Preprocessors.prettyPrint()) | ||
); | ||
} | ||
} |
Oops, something went wrong.