6-project-permissions #19
@ -14,15 +14,18 @@ public class VariableService {
|
|||||||
private final VariableRepository variableRepository;
|
private final VariableRepository variableRepository;
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
|
|
||||||
public VariableService(VariableRepository variableRepository, ProjectService projectService) {
|
public VariableService(VariableRepository variableRepository,
|
||||||
|
ProjectService projectService) {
|
||||||
this.variableRepository = variableRepository;
|
this.variableRepository = variableRepository;
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable getById(Integer id) {
|
public Variable getById(Integer id) {
|
||||||
return variableRepository
|
Variable variable = variableRepository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("Variable not found by id"));
|
.orElseThrow(() -> new RuntimeException("Variable not found by id"));
|
||||||
|
checkIsCurrentUserVariableWithThrow(variable);
|
||||||
|
return variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variable save(VariableForm variableForm) {
|
public Variable save(VariableForm variableForm) {
|
||||||
@ -65,4 +68,8 @@ public class VariableService {
|
|||||||
public List<Variable> getAllByProject(Integer projectId) {
|
public List<Variable> getAllByProject(Integer projectId) {
|
||||||
return variableRepository.getByProject(projectService.getById(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