-
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.
Merge pull request #72 from TeamMiso/feat/notification-detail
🔀 :: 문의사항 답변 글 상세보기 API 구현
- Loading branch information
Showing
10 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/andreas311/miso/domain/notification/adapter/input/NotificationAdapter.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,22 @@ | ||
package andreas311.miso.domain.notification.adapter.input | ||
|
||
import andreas311.miso.common.annotation.RequestController | ||
import andreas311.miso.domain.notification.adapter.input.data.DetailNotificationResponse | ||
import andreas311.miso.domain.notification.adapter.input.mapper.NotificationDataMapper | ||
import andreas311.miso.domain.notification.application.port.input.DetailNotificationUseCase | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
|
||
@RequestController("/notification") | ||
class NotificationAdapter( | ||
private val notificationDataMapper: NotificationDataMapper, | ||
private val detailNotificationUseCase: DetailNotificationUseCase | ||
) { | ||
@GetMapping("/{id}") | ||
fun detail(@PathVariable id: Long): ResponseEntity<DetailNotificationResponse> = | ||
detailNotificationUseCase.execute(id) | ||
.let { notificationDataMapper.toResponse(it) } | ||
.let { ResponseEntity.status(HttpStatus.OK).body(it) } | ||
} |
5 changes: 5 additions & 0 deletions
5
...tlin/andreas311/miso/domain/notification/adapter/input/data/DetailNotificationResponse.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 andreas311.miso.domain.notification.adapter.input.data | ||
|
||
data class DetailNotificationResponse( | ||
val answer: String | ||
) |
13 changes: 13 additions & 0 deletions
13
...kotlin/andreas311/miso/domain/notification/adapter/input/mapper/NotificationDataMapper.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,13 @@ | ||
package andreas311.miso.domain.notification.adapter.input.mapper | ||
|
||
import andreas311.miso.domain.notification.adapter.input.data.DetailNotificationResponse | ||
import andreas311.miso.domain.notification.application.port.input.dto.DetailNotificationDto | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class NotificationDataMapper { | ||
fun toResponse(detailNotificationDto: DetailNotificationDto): DetailNotificationResponse = | ||
DetailNotificationResponse( | ||
answer = detailNotificationDto.answer | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
...iso/domain/notification/adapter/output/persistence/QueryNotificationPersistenceAdapter.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,18 @@ | ||
package andreas311.miso.domain.notification.adapter.output.persistence | ||
|
||
import andreas311.miso.domain.notification.adapter.output.persistence.mapper.NotificationMapper | ||
import andreas311.miso.domain.notification.adapter.output.persistence.repository.NotificationRepository | ||
import andreas311.miso.domain.notification.application.port.output.QueryNotificationPort | ||
import andreas311.miso.domain.notification.domain.Notification | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class QueryNotificationPersistenceAdapter( | ||
private val notificationMapper: NotificationMapper, | ||
private val notificationRepository: NotificationRepository | ||
) : QueryNotificationPort { | ||
override fun findByInquiryIdOrNull(id: Long): Notification? { | ||
val notificationEntity = notificationRepository.findByInquiryId(id) | ||
return notificationMapper.toDomain(notificationEntity) | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...ndreas311/miso/domain/notification/application/exception/NotificationNotFoundException.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,6 @@ | ||
package andreas311.miso.domain.notification.application.exception | ||
|
||
import andreas311.miso.global.error.ErrorCode | ||
import andreas311.miso.global.error.exception.MisoException | ||
|
||
class NotificationNotFoundException : MisoException(ErrorCode.NOTIFICATION_NOT_FOUND) |
7 changes: 7 additions & 0 deletions
7
...n/andreas311/miso/domain/notification/application/port/input/DetailNotificationUseCase.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,7 @@ | ||
package andreas311.miso.domain.notification.application.port.input | ||
|
||
import andreas311.miso.domain.notification.application.port.input.dto.DetailNotificationDto | ||
|
||
interface DetailNotificationUseCase { | ||
fun execute(id: Long): DetailNotificationDto | ||
} |
11 changes: 11 additions & 0 deletions
11
...n/andreas311/miso/domain/notification/application/port/input/dto/DetailNotificationDto.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,11 @@ | ||
package andreas311.miso.domain.notification.application.port.input.dto | ||
|
||
import andreas311.miso.domain.notification.domain.Notification | ||
|
||
data class DetailNotificationDto( | ||
val answer: String | ||
) { | ||
constructor(notification: Notification) : this( | ||
answer = notification.answer | ||
) | ||
} |
7 changes: 7 additions & 0 deletions
7
...tlin/andreas311/miso/domain/notification/application/port/output/QueryNotificationPort.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,7 @@ | ||
package andreas311.miso.domain.notification.application.port.output | ||
|
||
import andreas311.miso.domain.notification.domain.Notification | ||
|
||
interface QueryNotificationPort { | ||
fun findByInquiryIdOrNull(id: Long): Notification? | ||
} |
19 changes: 19 additions & 0 deletions
19
...tlin/andreas311/miso/domain/notification/application/service/DetailNotificationService.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,19 @@ | ||
package andreas311.miso.domain.notification.application.service | ||
|
||
import andreas311.miso.common.annotation.ReadOnlyRollbackService | ||
import andreas311.miso.domain.notification.application.exception.NotificationNotFoundException | ||
import andreas311.miso.domain.notification.application.port.input.DetailNotificationUseCase | ||
import andreas311.miso.domain.notification.application.port.input.dto.DetailNotificationDto | ||
import andreas311.miso.domain.notification.application.port.output.QueryNotificationPort | ||
|
||
@ReadOnlyRollbackService | ||
class DetailNotificationService( | ||
private val queryNotificationPort: QueryNotificationPort | ||
) : DetailNotificationUseCase { | ||
override fun execute(id: Long): DetailNotificationDto { | ||
val notification = queryNotificationPort.findByInquiryIdOrNull(id) | ||
?: throw NotificationNotFoundException() | ||
|
||
return DetailNotificationDto(notification) | ||
} | ||
} |