#55 added findAll method in ConferenceService
This commit is contained in:
parent
d189891e8c
commit
2d04b1b43a
@ -2,7 +2,10 @@ package ru.ulstu.conference.controller;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import ru.ulstu.conference.model.ConferenceFilterDto;
|
||||
import ru.ulstu.conference.service.ConferenceService;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
@ -16,9 +19,9 @@ public class ConferenceController {
|
||||
public ConferenceController(ConferenceService paperService) {
|
||||
this.conferenceService = paperService;
|
||||
}
|
||||
//
|
||||
// @GetMapping("/papers")
|
||||
// public void getPapers(ModelMap modelMap) {
|
||||
// modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null));
|
||||
// }
|
||||
|
||||
@GetMapping("/papers")
|
||||
public void getPapers(ModelMap modelMap) {
|
||||
modelMap.put("filteredPapers", new ConferenceFilterDto(conferenceService.findAllDto(), null, null));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,20 @@
|
||||
package ru.ulstu.conference.service;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.conference.model.ConferenceDto;
|
||||
import ru.ulstu.conference.repository.ConferenceRepository;
|
||||
import ru.ulstu.deadline.service.DeadlineService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
@Service
|
||||
public class ConferenceService {
|
||||
private final static int MAX_DISPLAY_SIZE = 40;
|
||||
|
||||
private final ConferenceRepository conferenceRepository;
|
||||
private final DeadlineService deadlineService;
|
||||
|
||||
@ -14,4 +23,28 @@ public class ConferenceService {
|
||||
this.conferenceRepository = conferenceRepository;
|
||||
this.deadlineService = deadlineService;
|
||||
}
|
||||
|
||||
public List<Conference> findAll() {
|
||||
return conferenceRepository.findAll();
|
||||
}
|
||||
|
||||
public List<ConferenceDto> findAllDto() {
|
||||
List<ConferenceDto> conferences = convert(findAll(), ConferenceDto::new);
|
||||
conferences.forEach(conferenceDto -> conferenceDto.setTitle(StringUtils.abbreviate(conferenceDto.getTitle(), MAX_DISPLAY_SIZE)));
|
||||
return conferences;
|
||||
}
|
||||
|
||||
// private List<Paper> sortPapers(List<Conference> conferences) {
|
||||
// return conferences.stream().sorted((paper1, paper2) -> {
|
||||
// int statusCompareResult =
|
||||
// Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus()))
|
||||
// .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus()));
|
||||
// if (statusCompareResult != 0) {
|
||||
// return statusCompareResult;
|
||||
// }
|
||||
// return paper1.getTitle().compareTo(paper2.getTitle());
|
||||
// }).collect(toList());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user