From 2e18e34647e0c76e415a5c381dd6e4b207991de9 Mon Sep 17 00:00:00 2001 From: BarminaA Date: Fri, 14 Oct 2022 11:27:27 +0400 Subject: [PATCH] #66-view list rules --- .../ru/ulstu/extractor/controller/Route.java | 1 + .../extractor/controller/RuleController.java | 25 +++++++++++++++++++ .../java/ru/ulstu/extractor/model/Rule.java | 8 +++--- .../extractor/repository/RuleRepository.java | 7 ++++++ .../ulstu/extractor/service/RuleService.java | 20 +++++++++++++++ src/main/resources/templates/listRules.html | 19 ++++++++------ 6 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 src/main/java/ru/ulstu/extractor/controller/RuleController.java create mode 100644 src/main/java/ru/ulstu/extractor/repository/RuleRepository.java create mode 100644 src/main/java/ru/ulstu/extractor/service/RuleService.java diff --git a/src/main/java/ru/ulstu/extractor/controller/Route.java b/src/main/java/ru/ulstu/extractor/controller/Route.java index 37cc08f..0d3f39e 100644 --- a/src/main/java/ru/ulstu/extractor/controller/Route.java +++ b/src/main/java/ru/ulstu/extractor/controller/Route.java @@ -16,6 +16,7 @@ public class Route { public static final String INDEXING_NEW_REPOSITORY = "indexNewRepository"; public static final String FILTER_COMMITS = "filterCommits"; public static final String STATISTIC = "statistic"; + public static final String LIST_RULE = "listRules"; public static String getLIST_INDEXED_REPOSITORIES() { return LIST_INDEXED_REPOSITORIES; diff --git a/src/main/java/ru/ulstu/extractor/controller/RuleController.java b/src/main/java/ru/ulstu/extractor/controller/RuleController.java new file mode 100644 index 0000000..f9c4eab --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/controller/RuleController.java @@ -0,0 +1,25 @@ +package ru.ulstu.extractor.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import ru.ulstu.extractor.service.RuleService; +import springfox.documentation.annotations.ApiIgnore; + +import static ru.ulstu.extractor.controller.Route.LIST_RULE; + +@Controller +@ApiIgnore +public class RuleController { + private RuleService ruleService; + + public RuleController(RuleService ruleService) { + this.ruleService = ruleService; + } + + @GetMapping(LIST_RULE) + public String getList(Model model) { + model.addAttribute("rules", ruleService.getList()); + return LIST_RULE; + } +} diff --git a/src/main/java/ru/ulstu/extractor/model/Rule.java b/src/main/java/ru/ulstu/extractor/model/Rule.java index 699e621..0075b92 100644 --- a/src/main/java/ru/ulstu/extractor/model/Rule.java +++ b/src/main/java/ru/ulstu/extractor/model/Rule.java @@ -31,11 +31,11 @@ public class Rule extends BaseEntity { this.consequent = consequent; } - public AntecedentValue getFirstValue() { + public AntecedentValue getFirstAntecedentValue() { return firstAntecedentValue; } - public void setFirstValue(AntecedentValue firstAntecedentValue) { + public void setFirstAntecedentValue(AntecedentValue firstAntecedentValue) { this.firstAntecedentValue = firstAntecedentValue; } @@ -47,11 +47,11 @@ public class Rule extends BaseEntity { this.firstAntecedent = firstAntecedent; } - public AntecedentValue getSecondValue() { + public AntecedentValue getSecondAntecedentValue() { return secondAntecedentValue; } - public void setSecondValue(AntecedentValue secondAntecedentValue) { + public void setSecondAntecedentValue(AntecedentValue secondAntecedentValue) { this.secondAntecedentValue = secondAntecedentValue; } diff --git a/src/main/java/ru/ulstu/extractor/repository/RuleRepository.java b/src/main/java/ru/ulstu/extractor/repository/RuleRepository.java new file mode 100644 index 0000000..e931488 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/repository/RuleRepository.java @@ -0,0 +1,7 @@ +package ru.ulstu.extractor.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import ru.ulstu.extractor.model.Rule; + +public interface RuleRepository extends JpaRepository { +} diff --git a/src/main/java/ru/ulstu/extractor/service/RuleService.java b/src/main/java/ru/ulstu/extractor/service/RuleService.java new file mode 100644 index 0000000..7b9f4e1 --- /dev/null +++ b/src/main/java/ru/ulstu/extractor/service/RuleService.java @@ -0,0 +1,20 @@ +package ru.ulstu.extractor.service; + +import org.springframework.stereotype.Service; +import ru.ulstu.extractor.model.Rule; +import ru.ulstu.extractor.repository.RuleRepository; + +import java.util.List; + +@Service +public class RuleService { + private final RuleRepository ruleRepository; + + public RuleService(RuleRepository ruleRepository) { + this.ruleRepository = ruleRepository; + } + + public List getList() { + return ruleRepository.findAll(); + } +} diff --git a/src/main/resources/templates/listRules.html b/src/main/resources/templates/listRules.html index a4694e7..c10aa15 100644 --- a/src/main/resources/templates/listRules.html +++ b/src/main/resources/templates/listRules.html @@ -1,6 +1,6 @@ Простая обработка формы на Spring MVC @@ -10,16 +10,19 @@ - - + - - - - - + + + + + + + + +
ПравилаПравила
Если задач много, а коммитов мало, то увеличить колличество авторов
Если авторов много, задач мало, оценнить эффективность авторов
Еслиито
-- 2.34.1