-
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 #70 from TeamMiso/feat/inquiry-respond
문의사항 글 답변하기 api 구현
- Loading branch information
Showing
15 changed files
with
175 additions
and
13 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
8 changes: 8 additions & 0 deletions
8
...n/andreas311/miso/domain/inquiry/adapter/input/data/request/WriteInquiryRespondRequest.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,8 @@ | ||
package andreas311.miso.domain.inquiry.adapter.input.data.request | ||
|
||
import javax.validation.constraints.NotNull | ||
|
||
data class WriteInquiryRespondRequest( | ||
@field:NotNull | ||
val answer: String | ||
) |
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
7 changes: 7 additions & 0 deletions
7
...otlin/andreas311/miso/domain/inquiry/application/port/input/WriteInquiryRespondUseCase.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.inquiry.application.port.input | ||
|
||
import andreas311.miso.domain.inquiry.application.port.input.dto.WriteInquiryRespondDto | ||
|
||
interface WriteInquiryRespondUseCase { | ||
fun execute(id: Long, writeInquiryRespondDto: WriteInquiryRespondDto) | ||
} |
5 changes: 5 additions & 0 deletions
5
...otlin/andreas311/miso/domain/inquiry/application/port/input/dto/WriteInquiryRespondDto.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.inquiry.application.port.input.dto | ||
|
||
data class WriteInquiryRespondDto( | ||
val answer: String | ||
) |
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
38 changes: 38 additions & 0 deletions
38
...n/kotlin/andreas311/miso/domain/inquiry/application/service/WriteInquiryRespondService.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,38 @@ | ||
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.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.output.CommandNotificationPort | ||
import andreas311.miso.domain.notification.domain.Notification | ||
|
||
@RollbackService | ||
class WriteInquiryRespondService( | ||
private val userSecurityPort: UserSecurityPort, | ||
private val queryInquiryPort: QueryInquiryPort, | ||
private val commandInquiryPort: CommandInquiryPort, | ||
private val commandNotificationPort: CommandNotificationPort | ||
) : WriteInquiryRespondUseCase { | ||
override fun execute(id: Long, writeInquiryRespondDto: WriteInquiryRespondDto) { | ||
val user = userSecurityPort.currentUser() | ||
|
||
val inquiry = queryInquiryPort.findByIdOrNull(id) | ||
?: throw InquiryNotFoundException() | ||
|
||
commandInquiryPort.saveInquiry(inquiry.updateInquiryStatus(InquiryStatus.COMPLETE)) | ||
|
||
commandNotificationPort.saveNotification( | ||
Notification( | ||
id = 0L, | ||
answer = writeInquiryRespondDto.answer, | ||
user = user, | ||
inquiry = inquiry | ||
) | ||
) | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...o/domain/notification/adapter/output/persistence/CommandNotificationPersistenceAdapter.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.CommandNotificationPort | ||
import andreas311.miso.domain.notification.domain.Notification | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class CommandNotificationPersistenceAdapter( | ||
private val notificationMapper: NotificationMapper, | ||
private val notificationRepository: NotificationRepository | ||
) : CommandNotificationPort { | ||
override fun saveNotification(notification: Notification): Notification { | ||
val notificationEntity = notificationRepository.save(notificationMapper.toEntity(notification)) | ||
return notificationMapper.toDomain(notificationEntity)!! | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...dreas311/miso/domain/notification/adapter/output/persistence/entity/NotificationEntity.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,25 @@ | ||
package andreas311.miso.domain.notification.adapter.output.persistence.entity | ||
|
||
import andreas311.miso.domain.inquiry.adapter.output.persistence.entity.InquiryEntity | ||
import andreas311.miso.domain.user.adapter.output.persistence.entity.UserEntity | ||
import javax.persistence.* | ||
|
||
@Entity | ||
@Table(name = "notification") | ||
data class NotificationEntity( | ||
@Id | ||
@Column(name = "notification_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long, | ||
|
||
@Column(name = "answer", nullable = false) | ||
val answer: String, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "inquiry_id") | ||
val inquiry: InquiryEntity, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id") | ||
val user: UserEntity | ||
) |
31 changes: 31 additions & 0 deletions
31
...dreas311/miso/domain/notification/adapter/output/persistence/mapper/NotificationMapper.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,31 @@ | ||
package andreas311.miso.domain.notification.adapter.output.persistence.mapper | ||
|
||
import andreas311.miso.domain.inquiry.adapter.output.persistence.mapper.InquiryMapper | ||
import andreas311.miso.domain.notification.adapter.output.persistence.entity.NotificationEntity | ||
import andreas311.miso.domain.notification.domain.Notification | ||
import andreas311.miso.domain.user.adapter.output.persistence.mapper.UserMapper | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class NotificationMapper( | ||
private val userMapper: UserMapper, | ||
private val inquiryMapper: InquiryMapper | ||
) { | ||
infix fun toEntity(domain: Notification): NotificationEntity = | ||
NotificationEntity( | ||
id = domain.id, | ||
answer = domain.answer, | ||
user = userMapper.toEntity(domain.user), | ||
inquiry = inquiryMapper.toEntity(domain.inquiry) | ||
) | ||
|
||
infix fun toDomain(entity: NotificationEntity?): Notification? = | ||
entity?.let { | ||
Notification( | ||
id = entity.id, | ||
answer = entity.answer, | ||
user = userMapper.toDomain(entity.user)!!, | ||
inquiry = inquiryMapper.toDomain(entity.inquiry)!! | ||
) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
.../miso/domain/notification/adapter/output/persistence/repository/NotificationRepository.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.adapter.output.persistence.repository | ||
|
||
import andreas311.miso.domain.notification.adapter.output.persistence.entity.NotificationEntity | ||
import org.springframework.data.repository.CrudRepository | ||
|
||
interface NotificationRepository : CrudRepository<NotificationEntity, Long> |
7 changes: 7 additions & 0 deletions
7
...in/andreas311/miso/domain/notification/application/port/output/CommandNotificationPort.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 CommandNotificationPort { | ||
fun saveNotification(notification: Notification): Notification | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/andreas311/miso/domain/notification/domain/Notification.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.domain | ||
|
||
import andreas311.miso.domain.inquiry.domain.Inquiry | ||
import andreas311.miso.domain.user.domain.User | ||
|
||
data class Notification( | ||
val id: Long, | ||
val answer: String, | ||
val inquiry: Inquiry, | ||
val user: User | ||
) |