pass values for paper

This commit is contained in:
Anton Romanov 2018-12-04 11:35:51 +04:00
parent f376fedc64
commit f9670ad0a5
4 changed files with 64 additions and 42 deletions

View File

@ -1,7 +1,9 @@
package ru.ulstu.paper.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
@ -10,6 +12,7 @@ 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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.core.model.response.Response;
import ru.ulstu.paper.model.PaperDto;
@ -46,8 +49,9 @@ public class PaperController {
}
@PostMapping("/paper")
public void createPaper(@ModelAttribute PaperDto paperDto) throws IOException {
public String createPaper(@ModelAttribute PaperDto paperDto) throws IOException {
paperService.create(paperDto);
return "redirect:/papers/papers";
}
@PutMapping

View File

@ -1,8 +1,7 @@
package ru.ulstu.paper.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotNull;
@ -20,6 +19,7 @@ public class PaperDto {
private Date createDate;
private Date updateDate;
@NotNull
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date deadlineDate;
private String comment;
private Boolean locked;
@ -32,32 +32,6 @@ public class PaperDto {
public PaperDto() {
}
@JsonCreator
public PaperDto(@JsonProperty("id") Integer id,
@JsonProperty("title") String title,
@JsonProperty("status") Paper.PaperStatus status,
@JsonProperty("createDate") Date createDate,
@JsonProperty("updateDate") Date updateDate,
@JsonProperty("deadlineDate") Date deadlineDate,
@JsonProperty("comment") String comment,
@JsonProperty("locked") Boolean locked,
@JsonProperty("tmpFileName") String tmpFileName,
@JsonProperty("authors") Set<UserDto> authors) {
this.id = id;
this.title = title;
this.status = status;
this.createDate = createDate;
this.updateDate = updateDate;
this.deadlineDate = deadlineDate;
this.comment = comment;
this.locked = locked;
this.tmpFileName = tmpFileName;
this.fileId = null;
this.fileName = null;
this.fileCreateDate = null;
this.authors = authors;
}
public PaperDto(Paper paper) {
this.id = paper.getId();
this.title = paper.getTitle();
@ -126,6 +100,58 @@ public class PaperDto {
return authors;
}
public void setId(Integer id) {
this.id = id;
}
public void setTitle(String title) {
this.title = title;
}
public void setStatus(Paper.PaperStatus status) {
this.status = status;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public void setDeadlineDate(Date deadlineDate) {
this.deadlineDate = deadlineDate;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setLocked(Boolean locked) {
this.locked = locked;
}
public void setTmpFileName(String tmpFileName) {
this.tmpFileName = tmpFileName;
}
public void setFileId(Integer fileId) {
this.fileId = fileId;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void setFileCreateDate(Date fileCreateDate) {
this.fileCreateDate = fileCreateDate;
}
public void setAuthors(Set<UserDto> authors) {
this.authors = authors;
}
public String getAuthorsString() {
return authors
.stream()

View File

@ -27,21 +27,16 @@
<div class="row">
<div class="col-lg-12">
<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="title">Название:</label>
<input class="form-control" id="title" name="title" type="text"
<input class="form-control" id="title" type="text"
placeholder="Название статьи"
required=""
data-validation-required-message="Введите название статьи"
th:value="${title}"
th:field="*{title}"
/>
th:field="*{title}"/>
<p class="help-block text-danger"></p>
</div>
@ -55,21 +50,18 @@
<div class="form-group">
<label for="comment">Комментарий:</label>
<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"
th:value="${deadlineDate}"
th:field="*{deadlineDate}"
/>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="locked"
th:value="${locked}"
th:field="*{locked}"/>
<label class="form-check-label" for="locked">Заблокирована</label>
</div>

View File

@ -58,7 +58,7 @@
<script type="text/javascript">
/*<![CDATA[*/
$(document).ready(function () {
/* $(document).ready(function () {
$(".paper-row").mouseenter(function (event) {
var paperRow = $(event.target).closest(".paper-row");
$(paperRow).css("background-color", "#f8f9fa");
@ -70,7 +70,7 @@
$(paperRow).css("background-color", "white");
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
});
});
});*/
/*]]>*/
</script>