-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement DeleteDiaryPersistenceAdapter
- Loading branch information
1 parent
6721151
commit 229fda8
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ain/kotlin/me/daegyeo/maru/diary/adaptor/out/persistence/DeleteDiaryPersistenceAdapter.kt
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package me.daegyeo.maru.diary.adaptor.out.persistence | ||
|
||
import me.daegyeo.maru.diary.application.port.out.DeleteDiaryPort | ||
import org.springframework.stereotype.Component | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
@Component | ||
class DeleteDiaryPersistenceAdapter(private val diaryRepository: DiaryRepository) : DeleteDiaryPort { | ||
override fun deleteDiary(diaryId: Long): Boolean { | ||
val diary = diaryRepository.findById(diaryId).getOrNull() | ||
return diary?.let { | ||
diaryRepository.delete(it) | ||
true | ||
} ?: false | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/me/daegyeo/maru/diary/application/port/out/DeleteDiaryPort.kt
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.daegyeo.maru.diary.application.port.out | ||
|
||
fun interface DeleteDiaryPort { | ||
fun deleteDiary(diaryId: Long): Boolean | ||
} |