6-project-permissions #19

Merged
romanov73 merged 4 commits from 6-project-permissions into master 2025-02-26 12:07:43 +04:00
Showing only changes of commit 0093416e6c - Show all commits

View File

@ -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());
}
}