Resolve "Список периодических событий" #129

Merged
romanov73 merged 57 commits from 4-show-time-line into master 2018-10-30 23:32:01 +04:00
5 changed files with 45 additions and 3 deletions
Showing only changes of commit e163529d66 - Show all commits

View File

@ -1,10 +1,17 @@
package ru.ulstu.paper.controller; 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.configuration.Constants;
import ru.ulstu.core.model.response.Response; import ru.ulstu.core.model.response.Response;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto; import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.service.PaperService; import ru.ulstu.paper.service.PaperService;
import java.io.IOException; import java.io.IOException;
@ -43,4 +50,9 @@ public class PaperController {
paperService.delete(paperId); paperService.delete(paperId);
return new Response(true); return new Response(true);
} }
@GetMapping("/statuses")
public Response<List<PaperStatusDto>> getPaperStatuses() {
return new Response<>(paperService.getPaperStatuses());
}
} }

View 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;
}
}

View File

@ -5,6 +5,7 @@ import org.springframework.transaction.annotation.Transactional;
import ru.ulstu.file.service.FileService; import ru.ulstu.file.service.FileService;
import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.Paper;
import ru.ulstu.paper.model.PaperDto; import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.paper.model.PaperStatusDto;
import ru.ulstu.paper.repository.PaperRepository; import ru.ulstu.paper.repository.PaperRepository;
import java.io.IOException; import java.io.IOException;
@ -75,4 +76,8 @@ public class PaperService {
} }
paperRepository.delete(paper); paperRepository.delete(paper);
} }
public List<PaperStatusDto> getPaperStatuses() {
return convert(Arrays.asList(Paper.PaperStatus.values()), status ->new PaperStatusDto(status));
}
} }

View File

@ -1,4 +1,5 @@
var urlPapers = "https://localhost:8443/api/1.0/papers"; var urlPapers = "https://localhost:8443/api/1.0/papers";
var urlPaperStatuses = "https://localhost:8443/api/1.0/papers/statuses";
function showPapers(papersElement) { function showPapers(papersElement) {
getFromRest(urlPapers, function (paperList) { getFromRest(urlPapers, function (paperList) {

View File

@ -76,6 +76,7 @@
</div> </div>
</section> </section>
<script type="text/javascript" src="/js/file-loader.js"></script> <script type="text/javascript" src="/js/file-loader.js"></script>
<script src="/js/papers.js"></script>
<script> <script>
/*<![CDATA[*/ /*<![CDATA[*/
$(document).ready(function () { $(document).ready(function () {
@ -83,12 +84,16 @@
div: "loader", div: "loader",
url: urlFileUpload, url: urlFileUpload,
maxSize: 1.5, maxSize: 1.5,
extensions: ["xls", "jpg", "pdf", "txt", "png"], extensions: ["doc", "docx","xls", "jpg", "pdf", "txt", "png"],
callback: function (response) { callback: function (response) {
showFeedbackMessage("Файл успешно загружен"); showFeedbackMessage("Файл успешно загружен");
console.debug(response); console.debug(response);
} }
}); });
getFromRest(urlPaperStatuses, function(response) {
fillSelect($("#status"), response);
});
}); });
/*]]>*/ /*]]>*/
</script> </script>