#17 -- REST CRUD for terms
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m8s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m8s
This commit is contained in:
parent
d8f51fefc6
commit
9ad33c4e79
@ -0,0 +1,47 @@
|
|||||||
|
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.RestController;
|
||||||
|
import ru.ulstu.fc.rule.model.FuzzyTerm;
|
||||||
|
import ru.ulstu.fc.rule.model.FuzzyTermForm;
|
||||||
|
import ru.ulstu.fc.rule.service.FuzzyTermService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController("fuzzyTermRest")
|
||||||
|
public class FuzzyTermRestController {
|
||||||
|
private final FuzzyTermService fuzzyTermService;
|
||||||
|
|
||||||
|
public FuzzyTermRestController(FuzzyTermService fuzzyTermService) {
|
||||||
|
this.fuzzyTermService = fuzzyTermService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list/{projectId}/{variableId}")
|
||||||
|
public List<FuzzyTerm> getList(@PathVariable(value = "projectId") Integer projectId,
|
||||||
|
@PathVariable(value = "variableId") Integer variableId) {
|
||||||
|
return fuzzyTermService.getAll(projectId, variableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/{projectId}/{variableId}/{fuzzyTermId}")
|
||||||
|
public FuzzyTerm getById(@PathVariable(value = "projectId") Integer projectId,
|
||||||
|
@PathVariable(value = "variableId") Integer variableId,
|
||||||
|
@PathVariable(value = "fuzzyTermId") Integer fuzzyTermId) {
|
||||||
|
return fuzzyTermService.getById(fuzzyTermId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public FuzzyTerm save(@Valid FuzzyTermForm fuzzyTermForm) {
|
||||||
|
return fuzzyTermService.save(fuzzyTermForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
public void delete(@Valid FuzzyTermForm fuzzyTermForm) {
|
||||||
|
if (fuzzyTermForm != null && fuzzyTermForm.getId() != null) {
|
||||||
|
fuzzyTermService.delete(fuzzyTermForm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,11 @@
|
|||||||
package ru.ulstu.fc.rule.model;
|
package ru.ulstu.fc.rule.model;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class FuzzyTermForm {
|
public class FuzzyTermForm {
|
||||||
|
@NotNull
|
||||||
private Integer projectId;
|
private Integer projectId;
|
||||||
|
@NotNull
|
||||||
private Integer variableId;
|
private Integer variableId;
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String description;
|
private String description;
|
||||||
|
@ -53,4 +53,8 @@ public class FuzzyTermService {
|
|||||||
}
|
}
|
||||||
return variableService.getById(variableId).getFuzzyTerms();
|
return variableService.getById(variableId).getFuzzyTerms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FuzzyTerm> getAll(Integer projectId, Integer variableId) {
|
||||||
|
return getByVariableId(variableId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user