#6 -- Check permissions to the fuzzy rule
Some checks failed
CI fuzzy controller / container-test-job (push) Has been cancelled
Some checks failed
CI fuzzy controller / container-test-job (push) Has been cancelled
This commit is contained in:
parent
71a7adc5fd
commit
a4f2cf2fcb
@ -11,15 +11,18 @@ public class FuzzyRuleService {
|
|||||||
private final FuzzyRuleRepository ruleRepository;
|
private final FuzzyRuleRepository ruleRepository;
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
|
|
||||||
public FuzzyRuleService(FuzzyRuleRepository ruleRepository, ProjectService projectService) {
|
public FuzzyRuleService(FuzzyRuleRepository ruleRepository,
|
||||||
|
ProjectService projectService) {
|
||||||
this.ruleRepository = ruleRepository;
|
this.ruleRepository = ruleRepository;
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FuzzyRule getById(Integer id) {
|
public FuzzyRule getById(Integer id) {
|
||||||
return ruleRepository
|
FuzzyRule fuzzyRule = ruleRepository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("Rule not found by id"));
|
.orElseThrow(() -> new RuntimeException("Rule not found by id"));
|
||||||
|
checkIsCurrentUserFuzzyRuleWithThrow(fuzzyRule);
|
||||||
|
return fuzzyRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FuzzyRule save(FuzzyRuleForm ruleForm) {
|
public FuzzyRule save(FuzzyRuleForm ruleForm) {
|
||||||
@ -35,7 +38,10 @@ public class FuzzyRuleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void delete(FuzzyRuleForm ruleForm) {
|
public void delete(FuzzyRuleForm ruleForm) {
|
||||||
getById(ruleForm.getId());
|
ruleRepository.delete(getById(ruleForm.getId()));
|
||||||
ruleRepository.deleteById(ruleForm.getId());
|
}
|
||||||
|
|
||||||
|
public void checkIsCurrentUserFuzzyRuleWithThrow(FuzzyRule fuzzyRule) {
|
||||||
|
projectService.checkIsCurrentUserProjectWithThrow(fuzzyRule.getProject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user