#17 -- REST CRUD for rules
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 59s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 59s
This commit is contained in:
parent
d10db93950
commit
92be5c9ac6
@ -0,0 +1,40 @@
|
||||
package ru.ulstu.fc.rule.controller;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
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 org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.fc.rule.model.FuzzyRule;
|
||||
import ru.ulstu.fc.rule.model.FuzzyRuleForm;
|
||||
import ru.ulstu.fc.rule.service.FuzzyRuleService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("fuzzyRuleRest")
|
||||
public class FuzzyRuleRestController {
|
||||
private final FuzzyRuleService ruleService;
|
||||
|
||||
public FuzzyRuleRestController(FuzzyRuleService ruleService) {
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
@GetMapping("/get/{projectId}/{ruleId}")
|
||||
public FuzzyRule get(@PathVariable(value = "projectId") Integer projectId,
|
||||
@PathVariable(value = "ruleId") Integer id) {
|
||||
return ruleService.getById(id);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public FuzzyRule save(@Valid FuzzyRuleForm fuzzyRuleForm) {
|
||||
return ruleService.save(fuzzyRuleForm);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void delete(@Valid FuzzyRuleForm fuzzyRuleForm) {
|
||||
if (fuzzyRuleForm != null && fuzzyRuleForm.getId() != null) {
|
||||
ruleService.delete(fuzzyRuleForm);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ public class FuzzyRuleService {
|
||||
.orElseThrow(() -> new RuntimeException("Rule not found by id"));
|
||||
}
|
||||
|
||||
public Object save(FuzzyRuleForm ruleForm) {
|
||||
public FuzzyRule save(FuzzyRuleForm ruleForm) {
|
||||
FuzzyRule rule;
|
||||
if (ruleForm.getId() == null || ruleForm.getId() == 0) {
|
||||
rule = new FuzzyRule();
|
||||
|
Loading…
x
Reference in New Issue
Block a user