load paper
This commit is contained in:
parent
5fa5d670a5
commit
f376fedc64
@ -4,11 +4,13 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.paper.model.PaperFilterDto;
|
||||
@ -34,9 +36,18 @@ public class PaperController {
|
||||
modelMap.put("papers", paperService.findAllDto());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Response<Integer> createPaper(@RequestBody @Valid PaperDto paperDto) throws IOException {
|
||||
return new Response<>(paperService.create(paperDto));
|
||||
@GetMapping("/paper")
|
||||
public void getPapers(ModelMap modelMap, @RequestParam(value="id") Integer id) {
|
||||
if (id != null && id > 0) {
|
||||
modelMap.put("paper", paperService.findOneDto(id));
|
||||
} else {
|
||||
modelMap.put("paper", new PaperDto());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/paper")
|
||||
public void createPaper(@ModelAttribute PaperDto paperDto) throws IOException {
|
||||
paperService.create(paperDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
|
@ -14,6 +14,8 @@ import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@ -48,13 +50,16 @@ public class Paper extends BaseEntity implements UserContainer {
|
||||
private PaperStatus status = PaperStatus.DRAFT;
|
||||
|
||||
@Column(name = "create_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createDate = new Date();
|
||||
|
||||
@Column(name = "update_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updateDate = new Date();
|
||||
|
||||
@Column(name = "deadline_date")
|
||||
@NotNull
|
||||
@Temporal(TemporalType.DATE)
|
||||
private Date deadlineDate;
|
||||
|
||||
private String comment;
|
||||
|
@ -13,21 +13,24 @@ import java.util.stream.Collectors;
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class PaperDto {
|
||||
private final Integer id;
|
||||
private Integer id;
|
||||
@NotEmpty
|
||||
private final String title;
|
||||
private final Paper.PaperStatus status;
|
||||
private final Date createDate;
|
||||
private final Date updateDate;
|
||||
private String title;
|
||||
private Paper.PaperStatus status;
|
||||
private Date createDate;
|
||||
private Date updateDate;
|
||||
@NotNull
|
||||
private final Date deadlineDate;
|
||||
private final String comment;
|
||||
private final Boolean locked;
|
||||
private final String tmpFileName;
|
||||
private final Integer fileId;
|
||||
private final String fileName;
|
||||
private final Date fileCreateDate;
|
||||
private final Set<UserDto> authors;
|
||||
private Date deadlineDate;
|
||||
private String comment;
|
||||
private Boolean locked;
|
||||
private String tmpFileName;
|
||||
private Integer fileId;
|
||||
private String fileName;
|
||||
private Date fileCreateDate;
|
||||
private Set<UserDto> authors;
|
||||
|
||||
public PaperDto() {
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public PaperDto(@JsonProperty("id") Integer id,
|
||||
|
@ -56,6 +56,10 @@ public class PaperService {
|
||||
return convert(findAll(), PaperDto::new);
|
||||
}
|
||||
|
||||
public PaperDto findOneDto(Integer id) {
|
||||
return new PaperDto(paperRepository.findOne(id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer create(PaperDto paperDto) throws IOException {
|
||||
Paper newPaper = copyFromDto(new Paper(), paperDto);
|
||||
|
@ -23,4 +23,10 @@
|
||||
constraintName="fk_event_child_event" referencedTableName="event"
|
||||
referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
<changeSet author="orion" id="20181126_000000-4">
|
||||
<modifyDataType
|
||||
columnName="deadline_date"
|
||||
newDataType="date"
|
||||
tableName="paper"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
@ -32,7 +32,8 @@ function showPapers(papersElement, paperRowClass) {
|
||||
});
|
||||
}
|
||||
|
||||
function deletePaper(id, papersElement, paperRowClass) {
|
||||
function deletePaper(idElement, papersElement, paperRowClass) {
|
||||
var id = $(idElement).parent().find('.id-class').val();
|
||||
$("#remove-paper-modal").modal('show');
|
||||
|
||||
$("#modal-btn-yes").on("click", function () {
|
||||
|
@ -88,8 +88,6 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Custom scripts for this template -->
|
||||
<script src="/js/agency.js"></script>
|
||||
<script src="/js/core.js"></script>
|
||||
<!-- Yandex.Metrika counter -->
|
||||
<script type="text/javascript" >
|
||||
|
@ -19,7 +19,7 @@
|
||||
Список</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./dashboard" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||
<a href="./dashboard?id=0" class="btn btn-light toolbar-button"><i class="fa fa-newspaper-o"
|
||||
aria-hidden="true"></i> Панель управления</a>
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
|
@ -30,7 +30,9 @@
|
||||
<i class="fa fa-file-text-o fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
<a th:href="@{'paper?id='+${paper.id}}"><span th:text="${paper.title}"></span></a>
|
||||
<span class="remove-paper pull-right d-none" onclick="deletePaper('${id}','#paper-list', '.paper-row')">
|
||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||
<span class="remove-paper pull-right d-none"
|
||||
onclick="deletePaper($(this), '#paper-list', '.paper-row');">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorator="default">
|
||||
layout:decorator="default" xmlns:form="http://www.w3.org/1999/xhtml" xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
|
||||
</head>
|
||||
@ -23,15 +23,25 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form id="contactForm" name="sentMessage" novalidate="">
|
||||
<form method="post" action="#" th:action="@{/papers/paper}" th:object="${paper}">
|
||||
<input type="hidden" name="id" th:field="*{id}"
|
||||
th:value="${id}"
|
||||
/>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label for="name">Название:</label>
|
||||
<input class="form-control" id="name" type="text" placeholder="Название статьи"
|
||||
required="" data-validation-required-message="Введите название статьи"/>
|
||||
<label for="title">Название:</label>
|
||||
|
||||
<input class="form-control" id="title" name="title" type="text"
|
||||
placeholder="Название статьи"
|
||||
required=""
|
||||
data-validation-required-message="Введите название статьи"
|
||||
th:value="${title}"
|
||||
th:field="*{title}"
|
||||
/>
|
||||
<p class="help-block text-danger"></p>
|
||||
</div>
|
||||
|
||||
@ -44,16 +54,23 @@
|
||||
|
||||
<div class="form-group">
|
||||
<label for="comment">Комментарий:</label>
|
||||
<textarea class="form-control" rows="5" id="comment"></textarea>
|
||||
<textarea class="form-control" rows="5" id="comment"
|
||||
th:value="${comment}"
|
||||
th:field="*{comment}"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Дедлайн:</label>
|
||||
<input type="date" class="form-control" name="deadline"/>
|
||||
<input type="date" class="form-control" name="deadline"
|
||||
th:value="${deadlineDate}"
|
||||
th:field="*{deadlineDate}"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="locked"/>
|
||||
<input type="checkbox" class="form-check-input" id="locked"
|
||||
th:value="${locked}"
|
||||
th:field="*{locked}"/>
|
||||
<label class="form-check-label" for="locked">Заблокирована</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -70,7 +87,8 @@
|
||||
<label>Последнее изменение:</label>
|
||||
<input type="date" class="form-control" name="date-update"/>
|
||||
</div>
|
||||
<p><a href="#myModal1" class="btn btn-primary" data-toggle="modal">Редактировать авторов
|
||||
<p><a href="#myModal1" class="btn btn-primary" data-toggle="modal">Редактировать
|
||||
авторов
|
||||
статьи</a></p>
|
||||
<div id="myModal1" class="modal fade">
|
||||
<div class="modal-dialog">
|
||||
@ -111,7 +129,8 @@
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle"
|
||||
type="button" data-toggle="dropdown">Выберите автора
|
||||
type="button" data-toggle="dropdown">Выберите
|
||||
автора
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<input class="form-control" id="myInput" type="text"
|
||||
@ -156,6 +175,7 @@
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -25,7 +25,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-12 col-md-12 col-lg-4 col-xl-3">
|
||||
<a href="./paper" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
|
||||
<a href="./paper?id=0" class="btn btn-light toolbar-button"><i class="fa fa-plus-circle"
|
||||
aria-hidden="true"></i>
|
||||
Добавить статью</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user