#64 added method addPaper

merge-requests/70/head
Nightblade73 5 years ago
parent b6ced3ce1a
commit 5bfeaff054

@ -95,6 +95,16 @@ public class ConferenceController {
return CONFERENCE_PAGE;
}
@PostMapping(value = "/conference", params = "addPaper")
public String addPaper(@Valid ConferenceDto conferenceDto, Errors errors) {
if (errors.hasErrors()) {
return CONFERENCE_PAGE;
}
conferenceService.addPaper(conferenceDto);
return CONFERENCE_PAGE;
}
@PostMapping(value = "/conference", params = "removeDeadline")
public String removeDeadline(@Valid ConferenceDto conferenceDto, Errors errors,
@RequestParam(value = "removeDeadline") Integer deadlineIndex) throws IOException {

@ -149,7 +149,7 @@ public class ConferenceService {
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
conferenceDto.getPaperIds().forEach(paperId ->
conference.getPapers().add(paperService.findEntityById(paperId)));
conference.getPapers().add(paperService.findPaperById(paperId)));
}
return conference;
}
@ -173,4 +173,10 @@ public class ConferenceService {
public List<Conference> findAllActive() {
return conferenceRepository.findAllActive(new Date());
}
public void addPaper(ConferenceDto conferenceDto) {
Paper paper = new Paper();
paper.setTitle(userService.getCurrentUser().getLastName() + "_" + conferenceDto.getTitle());
conferenceDto.getPapers().add(paper);
}
}

@ -223,7 +223,7 @@ public class PaperService {
return new PaperDto(paperRepository.findOne(paperId));
}
public Paper findEntityById(Integer paperId) {
public Paper findPaperById(Integer paperId) {
return paperRepository.findOne(paperId);
}

@ -135,7 +135,15 @@
<div class="paper d-flex list-group-item p-0"
th:each="paper, rowStat : *{papers}">
<a class="paper-name"
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}"
th:if="*{papers[__${rowStat.index}__].id !=null}">
<span th:text="*{papers[__${rowStat.index}__].title}">
Имя статьи
</span>
<img class="icon-paper" src="/img/conference/paper.png"/>
</a>
<a class="paper-name"
th:unless="*{papers[__${rowStat.index}__].id !=null}">
<span th:text="*{papers[__${rowStat.index}__].title}">
Имя статьи
</span>
@ -156,7 +164,7 @@
</option>
</select>
<button id="add-paper" class="btn btn-primary"
type="button">
type="submit" name="addPaper">
Добавить статью
</button>
</div>

Loading…
Cancel
Save