#13 -- Show rules of project
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m36s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m36s
This commit is contained in:
parent
2ca47e0d98
commit
ef9b78251c
@ -0,0 +1,23 @@
|
|||||||
|
package ru.ulstu.fc.project.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import ru.ulstu.fc.project.model.Project;
|
||||||
|
import ru.ulstu.fc.project.model.ProjectForm;
|
||||||
|
import ru.ulstu.fc.project.service.ProjectRulesService;
|
||||||
|
import ru.ulstu.fc.project.service.ProjectService;
|
||||||
|
import ru.ulstu.fc.user.model.UserRoleConstants;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@Hidden
|
||||||
|
@RequestMapping("projectRules")
|
||||||
|
@Secured({UserRoleConstants.ADMIN})
|
||||||
|
public class ProjecRulesController {
|
||||||
|
|
||||||
|
}
|
@ -10,18 +10,22 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import ru.ulstu.fc.project.model.Project;
|
import ru.ulstu.fc.project.model.Project;
|
||||||
import ru.ulstu.fc.project.model.ProjectForm;
|
import ru.ulstu.fc.project.model.ProjectForm;
|
||||||
|
import ru.ulstu.fc.project.service.ProjectRulesService;
|
||||||
import ru.ulstu.fc.project.service.ProjectService;
|
import ru.ulstu.fc.project.service.ProjectService;
|
||||||
import ru.ulstu.fc.user.model.UserRoleConstants;
|
import ru.ulstu.fc.user.model.UserRoleConstants;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@Hidden
|
@Hidden
|
||||||
@RequestMapping("project")
|
@RequestMapping("project")
|
||||||
@Secured({UserRoleConstants.ADMIN})
|
@Secured({ UserRoleConstants.ADMIN })
|
||||||
public class ProjectController {
|
public class ProjectController {
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
|
private final ProjectRulesService projectRulesService;
|
||||||
|
|
||||||
public ProjectController(ProjectService projectService) {
|
public ProjectController(ProjectService projectService,
|
||||||
|
ProjectRulesService projectRulesService) {
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
|
this.projectRulesService = projectRulesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@ -36,6 +40,8 @@ public class ProjectController {
|
|||||||
new ProjectForm((id != null && id != 0)
|
new ProjectForm((id != null && id != 0)
|
||||||
? projectService.getById(id)
|
? projectService.getById(id)
|
||||||
: new Project()));
|
: new Project()));
|
||||||
|
|
||||||
|
model.addAttribute("rules", projectRulesService.getByProjectId(id));
|
||||||
return "project/edit";
|
return "project/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package ru.ulstu.fc.project.repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import ru.ulstu.fc.rule.model.Rule;
|
||||||
|
|
||||||
|
public interface RuleRepository extends JpaRepository<Rule, Integer> {
|
||||||
|
|
||||||
|
List<Rule> findByProjectId(Integer projectId);
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package ru.ulstu.fc.project.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import ru.ulstu.fc.project.repository.RuleRepository;
|
||||||
|
import ru.ulstu.fc.rule.model.Rule;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProjectRulesService {
|
||||||
|
private final RuleRepository ruleRepository;
|
||||||
|
|
||||||
|
public ProjectRulesService(RuleRepository ruleRepository) {
|
||||||
|
this.ruleRepository = ruleRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Rule> getByProjectId(Integer projectId) {
|
||||||
|
return ruleRepository.findByProjectId(projectId);
|
||||||
|
}
|
||||||
|
}
|
20
src/main/java/ru/ulstu/fc/rule/model/Rule.java
Normal file
20
src/main/java/ru/ulstu/fc/rule/model/Rule.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package ru.ulstu.fc.rule.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import ru.ulstu.fc.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.fc.project.model.Project;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Rule extends BaseEntity {
|
||||||
|
@ManyToOne
|
||||||
|
private Project project;
|
||||||
|
|
||||||
|
public Project getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProject(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
}
|
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<h4> Список правил</h4>
|
<h4> Список правил</h4>
|
||||||
<div class="row">
|
<div class="row" th:each="r, iter : ${rules}">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<span class="badge badge-light">1. Если</span>
|
<span class="badge badge-light" th:text="${iter} + ' Если'"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-md-2 offset-md-3">
|
<div class="col col-md-2 offset-md-3">
|
||||||
<span class="badge badge-primary">Переменная</span>
|
<span class="badge badge-primary">Переменная</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user