Skip to content

Commit

Permalink
formatt backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel7373 committed Jan 13, 2025
1 parent 0ac22f9 commit 8a468fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package ch.puzzle.okr.service.business;

import static org.springframework.http.HttpStatus.NOT_FOUND;

import ch.puzzle.okr.ErrorKey;
import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Completed;
import ch.puzzle.okr.service.persistence.CompletedPersistenceService;
import ch.puzzle.okr.service.validation.CompletedValidationService;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;

import java.util.List;

import static org.springframework.http.HttpStatus.NOT_FOUND;
import org.springframework.stereotype.Service;

@Service
public class CompletedBusinessService {
Expand Down Expand Up @@ -41,9 +40,12 @@ public void deleteCompletedByObjectiveId(Long objectiveId) {
public Completed getCompletedByObjectiveId(Long objectiveId) {
validator.validateOnGet(objectiveId);
Completed completed = completedPersistenceService.getCompletedByObjectiveId(objectiveId);
// Must exist in business service in order to prevent error while deleting ongoing objectives
// Must exist in business service in order to prevent error while deleting
// ongoing objectives
if (completed == null) {
throw new OkrResponseStatusException(NOT_FOUND, ErrorKey.MODEL_WITH_ID_NOT_FOUND, List.of(completedPersistenceService.getModelName(), objectiveId));
throw new OkrResponseStatusException(NOT_FOUND,
ErrorKey.MODEL_WITH_ID_NOT_FOUND,
List.of(completedPersistenceService.getModelName(), objectiveId));
}
return completed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public String getModelName() {
}

public Completed getCompletedByObjectiveId(Long objectiveId) {
return getRepository()
.findByObjectiveId(objectiveId).orElse(null);
return getRepository().findByObjectiveId(objectiveId).orElse(null);
}
}

0 comments on commit 8a468fd

Please sign in to comment.