show authors
This commit is contained in:
parent
c88ce3ac37
commit
dc5abe1508
@ -37,6 +37,11 @@ public class PaperController {
|
|||||||
modelMap.put("papers", paperService.findAllDto());
|
modelMap.put("papers", paperService.findAllDto());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/dashboard")
|
||||||
|
public void getDashboard(ModelMap modelMap) {
|
||||||
|
modelMap.put("papers", paperService.findAllDto());
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/paper")
|
@GetMapping("/paper")
|
||||||
public void getPapers(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
public void getPapers(ModelMap modelMap, @RequestParam(value = "id") Integer id) {
|
||||||
if (id != null && id > 0) {
|
if (id != null && id > 0) {
|
||||||
|
@ -4,12 +4,14 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import ru.ulstu.deadline.model.DeadlineDto;
|
import ru.ulstu.deadline.model.DeadlineDto;
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
@ -29,7 +31,8 @@ public class PaperDto {
|
|||||||
private Integer fileId;
|
private Integer fileId;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private Date fileCreateDate;
|
private Date fileCreateDate;
|
||||||
private Set<Integer> authors;
|
private Set<Integer> authorIds;
|
||||||
|
private Set<UserDto> authors;
|
||||||
|
|
||||||
public PaperDto() {
|
public PaperDto() {
|
||||||
deadlines.add(new DeadlineDto());
|
deadlines.add(new DeadlineDto());
|
||||||
@ -45,7 +48,8 @@ public class PaperDto {
|
|||||||
@JsonProperty("comment") String comment,
|
@JsonProperty("comment") String comment,
|
||||||
@JsonProperty("locked") Boolean locked,
|
@JsonProperty("locked") Boolean locked,
|
||||||
@JsonProperty("tmpFileName") String tmpFileName,
|
@JsonProperty("tmpFileName") String tmpFileName,
|
||||||
@JsonProperty("authors") Set<Integer> authors) {
|
@JsonProperty("authorIds") Set<Integer> authorIds,
|
||||||
|
@JsonProperty("authors") Set<UserDto> authors) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
@ -74,110 +78,126 @@ public class PaperDto {
|
|||||||
this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId();
|
this.fileId = paper.getFileData() == null ? null : paper.getFileData().getId();
|
||||||
this.fileName = paper.getFileData() == null ? null : paper.getFileData().getName();
|
this.fileName = paper.getFileData() == null ? null : paper.getFileData().getName();
|
||||||
this.fileCreateDate = paper.getFileData() == null ? null : paper.getFileData().getCreateDate();
|
this.fileCreateDate = paper.getFileData() == null ? null : paper.getFileData().getCreateDate();
|
||||||
this.authors = convert(paper.getAuthors(), user -> user.getId());
|
this.authorIds = convert(paper.getAuthors(), user -> user.getId());
|
||||||
|
this.authors = convert(paper.getAuthors(), UserDto::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Paper.PaperStatus getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreateDate() {
|
|
||||||
return createDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getUpdateDate() {
|
|
||||||
return updateDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DeadlineDto> getDeadlines() {
|
|
||||||
return deadlines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment() {
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getLocked() {
|
|
||||||
return locked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTmpFileName() {
|
|
||||||
return tmpFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getFileId() {
|
|
||||||
return fileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getFileCreateDate() {
|
|
||||||
return fileCreateDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Integer> getAuthors() {
|
|
||||||
return authors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Paper.PaperStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
public void setStatus(Paper.PaperStatus status) {
|
public void setStatus(Paper.PaperStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getCreateDate() {
|
||||||
|
return createDate;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCreateDate(Date createDate) {
|
public void setCreateDate(Date createDate) {
|
||||||
this.createDate = createDate;
|
this.createDate = createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getUpdateDate() {
|
||||||
|
return updateDate;
|
||||||
|
}
|
||||||
|
|
||||||
public void setUpdateDate(Date updateDate) {
|
public void setUpdateDate(Date updateDate) {
|
||||||
this.updateDate = updateDate;
|
this.updateDate = updateDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DeadlineDto> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<DeadlineDto> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
public void setComment(String comment) {
|
public void setComment(String comment) {
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getLocked() {
|
||||||
|
return locked;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLocked(Boolean locked) {
|
public void setLocked(Boolean locked) {
|
||||||
this.locked = locked;
|
this.locked = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTmpFileName() {
|
||||||
|
return tmpFileName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTmpFileName(String tmpFileName) {
|
public void setTmpFileName(String tmpFileName) {
|
||||||
this.tmpFileName = tmpFileName;
|
this.tmpFileName = tmpFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getFileId() {
|
||||||
|
return fileId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFileId(Integer fileId) {
|
public void setFileId(Integer fileId) {
|
||||||
this.fileId = fileId;
|
this.fileId = fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFileName(String fileName) {
|
public void setFileName(String fileName) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getFileCreateDate() {
|
||||||
|
return fileCreateDate;
|
||||||
|
}
|
||||||
|
|
||||||
public void setFileCreateDate(Date fileCreateDate) {
|
public void setFileCreateDate(Date fileCreateDate) {
|
||||||
this.fileCreateDate = fileCreateDate;
|
this.fileCreateDate = fileCreateDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthors(Set<Integer> authors) {
|
public Set<UserDto> getAuthors() {
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthors(Set<UserDto> authors) {
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeadlines(List<DeadlineDto> deadlines) {
|
public Set<Integer> getAuthorIds() {
|
||||||
this.deadlines = deadlines;
|
return authorIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthorIds(Set<Integer> authorIds) {
|
||||||
|
this.authorIds = authorIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthorsString() {
|
||||||
|
return authors
|
||||||
|
.stream()
|
||||||
|
.map(author -> author.getLastName())
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ public class PaperService {
|
|||||||
if (paperDto.getTmpFileName() != null) {
|
if (paperDto.getTmpFileName() != null) {
|
||||||
paper.setFileData(fileService.createFileFromTmp(paperDto.getTmpFileName()));
|
paper.setFileData(fileService.createFileFromTmp(paperDto.getTmpFileName()));
|
||||||
}
|
}
|
||||||
if (paperDto.getAuthors() != null && !paperDto.getAuthors().isEmpty()) {
|
if (paperDto.getAuthorIds() != null && !paperDto.getAuthorIds().isEmpty()) {
|
||||||
paperDto.getAuthors().forEach(authorIds -> paper.getAuthors().add(userService.findById(authorIds)));
|
paperDto.getAuthorIds().forEach(authorIds -> paper.getAuthors().add(userService.findById(authorIds)));
|
||||||
} else {
|
} else {
|
||||||
paper.getAuthors().clear();
|
paper.getAuthors().clear();
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
<div class="col-lg-12 text-center">
|
<div class="col-lg-12 text-center">
|
||||||
<h2 class="section-heading text-uppercase">Статьи</h2>
|
<h2 class="section-heading text-uppercase">Статьи</h2>
|
||||||
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
<div th:replace="papers/fragments/paperNavigationFragment"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-content-center" id="dashboard">
|
<div class="row justify-content-center" id="dashboard">
|
||||||
|
<th:block th:each="paper : ${papers}">
|
||||||
|
<div th:replace="papers/fragments/paperDashboardFragment :: titleLine(paper=${paper})"/>
|
||||||
|
</th:block>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head th:fragment="headerfiles">
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div th:fragment="titleLine (paper)" class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3 dashboard-card">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2">
|
||||||
|
<span class="fa-stack fa-1x">
|
||||||
|
<th:block th:switch="${paper.status.name()}">
|
||||||
|
<div th:case="'ATTENTION'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-warning"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'DRAFT'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-draft"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'ON_PREPARATION'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'ON_REVIEW'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'COMPLETED'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-success"></i>
|
||||||
|
</div>
|
||||||
|
<div th:case="'FAILED'">
|
||||||
|
<i class="fa fa-circle fa-stack-2x text-failed"></i>
|
||||||
|
</div>
|
||||||
|
</th:block>
|
||||||
|
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="col col-10 text-right">
|
||||||
|
<h7 class="service-heading" th:text="${paper.title}"> title</h7>
|
||||||
|
<p class="text-muted" th:text="${paper.authorsString}">authors</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -29,7 +29,10 @@
|
|||||||
</th:block>
|
</th:block>
|
||||||
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||||
</span>
|
</span>
|
||||||
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
<a th:href="@{'paper?id='+${paper.id}}">
|
||||||
|
<span class="h6" th:text="${paper.title}"/>
|
||||||
|
<span class="text-muted" th:text="${paper.authorsString}"/>
|
||||||
|
</a>
|
||||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||||
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}"
|
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}"
|
||||||
data-confirm="Удалить статью?">
|
data-confirm="Удалить статью?">
|
||||||
|
@ -101,12 +101,12 @@
|
|||||||
<label>Редактировать авторов статьи:</label>
|
<label>Редактировать авторов статьи:</label>
|
||||||
<select class="selectpicker form-control" multiple="true" data-live-search="true"
|
<select class="selectpicker form-control" multiple="true" data-live-search="true"
|
||||||
title="-- Выберите авторов --"
|
title="-- Выберите авторов --"
|
||||||
th:field="*{authors}">
|
th:field="*{authorIds}">
|
||||||
<option th:each="author: ${allAuthors}" th:value="${author.id}"
|
<option th:each="author: ${allAuthors}" th:value="${author.id}"
|
||||||
th:text="${author.firstName}">Status
|
th:text="${author.lastName}">Status
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<p th:if="${#fields.hasErrors('authors')}" th:errors="*{authors}"
|
<p th:if="${#fields.hasErrors('authorIds')}" th:errors="*{authorIds}"
|
||||||
class="alert alert-danger">Incorrect title</p>
|
class="alert alert-danger">Incorrect title</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user