-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…e-api [FIX] 업무 카드 & 업무 삭제 로직 오류 수정
- Loading branch information
Showing
9 changed files
with
31 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
src/main/java/site/katchup/katchupserver/api/task/repository/TaskRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
package site.katchup.katchupserver.api.task.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import site.katchup.katchupserver.api.category.domain.Category; | ||
import site.katchup.katchupserver.api.task.domain.Task; | ||
import site.katchup.katchupserver.common.exception.NotFoundException; | ||
import site.katchup.katchupserver.common.response.ErrorCode; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface TaskRepository extends JpaRepository<Task, Long> { | ||
List<Task> findByCategoryId(Long categoryId); | ||
|
||
Optional<Task> findByIdAndIsDeletedFalse(Long id); | ||
|
||
boolean existsByCategoryIdAndName(Long categoryId, String name); | ||
|
||
@Query("select t from Task t where t.category.id = :categoryId and t.isDeleted = false") | ||
List<Task> findAllByCategoryIdAndNotDeleted(@Param("categoryId") Long categoryId); | ||
|
||
default Task findByIdOrThrow(Long taskId) { | ||
return findById(taskId).orElseThrow( | ||
return findByIdAndIsDeletedFalse(taskId).orElseThrow( | ||
() -> new NotFoundException(ErrorCode.NOT_FOUND_TASK)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters