#69 changed method getConference in controller

This commit is contained in:
Nightblade73 2019-04-19 14:39:07 +04:00
parent 9edcebb2f5
commit b623402aa8
2 changed files with 17 additions and 18 deletions

View File

@ -15,12 +15,10 @@ import ru.ulstu.conference.model.ConferenceFilterDto;
import ru.ulstu.conference.model.ConferenceUser;
import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -49,14 +47,9 @@ public class ConferenceController {
@GetMapping("/conference")
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) {
ConferenceDto conferenceDto = conferenceService.findOneDto(id);
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
modelMap.put("conferenceDto", conferenceDto);
modelMap.put("conferenceDto", conferenceService.getExistConferenceById(id));
} else {
ConferenceDto conferenceDto = new ConferenceDto();
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
modelMap.put("conferenceDto", conferenceDto);
modelMap.put("conferenceDto", conferenceService.getNewConference());
}
}
@ -116,14 +109,6 @@ public class ConferenceController {
return CONFERENCE_PAGE;
}
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
return conferenceService.getConferencePapers(paperIds);
}
public boolean isCurrentUserParticipant(List<ConferenceUser> conferenceUsers) {
return conferenceService.isCurrentUserParticipant(conferenceUsers);
}
@ModelAttribute("allParticipation")
public List<ConferenceUser.Participation> getAllParticipation() {
return conferenceService.getAllParticipations();

View File

@ -13,6 +13,7 @@ import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.service.UserService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -41,6 +42,19 @@ public class ConferenceService {
this.userService = userService;
}
public ConferenceDto getExistConferenceById(Integer id) {
ConferenceDto conferenceDto = findOneDto(id);
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
return conferenceDto;
}
public ConferenceDto getNewConference() {
ConferenceDto conferenceDto = new ConferenceDto();
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
return conferenceDto;
}
public List<Conference> findAll() {
return conferenceRepository.findAll();
@ -103,7 +117,7 @@ public class ConferenceService {
conferenceDto.setDisabledTakePart(true);
}
public List<Paper> getConferencePapers(List<Integer> paperIds) {
public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
return paperService.findAllNotSelect(paperIds);
}