/
linto
/
opensearch-example
Обзор
Документация
Войти
/
linto
/
opensearch-example
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/com/example/demo/controller/IndexController.java
44 строки
1 KB
linto
init
30 июл 2025, 11:44
30 июл 2025, 11:44
dc5aaf3
Код
Авторство
О чём код?
package com.example.demo.controller; import java.time.ZoneId; import java.util.List; import java.util.stream.Collectors; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import com.example.demo.opensearch.model.Root; import com.example.demo.service.IndexUpdateService; import com.example.demo.service.SubjectService; import lombok.RequiredArgsConstructor; @RestController @RequestMapping("/index") @RequiredArgsConstructor public class IndexController { private final SubjectService subjectService; private final IndexUpdateService indexUpdateService; @GetMapping() @ResponseStatus(code = HttpStatus.OK) public void indexAll() { List<Root> entities = subjectService.findAll().stream().map(c -> Root.builder() .id(c.getId()) .inn(c.getInn()) .kpp(c.getKpp()) .name(c.getName()) .ogrn(c.getOgrn()) .createdat(c.getCreatedat().atZone(ZoneId.systemDefault()).toInstant()) .updatedat(c.getUpdatedat().atZone(ZoneId.systemDefault()).toInstant()) .build()) .collect(Collectors.toList()); indexUpdateService.update(entities); } }