From ac9dcaa11d0b29c5f0ee2fdaa54086b735764c1a Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 17 Mar 2021 12:19:03 +0400 Subject: [PATCH] #2 - add web pages --- .../extractor/mvc/GitExtractorController.java | 23 ++++++----- .../ulstu/extractor/mvc/model/EmailForm.java | 40 ------------------- .../ulstu/extractor/mvc/model/RepoForm.java | 20 ++++++++++ src/main/resources/templates/filtering.html | 25 ++++++++++++ src/main/resources/templates/index.html | 32 --------------- src/main/resources/templates/newRepo.html | 22 ++++++++++ src/main/resources/templates/result.html | 25 ------------ src/main/resources/templates/resultRepo.html | 18 +++++++++ 8 files changed, 97 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/ru/ulstu/extractor/mvc/model/EmailForm.java create mode 100644 src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java create mode 100644 src/main/resources/templates/filtering.html delete mode 100644 src/main/resources/templates/index.html create mode 100644 src/main/resources/templates/newRepo.html delete mode 100644 src/main/resources/templates/result.html create mode 100644 src/main/resources/templates/resultRepo.html diff --git a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java index 487479c..4d9b72b 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java +++ b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java @@ -5,22 +5,23 @@ 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.EmailForm; +import ru.ulstu.extractor.mvc.model.RepoForm; @Controller public class GitExtractorController { - @GetMapping("/") - public String indexForm(Model model) { - model.addAttribute("emailForm", new EmailForm()); - return "index"; + + @GetMapping("/newRepo") + public String indexNewRepo(Model model) { + model.addAttribute("repoForm", new RepoForm()); + return "newRepo"; } - @PostMapping("/sendEmail") - public String sendEmail(@ModelAttribute EmailForm emailForm, Model model) { - if (emailForm.getTo().isEmpty()) { - model.addAttribute("error", "'Кому' не должно быть пустым"); - return "index"; + @PostMapping("/sendRepo") + public String sendRepo(@ModelAttribute RepoForm repoForm, Model model) { + if (repoForm.getRepo() == null || repoForm.getRepo().isEmpty()) { + model.addAttribute("error", "'Git' не должно быть пустым"); + return "newRepo"; } - return "result"; + return "filtering"; } } diff --git a/src/main/java/ru/ulstu/extractor/mvc/model/EmailForm.java b/src/main/java/ru/ulstu/extractor/mvc/model/EmailForm.java deleted file mode 100644 index 59765ee..0000000 --- a/src/main/java/ru/ulstu/extractor/mvc/model/EmailForm.java +++ /dev/null @@ -1,40 +0,0 @@ -package ru.ulstu.extractor.mvc.model; - -public class EmailForm { - private String subject; - private String to; - private String message; - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "EmailForm{" + - "subject='" + subject + '\'' + - ", to='" + to + '\'' + - ", message='" + message + '\'' + - '}'; - } -} diff --git a/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java b/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java new file mode 100644 index 0000000..0a86e6e --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/mvc/model/RepoForm.java @@ -0,0 +1,20 @@ +package ru.ulstu.extractor.mvc.model; + +public class RepoForm { + private String repo; + + public String getRepo() { + return repo; + } + + public void setRepo(String repo) { + this.repo = repo; + } + + @Override + public String toString() { + return "EmailForm{" + + "subject='" + repo + + '}'; + } +} diff --git a/src/main/resources/templates/filtering.html b/src/main/resources/templates/filtering.html new file mode 100644 index 0000000..316f877 --- /dev/null +++ b/src/main/resources/templates/filtering.html @@ -0,0 +1,25 @@ + + + + Простая обработка формы на Spring MVC + + +
+ +
+

Фильтровать данные:
+ Автор
+ Дата
+ Удаленные строки
+ Добавленные строки
+

+

+ +

+
+ + +
+ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html deleted file mode 100644 index 939171f..0000000 --- a/src/main/resources/templates/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - Простая обработка формы на Spring MVC - - -
-

Форма

-
-

- - - - - - - - - - - -
Тема:
Кому:
Сообщение: