-
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 #124 from soma-baekgu/feature/BG-415-retrieve-reac…
…tion-event-comment [BG-415]: 리액션 이벤트 응답 조회 (3h / 3h)
- Loading branch information
Showing
9 changed files
with
175 additions
and
0 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
27 changes: 27 additions & 0 deletions
27
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionCommentWithUserDto.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,27 @@ | ||
package com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.api.user.dto.UserDto | ||
import com.backgu.amaker.domain.event.ReactionComment | ||
import com.backgu.amaker.domain.user.User | ||
import java.time.LocalDateTime | ||
|
||
data class ReactionCommentWithUserDto( | ||
val id: Long, | ||
val eventId: Long, | ||
val createdAt: LocalDateTime = LocalDateTime.now(), | ||
val updatedAt: LocalDateTime = LocalDateTime.now(), | ||
val userDto: UserDto, | ||
) { | ||
companion object { | ||
fun of( | ||
reactionComment: ReactionComment, | ||
user: User, | ||
) = ReactionCommentWithUserDto( | ||
id = reactionComment.id, | ||
eventId = reactionComment.eventId, | ||
createdAt = reactionComment.createdAt, | ||
updatedAt = reactionComment.updatedAt, | ||
userDto = UserDto.of(user), | ||
) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionOptionWithCommentDto.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,33 @@ | ||
package com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.common.exception.BusinessException | ||
import com.backgu.amaker.common.status.StatusCode | ||
import com.backgu.amaker.domain.event.ReactionComment | ||
import com.backgu.amaker.domain.event.ReactionOption | ||
import com.backgu.amaker.domain.user.User | ||
|
||
data class ReactionOptionWithCommentDto( | ||
val id: Long, | ||
val eventId: Long, | ||
val content: String, | ||
val comments: List<ReactionCommentWithUserDto>, | ||
) { | ||
companion object { | ||
fun of( | ||
reactionOption: ReactionOption, | ||
reactionComment: List<ReactionComment>, | ||
userMap: Map<String, User>, | ||
) = ReactionOptionWithCommentDto( | ||
id = reactionOption.id, | ||
eventId = reactionOption.eventId, | ||
content = reactionOption.content, | ||
comments = | ||
reactionComment.map { | ||
ReactionCommentWithUserDto.of( | ||
it, | ||
userMap[it.userId] ?: throw BusinessException(StatusCode.USER_NOT_FOUND), | ||
) | ||
}, | ||
) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...c/main/kotlin/com/backgu/amaker/api/event/dto/response/ReactionCommentWithUserResponse.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,26 @@ | ||
package com.backgu.amaker.api.event.dto.response | ||
|
||
import com.backgu.amaker.api.event.dto.ReactionCommentWithUserDto | ||
import com.backgu.amaker.api.user.dto.response.UserResponse | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDateTime | ||
|
||
data class ReactionCommentWithUserResponse( | ||
@Schema(description = "리액션 응답 id", example = "1") | ||
val id: Long, | ||
@Schema(description = "생성 시간", example = "2024-07-02T19:56:05.624+09:00") | ||
val createdAt: LocalDateTime = LocalDateTime.now(), | ||
@Schema(description = "수정 시간", example = "2024-07-02T19:56:05.624+09:00") | ||
val updatedAt: LocalDateTime = LocalDateTime.now(), | ||
val userDto: UserResponse, | ||
) { | ||
companion object { | ||
fun of(reactionComment: ReactionCommentWithUserDto) = | ||
ReactionCommentWithUserResponse( | ||
id = reactionComment.id, | ||
createdAt = reactionComment.createdAt, | ||
updatedAt = reactionComment.updatedAt, | ||
userDto = UserResponse.of(reactionComment.userDto), | ||
) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...main/kotlin/com/backgu/amaker/api/event/dto/response/ReactionOptionWithCommentResponse.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,24 @@ | ||
package com.backgu.amaker.api.event.dto.response | ||
|
||
import com.backgu.amaker.api.event.dto.ReactionOptionWithCommentDto | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class ReactionOptionWithCommentResponse( | ||
@Schema(description = "리액션 응답 옵션 id", example = "1") | ||
val id: Long, | ||
@Schema(description = "이벤트 id", example = "2") | ||
val eventId: Long, | ||
@Schema(description = "응답 내용", example = "좋네용!") | ||
val content: String, | ||
val comments: List<ReactionCommentWithUserResponse>, | ||
) { | ||
companion object { | ||
fun of(reactionOptionWithComment: ReactionOptionWithCommentDto) = | ||
ReactionOptionWithCommentResponse( | ||
id = reactionOptionWithComment.id, | ||
eventId = reactionOptionWithComment.eventId, | ||
content = reactionOptionWithComment.content, | ||
comments = reactionOptionWithComment.comments.map { ReactionCommentWithUserResponse.of(it) }, | ||
) | ||
} | ||
} |
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