pass values for paper
This commit is contained in:
parent
f376fedc64
commit
f9670ad0a5
@ -1,7 +1,9 @@
|
|||||||
package ru.ulstu.paper.controller;
|
package ru.ulstu.paper.controller;
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
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.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
@ -46,8 +49,9 @@ public class PaperController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/paper")
|
@PostMapping("/paper")
|
||||||
public void createPaper(@ModelAttribute PaperDto paperDto) throws IOException {
|
public String createPaper(@ModelAttribute PaperDto paperDto) throws IOException {
|
||||||
paperService.create(paperDto);
|
paperService.create(paperDto);
|
||||||
|
return "redirect:/papers/papers";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package ru.ulstu.paper.model;
|
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.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.user.model.UserDto;
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
@ -15,11 +14,12 @@ import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|||||||
public class PaperDto {
|
public class PaperDto {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String title;
|
private String title;
|
||||||
private Paper.PaperStatus status;
|
private Paper.PaperStatus status;
|
||||||
private Date createDate;
|
private Date createDate;
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date deadlineDate;
|
private Date deadlineDate;
|
||||||
private String comment;
|
private String comment;
|
||||||
private Boolean locked;
|
private Boolean locked;
|
||||||
@ -32,32 +32,6 @@ public class PaperDto {
|
|||||||
public 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) {
|
public PaperDto(Paper paper) {
|
||||||
this.id = paper.getId();
|
this.id = paper.getId();
|
||||||
this.title = paper.getTitle();
|
this.title = paper.getTitle();
|
||||||
@ -126,6 +100,58 @@ public class PaperDto {
|
|||||||
return authors;
|
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() {
|
public String getAuthorsString() {
|
||||||
return authors
|
return authors
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -27,21 +27,16 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<form method="post" action="#" th:action="@{/papers/paper}" th:object="${paper}">
|
<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="row">
|
||||||
<div class="col-md-6 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title">Название:</label>
|
<label for="title">Название:</label>
|
||||||
|
|
||||||
<input class="form-control" id="title" name="title" type="text"
|
<input class="form-control" id="title" type="text"
|
||||||
placeholder="Название статьи"
|
placeholder="Название статьи"
|
||||||
required=""
|
required=""
|
||||||
data-validation-required-message="Введите название статьи"
|
data-validation-required-message="Введите название статьи"
|
||||||
th:value="${title}"
|
th:field="*{title}"/>
|
||||||
th:field="*{title}"
|
|
||||||
/>
|
|
||||||
<p class="help-block text-danger"></p>
|
<p class="help-block text-danger"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -55,21 +50,18 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="comment">Комментарий:</label>
|
<label for="comment">Комментарий:</label>
|
||||||
<textarea class="form-control" rows="5" id="comment"
|
<textarea class="form-control" rows="5" id="comment"
|
||||||
th:value="${comment}"
|
|
||||||
th:field="*{comment}"></textarea>
|
th:field="*{comment}"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Дедлайн:</label>
|
<label>Дедлайн:</label>
|
||||||
<input type="date" class="form-control" name="deadline"
|
<input type="date" class="form-control" name="deadline"
|
||||||
th:value="${deadlineDate}"
|
|
||||||
th:field="*{deadlineDate}"
|
th:field="*{deadlineDate}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-check">
|
<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}"/>
|
th:field="*{locked}"/>
|
||||||
<label class="form-check-label" for="locked">Заблокирована</label>
|
<label class="form-check-label" for="locked">Заблокирована</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/*<![CDATA[*/
|
/*<![CDATA[*/
|
||||||
$(document).ready(function () {
|
/* $(document).ready(function () {
|
||||||
$(".paper-row").mouseenter(function (event) {
|
$(".paper-row").mouseenter(function (event) {
|
||||||
var paperRow = $(event.target).closest(".paper-row");
|
var paperRow = $(event.target).closest(".paper-row");
|
||||||
$(paperRow).css("background-color", "#f8f9fa");
|
$(paperRow).css("background-color", "#f8f9fa");
|
||||||
@ -70,7 +70,7 @@
|
|||||||
$(paperRow).css("background-color", "white");
|
$(paperRow).css("background-color", "white");
|
||||||
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
|
$(paperRow).closest(".paper-row").find(".remove-paper").addClass("d-none");
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
/*]]>*/
|
/*]]>*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user