66-derivation-of-rules
#67
Merged
romanov73
merged 1 commits from 66-derivation-of-rules
into master
2 years ago
@ -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;
|
||||
}
|
||||
}
|
@ -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<Rule, Integer> {
|
||||
}
|
@ -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<Rule> getList() {
|
||||
return ruleRepository.findAll();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue