All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m11s
53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
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.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,
|
|
ProjectRulesService projectRulesService) {
|
|
this.ruleService = ruleService;
|
|
this.projectRulesService = projectRulesService;
|
|
}
|
|
|
|
@GetMapping("/getAll/{projectId}")
|
|
public List<FuzzyRule> 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);
|
|
}
|
|
|
|
@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);
|
|
}
|
|
}
|
|
}
|