6-project-permissions #19
@ -14,15 +14,18 @@ public class VariableService {
|
||||
private final VariableRepository variableRepository;
|
||||
private final ProjectService projectService;
|
||||
|
||||
public VariableService(VariableRepository variableRepository, ProjectService projectService) {
|
||||
public VariableService(VariableRepository variableRepository,
|
||||
ProjectService projectService) {
|
||||
this.variableRepository = variableRepository;
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
public Variable getById(Integer id) {
|
||||
return variableRepository
|
||||
Variable variable = variableRepository
|
||||
.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Variable not found by id"));
|
||||
checkIsCurrentUserVariableWithThrow(variable);
|
||||
return variable;
|
||||
}
|
||||
|
||||
public Variable save(VariableForm variableForm) {
|
||||
@ -65,4 +68,8 @@ public class VariableService {
|
||||
public List<Variable> getAllByProject(Integer projectId) {
|
||||
return variableRepository.getByProject(projectService.getById(projectId));
|
||||
}
|
||||
|
||||
public void checkIsCurrentUserVariableWithThrow(Variable variable) {
|
||||
projectService.checkIsCurrentUserProjectWithThrow(variable.getProject());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user