diff --git a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java index 4d9b72b..4b46dae 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java +++ b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java @@ -5,6 +5,7 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; +import ru.ulstu.extractor.mvc.model.FilterForm; import ru.ulstu.extractor.mvc.model.RepoForm; @Controller @@ -16,12 +17,28 @@ public class GitExtractorController { return "newRepo"; } + @GetMapping("/filtering") + public String filter(Model model) { + model.addAttribute("filterForm", new FilterForm()); + return "filtering"; + } + @PostMapping("/sendRepo") public String sendRepo(@ModelAttribute RepoForm repoForm, Model model) { + model.addAttribute("filterForm", new FilterForm()); if (repoForm.getRepo() == null || repoForm.getRepo().isEmpty()) { model.addAttribute("error", "'Git' не должно быть пустым"); return "newRepo"; } return "filtering"; } + + @PostMapping("/sendFilter") + public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) { + if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) { + model.addAttribute("error", "'Строка' не должно быть пустым"); + return "filtering"; + } + return "resultRepo"; + } } diff --git a/src/main/java/ru/ulstu/extractor/mvc/model/FilterForm.java b/src/main/java/ru/ulstu/extractor/mvc/model/FilterForm.java new file mode 100644 index 0000000..9a3e8d0 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/mvc/model/FilterForm.java @@ -0,0 +1,20 @@ +package ru.ulstu.extractor.mvc.model; + +public class FilterForm { + private String filter; + + public String getFilter() { + return filter; + } + + public void setFilter(String filter) { + this.filter = filter; + } + + @Override + public String toString() { + return "FilterForm{" + + "subject='" + filter + + '}'; + } +} diff --git a/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java b/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java index 0a86e6e..7f5766f 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java +++ b/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java @@ -13,7 +13,7 @@ public class RepoForm { @Override public String toString() { - return "EmailForm{" + + return "RepoForm{" + "subject='" + repo + '}'; } diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index bb0ca4a..0017912 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -32,14 +32,16 @@
+
+