From 5fa5d670a57a77de30d6ded5dcecfbc82784c270 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 23 Nov 2018 16:45:40 +0400 Subject: [PATCH 01/21] show paper list in mvc --- .../java/ru/ulstu/file/FileController.java | 2 +- .../paper/controller/PaperController.java | 17 ++++---- .../papers/fragments/paperLineFragment.html | 41 +++++++++++++++++++ .../resources/templates/papers/papers.html | 35 ++++++++++++---- 4 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 src/main/resources/templates/papers/fragments/paperLineFragment.html diff --git a/src/main/java/ru/ulstu/file/FileController.java b/src/main/java/ru/ulstu/file/FileController.java index c372910..e60626b 100644 --- a/src/main/java/ru/ulstu/file/FileController.java +++ b/src/main/java/ru/ulstu/file/FileController.java @@ -20,7 +20,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import static java.nio.charset.StandardCharsets.UTF_8; -import static ru.ulstu.paper.controller.PaperController.URL; +import static ru.ulstu.file.FileController.URL; @RestController @RequestMapping(URL) diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index c5cbf4f..25532d3 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -1,5 +1,7 @@ package ru.ulstu.paper.controller; +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.PathVariable; @@ -7,8 +9,6 @@ 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.PaperDto; import ru.ulstu.paper.model.PaperFilterDto; @@ -19,22 +19,19 @@ import javax.validation.Valid; import java.io.IOException; import java.util.List; -import static ru.ulstu.paper.controller.PaperController.URL; -@RestController -@RequestMapping(URL) +@Controller() +@RequestMapping(value = "/papers") public class PaperController { - public static final String URL = Constants.API_1_0 + "papers"; - private final PaperService paperService; public PaperController(PaperService paperService) { this.paperService = paperService; } - @GetMapping - public Response> getPapers() { - return new Response<>(paperService.findAllDto()); + @GetMapping("/papers") + public void getPapers(ModelMap modelMap) { + modelMap.put("papers", paperService.findAllDto()); } @PostMapping diff --git a/src/main/resources/templates/papers/fragments/paperLineFragment.html b/src/main/resources/templates/papers/fragments/paperLineFragment.html new file mode 100644 index 0000000..e532bee --- /dev/null +++ b/src/main/resources/templates/papers/fragments/paperLineFragment.html @@ -0,0 +1,41 @@ + + + + + + +
+
+ + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + + +
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/papers/papers.html b/src/main/resources/templates/papers/papers.html index 3f440cd..76ae59a 100644 --- a/src/main/resources/templates/papers/papers.html +++ b/src/main/resources/templates/papers/papers.html @@ -1,7 +1,7 @@ + layout:decorator="default" xmlns:th=""> @@ -20,25 +20,32 @@
Панель управления + aria-hidden="true"> Панель + управления
+ +
+
-