-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Oh-Lottery/crawler
크롤러 업데이트 및 Swagger 적용
- Loading branch information
Showing
8 changed files
with
177 additions
and
173 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
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,23 @@ | ||
package com.ohlottery.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
@Configuration | ||
@EnableAsync | ||
public class AsyncConfig { | ||
@Bean | ||
public Executor taskExecutor() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(10); | ||
executor.setMaxPoolSize(100); | ||
executor.setQueueCapacity(50); | ||
executor.setThreadNamePrefix("AsyncExecutor-"); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
} |
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
32 changes: 24 additions & 8 deletions
32
src/main/java/com/ohlottery/controller/LotteryCrawlerController.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 |
---|---|---|
@@ -1,31 +1,47 @@ | ||
package com.ohlottery.controller; | ||
|
||
import com.ohlottery.service.DHLotteryCrawlerService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
//Authentication 과정 필수로 필요 | ||
|
||
@RestController | ||
@RequestMapping("/crawler") | ||
@RequiredArgsConstructor | ||
@Tag(name = "Lottery Crawler Controller", description = "당첨 정보 수동 크롤링") | ||
public class LotteryCrawlerController { | ||
|
||
private final DHLotteryCrawlerService lotteryCrawlerService; | ||
|
||
@PatchMapping("/lottery645/{round}") | ||
public ResponseEntity<Void> fetchLottery645(@PathVariable long round) { | ||
@Operation(summary = "6/45로또 데이터 업데이트", description = "해당 회차 6/45 당첨 정보를 데이터베이스에 저장") | ||
@GetMapping("/lottery645/{round}") | ||
public ResponseEntity<Void> fetchLottery645( | ||
@Parameter(description = "회차", example = "1") | ||
@PathVariable long round | ||
) { | ||
lotteryCrawlerService.fetchLottery645Data(round); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PatchMapping("/lottery720/{round}") | ||
public ResponseEntity<Void> fetchLottery720(@PathVariable long round) { | ||
@Operation(summary = "연금복권 데이터 업데이트", description = "해당 회차 6/45 당첨 정보를 데이터베이스에 저장") | ||
@GetMapping("/lottery720/{round}") | ||
public ResponseEntity<Void> fetchLottery720( | ||
@Parameter(description = "회차", example = "1") | ||
@PathVariable long round | ||
) { | ||
lotteryCrawlerService.fetchLottery720Data(round); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@Operation(summary = "모든 로또 데이터 업데이트", description = "1~n 회차까지 전부 데이터베이스에 저장") | ||
@GetMapping("/lottery/fetch") | ||
public ResponseEntity<Void> fetchAllData() { | ||
lotteryCrawlerService.fetchAllLotteryData(); | ||
return ResponseEntity.ok().build(); | ||
} | ||
} |
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
Oops, something went wrong.