#6 -- Check permissions to the fuzzy rule
Some checks failed
CI fuzzy controller / container-test-job (push) Has been cancelled

This commit is contained in:
Anton Romanov 2025-02-26 12:03:11 +04:00
parent 71a7adc5fd
commit a4f2cf2fcb

View File

@ -11,15 +11,18 @@ public class FuzzyRuleService {
private final FuzzyRuleRepository ruleRepository;
private final ProjectService projectService;
public FuzzyRuleService(FuzzyRuleRepository ruleRepository, ProjectService projectService) {
public FuzzyRuleService(FuzzyRuleRepository ruleRepository,
ProjectService projectService) {
this.ruleRepository = ruleRepository;
this.projectService = projectService;
}
public FuzzyRule getById(Integer id) {
return ruleRepository
FuzzyRule fuzzyRule = ruleRepository
.findById(id)
.orElseThrow(() -> new RuntimeException("Rule not found by id"));
checkIsCurrentUserFuzzyRuleWithThrow(fuzzyRule);
return fuzzyRule;
}
public FuzzyRule save(FuzzyRuleForm ruleForm) {
@ -35,7 +38,10 @@ public class FuzzyRuleService {
}
public void delete(FuzzyRuleForm ruleForm) {
getById(ruleForm.getId());
ruleRepository.deleteById(ruleForm.getId());
ruleRepository.delete(getById(ruleForm.getId()));
}
public void checkIsCurrentUserFuzzyRuleWithThrow(FuzzyRule fuzzyRule) {
projectService.checkIsCurrentUserProjectWithThrow(fuzzyRule.getProject());
}
}