complete task INDX-0001. sites list output to stdout
This commit is contained in:
parent
443ea20d55
commit
1209b34ceb
@ -4,8 +4,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import searchengine.config.SitesList;
|
||||
import searchengine.dto.statistics.StatisticsResponse;
|
||||
import searchengine.services.IndexingService;
|
||||
import searchengine.services.StatisticsService;
|
||||
|
||||
@RestController
|
||||
@ -13,9 +13,11 @@ import searchengine.services.StatisticsService;
|
||||
public class ApiController {
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
private final IndexingService indexingService;
|
||||
|
||||
public ApiController(StatisticsService statisticsService) {
|
||||
public ApiController(StatisticsService statisticsService, IndexingService indexingService) {
|
||||
this.statisticsService = statisticsService;
|
||||
this.indexingService = indexingService;
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@ -25,7 +27,7 @@ public class ApiController {
|
||||
|
||||
@GetMapping("/startIndexing")
|
||||
public ResponseEntity<StatisticsResponse> startIndexing() {
|
||||
System.out.println(new SitesList().getSites());
|
||||
indexingService.startIndexing();
|
||||
return ResponseEntity.ok(statisticsService.getStatistics());
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
package searchengine.services;
|
||||
|
||||
public interface IndexingService {
|
||||
void startIndexing();
|
||||
}
|
||||
|
@ -1,14 +1,25 @@
|
||||
package searchengine.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import searchengine.config.SitesList;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class IndexingServiceImpl implements IndexingService {
|
||||
boolean indexingIsRunning = false;
|
||||
private final SitesList sitesList;
|
||||
|
||||
@Override
|
||||
public void startIndexing() {
|
||||
if (indexingIsRunning) {
|
||||
System.out.println("Индексация уже запущена");
|
||||
return;
|
||||
}
|
||||
// Логика для запуска индексации или перенидексации сайтов
|
||||
|
||||
System.out.println("Список сайтов для индексации:");
|
||||
sitesList.getSites().forEach(site -> System.out.println("URL: " + site.getUrl() + ", Название: " + site.getName()));
|
||||
|
||||
System.out.println("Запуск индексации");
|
||||
indexingIsRunning = true;
|
||||
System.out.println("Индексация запущена");
|
||||
|
Loading…
x
Reference in New Issue
Block a user