-
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 #111 from soma-baekgu/feature/BG-244-reaction-comm…
…ent-create [BG-244]: 리엑션 이벤트에 대한 응답 등록 API를 개발한다 (2h / 3h)
- Loading branch information
Showing
21 changed files
with
389 additions
and
17 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
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
5 changes: 5 additions & 0 deletions
5
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionCommentCreateDto.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 com.backgu.amaker.api.event.dto | ||
|
||
data class ReactionCommentCreateDto( | ||
val optionId: Long, | ||
) |
25 changes: 25 additions & 0 deletions
25
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionCommentDto.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 com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.domain.event.ReactionComment | ||
import java.time.LocalDateTime | ||
|
||
data class ReactionCommentDto( | ||
val id: Long, | ||
val userId: String, | ||
val eventId: Long, | ||
val optionId: Long, | ||
val createdAt: LocalDateTime = LocalDateTime.now(), | ||
val updatedAt: LocalDateTime = LocalDateTime.now(), | ||
) { | ||
companion object { | ||
fun of(reactionComment: ReactionComment) = | ||
ReactionCommentDto( | ||
id = reactionComment.id, | ||
userId = reactionComment.userId, | ||
eventId = reactionComment.eventId, | ||
optionId = reactionComment.optionId, | ||
createdAt = reactionComment.createdAt, | ||
updatedAt = reactionComment.updatedAt, | ||
) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
api/src/main/kotlin/com/backgu/amaker/api/event/dto/request/ReactionCommentCreateRequest.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,14 @@ | ||
package com.backgu.amaker.api.event.dto.request | ||
|
||
import com.backgu.amaker.api.event.dto.ReactionCommentCreateDto | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class ReactionCommentCreateRequest( | ||
@Schema(description = "option id", example = "1") | ||
val optionId: Long, | ||
) { | ||
fun toDto() = | ||
ReactionCommentCreateDto( | ||
optionId = optionId, | ||
) | ||
} |
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
1 change: 1 addition & 0 deletions
1
api/src/test/kotlin/com/backgu/amaker/api/fixture/ChatRoomFacadeFixture.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
25 changes: 25 additions & 0 deletions
25
api/src/test/kotlin/com/backgu/amaker/api/fixture/ReactionCommentFixture.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 com.backgu.amaker.api.fixture | ||
|
||
import com.backgu.amaker.domain.event.ReactionComment | ||
import com.backgu.amaker.infra.jpa.event.entity.ReactionCommentEntity | ||
import com.backgu.amaker.infra.jpa.event.repository.ReactionCommentRepository | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ReactionCommentFixture( | ||
val reactionCommentRepository: ReactionCommentRepository, | ||
) { | ||
fun createPersistedReactionComment( | ||
userId: String, | ||
eventId: Long, | ||
optionId: Long, | ||
): ReactionComment = | ||
reactionCommentRepository | ||
.save( | ||
ReactionCommentEntity( | ||
userId = userId, | ||
eventId = eventId, | ||
optionId = optionId, | ||
), | ||
).toDomain() | ||
} |
35 changes: 35 additions & 0 deletions
35
api/src/test/kotlin/com/backgu/amaker/api/fixture/ReactionCommentFixtureFacade.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,35 @@ | ||
package com.backgu.amaker.api.fixture | ||
|
||
import com.backgu.amaker.api.fixture.dto.ReactionCommentFixtureDto | ||
import com.backgu.amaker.domain.chat.ChatRoomType | ||
import com.backgu.amaker.domain.chat.ChatType | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ReactionCommentFixtureFacade( | ||
val reactionCommentFixture: ReactionCommentFixture, | ||
val reactionEventFixture: ReactionEventFixture, | ||
val reactionOptionFixture: ReactionOptionFixture, | ||
val chatRoomFixture: ChatRoomFixture, | ||
val chatFixture: ChatFixture, | ||
val eventAssignedUserFixture: EventAssignedUserFixture, | ||
val userFixture: UserFixture, | ||
private val workspaceFixture: WorkspaceFixture, | ||
private val workspaceUserFixture: WorkspaceUserFixture, | ||
) { | ||
fun setUp( | ||
userId: String = "test-user-id", | ||
name: String = "김리더", | ||
workspaceId: Long = 1L, | ||
): ReactionCommentFixtureDto { | ||
val workspace = workspaceFixture.createPersistedWorkspace(workspaceId, "test-workspace") | ||
workspaceUserFixture.createPersistedWorkspaceUser(workspace.id, userId) | ||
userFixture.createPersistedUser(id = userId, name = name) | ||
val chatRoom = chatRoomFixture.createPersistedChatRoom(workspace.id, ChatRoomType.DEFAULT) | ||
val chat = chatFixture.createPersistedChat(chatRoom.id, userId, chatType = ChatType.REPLY) | ||
val reactionEvent = reactionEventFixture.createPersistedReactionEvent(chat.id) | ||
val options = reactionOptionFixture.createPersistedReactionOptions(reactionEvent.id) | ||
eventAssignedUserFixture.createPersistedEventAssignedUser(userId, reactionEvent.id) | ||
return ReactionCommentFixtureDto(reactionEvent, options) | ||
} | ||
} |
Oops, something went wrong.