diff --git a/build.gradle b/build.gradle index d044239..09ddc81 100644 --- a/build.gradle +++ b/build.gradle @@ -46,8 +46,7 @@ dependencies { implementation group: 'org.webjars', name: 'jquery', version: '3.6.0' implementation group: 'org.webjars', name: 'bootstrap', version: '4.6.0' implementation group: 'org.webjars', name: 'bootstrap-select', version: '1.13.8' - implementation group: 'org.webjars', name: 'font-awesome', version: '4.7.0' - implementation group: 'org.webjars', name: 'highcharts', version: '7.0.0' + implementation 'org.webjars.npm:bootstrap-icons:1.11.3' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-test' } diff --git a/src/main/java/ru/ulstu/fc/project/service/ProjectVariableService.java b/src/main/java/ru/ulstu/fc/project/service/ProjectVariableService.java index 5ec7194..1ad8658 100644 --- a/src/main/java/ru/ulstu/fc/project/service/ProjectVariableService.java +++ b/src/main/java/ru/ulstu/fc/project/service/ProjectVariableService.java @@ -24,4 +24,18 @@ public class ProjectVariableService { } return variableRepository.findByProject(projectService.getById(projectId)); } + + public List getInputByProjectId(Integer projectId) { + if (projectId == null || projectId == 0) { + return Collections.emptyList(); + } + return variableRepository.findInputByProject(projectService.getById(projectId)); + } + + public List getOutputByProjectId(Integer projectId) { + if (projectId == null || projectId == 0) { + return Collections.emptyList(); + } + return variableRepository.findOutputByProject(projectService.getById(projectId)); + } } diff --git a/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleRestController.java b/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleRestController.java index 03469d9..158e9ba 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleRestController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/FuzzyRuleRestController.java @@ -7,22 +7,34 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import ru.ulstu.fc.project.service.ProjectRulesService; import ru.ulstu.fc.rule.model.FuzzyRule; import ru.ulstu.fc.rule.model.FuzzyRuleForm; import ru.ulstu.fc.rule.service.FuzzyRuleService; +import java.util.List; + @RestController @RequestMapping("fuzzyRuleRest") public class FuzzyRuleRestController { private final FuzzyRuleService ruleService; + private final ProjectRulesService projectRulesService; - public FuzzyRuleRestController(FuzzyRuleService ruleService) { + public FuzzyRuleRestController(FuzzyRuleService ruleService, + ProjectRulesService projectRulesService) { this.ruleService = ruleService; + this.projectRulesService = projectRulesService; } - @GetMapping("/get/{projectId}/{ruleId}") - public FuzzyRule get(@PathVariable(value = "projectId") Integer projectId, - @PathVariable(value = "ruleId") Integer id) { + @GetMapping("/getAll/{projectId}") + public List getAll(@PathVariable(value = "projectId") Integer projectId) { + //TODO: return dto + return projectRulesService.getByProjectId(projectId); + } + + @GetMapping("/get/{ruleId}") + public FuzzyRule get(@PathVariable(value = "ruleId") Integer id) { + //TODO: return dto return ruleService.getById(id); } diff --git a/src/main/java/ru/ulstu/fc/rule/model/dto/VariableDto.java b/src/main/java/ru/ulstu/fc/rule/model/dto/VariableDto.java index f708cfa..541874a 100644 --- a/src/main/java/ru/ulstu/fc/rule/model/dto/VariableDto.java +++ b/src/main/java/ru/ulstu/fc/rule/model/dto/VariableDto.java @@ -8,6 +8,7 @@ import java.util.List; public class VariableDto { private Integer id; private String name; + private boolean input; private List terms = new ArrayList<>(); public VariableDto() { @@ -17,6 +18,7 @@ public class VariableDto { this.id = variable.getId(); this.name = variable.getName(); this.terms = variable.getFuzzyTerms().stream().map(FuzzyTermDto::new).toList(); + this.input = variable.isInput(); } public String getName() { @@ -42,4 +44,12 @@ public class VariableDto { public void setId(Integer id) { this.id = id; } + + public boolean isInput() { + return input; + } + + public void setInput(boolean input) { + this.input = input; + } } diff --git a/src/main/java/ru/ulstu/fc/rule/repository/VariableRepository.java b/src/main/java/ru/ulstu/fc/rule/repository/VariableRepository.java index 9499f09..ae56a66 100644 --- a/src/main/java/ru/ulstu/fc/rule/repository/VariableRepository.java +++ b/src/main/java/ru/ulstu/fc/rule/repository/VariableRepository.java @@ -1,6 +1,8 @@ package ru.ulstu.fc.rule.repository; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import ru.ulstu.fc.project.model.Project; import ru.ulstu.fc.rule.model.Variable; @@ -11,4 +13,10 @@ public interface VariableRepository extends JpaRepository { List findByProject(Project project); List getByProject(Project project); + + @Query("SELECT v FROM Variable v WHERE v.project = :project AND v.input = true") + List findInputByProject(@Param("project") Project project); + + @Query("SELECT v FROM Variable v WHERE v.project = :project AND v.input = false") + List findOutputByProject(@Param("project") Project project); } diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index d4459fb..1b3cb31 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -11,7 +11,8 @@ - + + diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index 209e768..ec19560 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -35,7 +35,13 @@ @@ -48,7 +54,7 @@ @@ -70,9 +76,9 @@ } else { ruleHtml += "
"; } - ruleHtml += "
"+getVariable(a)+"
"; + ruleHtml += "
" + getVariable(a) + "
"; ruleHtml += "
есть
"; - ruleHtml += "
"+getVariableValue(a)+"
"; + ruleHtml += "
" + getVariableValue(a) + "
"; } ruleHtml += "
То
" for (let i = 0; i < consequentComponents.length; i++) { @@ -87,11 +93,12 @@ ruleHtml += "
" + getVariableValue(c) + "
"; } $(el).html(ruleHtml); + $(el).removeClass('d-none'); } - $('.rule').each(function(index) { + + $('.rule').each(function (index) { addRule(index, $(this), $(this).text()); }); - diff --git a/src/main/resources/templates/project/list.html b/src/main/resources/templates/project/list.html index e5f6165..32d1359 100644 --- a/src/main/resources/templates/project/list.html +++ b/src/main/resources/templates/project/list.html @@ -7,16 +7,19 @@ diff --git a/src/main/resources/templates/project/listRules.html b/src/main/resources/templates/project/listRules.html deleted file mode 100644 index 04a8a7f..0000000 --- a/src/main/resources/templates/project/listRules.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Список правил - - -
-

Список правил

-
-
- 1. Если -
-
- Переменная -
-
- есть -
-
- значение -
-
- И / ИЛИ -
-
-
- - \ No newline at end of file diff --git a/src/main/resources/templates/variable/edit.html b/src/main/resources/templates/variable/edit.html index 2f9979d..cad10ef 100644 --- a/src/main/resources/templates/variable/edit.html +++ b/src/main/resources/templates/variable/edit.html @@ -39,8 +39,10 @@