Resolve "Принять участие в конференции пользователю" #183

Merged
VladimirZarayskiy merged 1 commits from 69-take-part-conf into dev 2019-04-19 17:05:08 +04:00
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.model.ConferenceUser;
import ru.ulstu.conference.service.ConferenceService; import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.paper.model.Paper;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -49,14 +47,9 @@ public class ConferenceController {
@GetMapping("/conference") @GetMapping("/conference")
public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) { public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
if (id != null && id > 0) { if (id != null && id > 0) {
ConferenceDto conferenceDto = conferenceService.findOneDto(id); modelMap.put("conferenceDto", conferenceService.getExistConferenceById(id));
conferenceDto.setNotSelectedPapers(getNotSelectPapers(conferenceDto.getPaperIds()));
conferenceDto.setDisabledTakePart(isCurrentUserParticipant(conferenceDto.getUsers()));
modelMap.put("conferenceDto", conferenceDto);
} else { } else {
ConferenceDto conferenceDto = new ConferenceDto(); modelMap.put("conferenceDto", conferenceService.getNewConference());
conferenceDto.setNotSelectedPapers(getNotSelectPapers(new ArrayList<Integer>()));
modelMap.put("conferenceDto", conferenceDto);
} }
} }
@ -116,14 +109,6 @@ public class ConferenceController {
return CONFERENCE_PAGE; 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") @ModelAttribute("allParticipation")
public List<ConferenceUser.Participation> getAllParticipation() { public List<ConferenceUser.Participation> getAllParticipation() {
return conferenceService.getAllParticipations(); return conferenceService.getAllParticipations();

View File

@ -13,6 +13,7 @@ import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserService;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -41,6 +42,19 @@ public class ConferenceService {
this.userService = userService; 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() { public List<Conference> findAll() {
return conferenceRepository.findAll(); return conferenceRepository.findAll();
@ -103,7 +117,7 @@ public class ConferenceService {
conferenceDto.setDisabledTakePart(true); conferenceDto.setDisabledTakePart(true);
} }
public List<Paper> getConferencePapers(List<Integer> paperIds) { public List<Paper> getNotSelectPapers(List<Integer> paperIds) {
return paperService.findAllNotSelect(paperIds); return paperService.findAllNotSelect(paperIds);
} }