Resolve "Список периодических событий" #129
@ -1,10 +1,17 @@
|
||||
package ru.ulstu.paper.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RestController;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.paper.model.PaperStatusDto;
|
||||
import ru.ulstu.paper.service.PaperService;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -43,4 +50,9 @@ public class PaperController {
|
||||
paperService.delete(paperId);
|
||||
return new Response(true);
|
||||
}
|
||||
|
||||
@GetMapping("/statuses")
|
||||
public Response<List<PaperStatusDto>> getPaperStatuses() {
|
||||
return new Response<>(paperService.getPaperStatuses());
|
||||
}
|
||||
}
|
||||
|
19
src/main/java/ru/ulstu/paper/model/PaperStatusDto.java
Normal file
19
src/main/java/ru/ulstu/paper/model/PaperStatusDto.java
Normal file
@ -0,0 +1,19 @@
|
||||
package ru.ulstu.paper.model;
|
||||
|
||||
public class PaperStatusDto {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public PaperStatusDto(Paper.PaperStatus status) {
|
||||
this.id = status.name();
|
||||
this.name = status.getName();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.file.service.FileService;
|
||||
import ru.ulstu.paper.model.Paper;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.paper.model.PaperStatusDto;
|
||||
import ru.ulstu.paper.repository.PaperRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -75,4 +76,8 @@ public class PaperService {
|
||||
}
|
||||
paperRepository.delete(paper);
|
||||
}
|
||||
|
||||
public List<PaperStatusDto> getPaperStatuses() {
|
||||
return convert(Arrays.asList(Paper.PaperStatus.values()), status ->new PaperStatusDto(status));
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
var urlPapers = "https://localhost:8443/api/1.0/papers";
|
||||
var urlPaperStatuses = "https://localhost:8443/api/1.0/papers/statuses";
|
||||
|
||||
function showPapers(papersElement) {
|
||||
getFromRest(urlPapers, function (paperList) {
|
||||
|
@ -76,6 +76,7 @@
|
||||
</div>
|
||||
</section>
|
||||
<script type="text/javascript" src="/js/file-loader.js"></script>
|
||||
<script src="/js/papers.js"></script>
|
||||
<script>
|
||||
/*<![CDATA[*/
|
||||
$(document).ready(function () {
|
||||
@ -83,12 +84,16 @@
|
||||
div: "loader",
|
||||
url: urlFileUpload,
|
||||
maxSize: 1.5,
|
||||
extensions: ["xls", "jpg", "pdf", "txt", "png"],
|
||||
extensions: ["doc", "docx","xls", "jpg", "pdf", "txt", "png"],
|
||||
callback: function (response) {
|
||||
showFeedbackMessage("Файл успешно загружен");
|
||||
console.debug(response);
|
||||
}
|
||||
});
|
||||
|
||||
getFromRest(urlPaperStatuses, function(response) {
|
||||
fillSelect($("#status"), response);
|
||||
});
|
||||
});
|
||||
/*]]>*/
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user