Skip to content

Commit

Permalink
✨ InquiryRespondService 에 문의 사항 답변 관련 푸시 알림 기능 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuuuuuk committed Apr 12, 2024
1 parent 777573c commit 6e8048e
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@ package andreas311.miso.domain.inquiry.application.service
import andreas311.miso.common.annotation.RollbackService
import andreas311.miso.domain.auth.application.port.output.UserSecurityPort
import andreas311.miso.domain.inquiry.application.exception.InquiryNotFoundException
import andreas311.miso.domain.inquiry.application.port.input.WriteInquiryRespondUseCase
import andreas311.miso.domain.inquiry.application.port.input.InquiryRespondUseCase
import andreas311.miso.domain.inquiry.application.port.input.dto.WriteInquiryRespondDto
import andreas311.miso.domain.inquiry.application.port.output.CommandInquiryPort
import andreas311.miso.domain.inquiry.application.port.output.QueryInquiryPort
import andreas311.miso.domain.inquiry.domain.InquiryStatus
import andreas311.miso.domain.notification.application.port.input.InquiryNotificationSendUseCase
import andreas311.miso.domain.notification.application.port.output.CommandNotificationPort
import andreas311.miso.domain.notification.application.port.output.QueryDeviceTokenPort
import andreas311.miso.domain.notification.domain.Notification

@RollbackService
class WriteInquiryRespondService(
class InquiryRespondService(
private val userSecurityPort: UserSecurityPort,
private val queryInquiryPort: QueryInquiryPort,
private val commandInquiryPort: CommandInquiryPort,
private val commandNotificationPort: CommandNotificationPort
) : WriteInquiryRespondUseCase {
private val queryDeviceTokenPort: QueryDeviceTokenPort,
private val commandNotificationPort: CommandNotificationPort,
private val inquiryNotificationSendUseCase: InquiryNotificationSendUseCase
) : InquiryRespondUseCase {
override fun execute(id: Long, writeInquiryRespondDto: WriteInquiryRespondDto) {
val user = userSecurityPort.currentUser()

val inquiry = queryInquiryPort.findByIdOrNull(id)
?: throw InquiryNotFoundException()

val deviceToken = queryDeviceTokenPort.findByUserIdOrNull(user.id)

commandInquiryPort.saveInquiry(inquiry.updateInquiryStatus(InquiryStatus.COMPLETE))

commandNotificationPort.saveNotification(
Expand All @@ -34,5 +40,7 @@ class WriteInquiryRespondService(
inquiry = inquiry
)
)

deviceToken?.let { inquiryNotificationSendUseCase.execute(inquiry, deviceToken.deviceToken) }
}
}

0 comments on commit 6e8048e

Please sign in to comment.