-
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 #110 from soma-baekgu/feature/BG-392-get-reaction-…
…chat [BG-392]: reaction 채팅 상세 조회 기능 구현 (1.5h / 2h)
- Loading branch information
Showing
14 changed files
with
325 additions
and
2 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
38 changes: 38 additions & 0 deletions
38
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionEventDetailDto.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 com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.api.user.dto.UserDto | ||
import com.backgu.amaker.domain.event.ReactionEvent | ||
import com.backgu.amaker.domain.event.ReactionOption | ||
import java.time.LocalDateTime | ||
|
||
data class ReactionEventDetailDto( | ||
val id: Long, | ||
val eventTitle: String, | ||
val options: List<ReactionOptionDto>, | ||
val deadLine: LocalDateTime, | ||
val notificationStartTime: LocalDateTime, | ||
val notificationInterval: Int, | ||
val eventCreator: UserDto, | ||
val finishUser: List<UserDto>, | ||
val waitingUser: List<UserDto>, | ||
) { | ||
companion object { | ||
fun of( | ||
reactionEvent: ReactionEvent, | ||
reactionOptions: List<ReactionOption>, | ||
eventCreator: UserDto, | ||
finishUser: List<UserDto>, | ||
waitingUser: List<UserDto>, | ||
) = ReactionEventDetailDto( | ||
id = reactionEvent.id, | ||
eventTitle = reactionEvent.eventTitle, | ||
options = reactionOptions.map { ReactionOptionDto.of(it) }, | ||
deadLine = reactionEvent.deadLine, | ||
notificationStartTime = reactionEvent.notificationStartTime, | ||
notificationInterval = reactionEvent.notificationInterval, | ||
eventCreator = eventCreator, | ||
finishUser = finishUser, | ||
waitingUser = waitingUser, | ||
) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
api/src/main/kotlin/com/backgu/amaker/api/event/dto/ReactionOptionDto.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 com.backgu.amaker.api.event.dto | ||
|
||
import com.backgu.amaker.domain.event.ReactionOption | ||
|
||
data class ReactionOptionDto( | ||
val id: Long, | ||
val eventId: Long, | ||
val content: String, | ||
) { | ||
companion object { | ||
fun of(reactionOption: ReactionOption) = | ||
ReactionOptionDto( | ||
id = reactionOption.id, | ||
eventId = reactionOption.eventId, | ||
content = reactionOption.content, | ||
) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
api/src/main/kotlin/com/backgu/amaker/api/event/dto/response/ReactionEventDetailResponse.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,42 @@ | ||
package com.backgu.amaker.api.event.dto.response | ||
|
||
import com.backgu.amaker.api.event.dto.ReactionEventDetailDto | ||
import com.backgu.amaker.api.user.dto.response.UserResponse | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import java.time.LocalDateTime | ||
|
||
data class ReactionEventDetailResponse( | ||
@Schema(description = "이벤트 id", example = "1") | ||
val id: Long, | ||
@Schema(description = "이벤트 제목", example = "우리 어디서 만날지") | ||
val eventTitle: String, | ||
@Schema(description = "선택지") | ||
val options: List<ReactionOptionResponse>, | ||
@Schema(description = "데드라인", example = "2024-07-24T07:39:37.598") | ||
val deadLine: LocalDateTime, | ||
@Schema(description = "알림 보낼 시작 시간", example = "2024-07-24T06:09:37.598") | ||
val notificationStartTime: LocalDateTime, | ||
@Schema(description = "알림 주기", example = "15") | ||
val notificationInterval: Int, | ||
@Schema(description = "이벤트 생성자") | ||
val eventCreator: UserResponse, | ||
@Schema(description = "이벤트를 수행한 유저") | ||
val finishUser: List<UserResponse>, | ||
@Schema(description = "이벤트 수행 대기중인 유저") | ||
val waitingUser: List<UserResponse>, | ||
) { | ||
companion object { | ||
fun of(reactionEventDetailDto: ReactionEventDetailDto) = | ||
ReactionEventDetailResponse( | ||
id = reactionEventDetailDto.id, | ||
eventTitle = reactionEventDetailDto.eventTitle, | ||
options = reactionEventDetailDto.options.map { ReactionOptionResponse.of(it) }, | ||
deadLine = reactionEventDetailDto.deadLine, | ||
notificationStartTime = reactionEventDetailDto.notificationStartTime, | ||
notificationInterval = reactionEventDetailDto.notificationInterval, | ||
eventCreator = UserResponse.of(reactionEventDetailDto.eventCreator), | ||
finishUser = reactionEventDetailDto.finishUser.map { UserResponse.of(it) }, | ||
waitingUser = reactionEventDetailDto.waitingUser.map { UserResponse.of(it) }, | ||
) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/kotlin/com/backgu/amaker/api/event/dto/response/ReactionOptionResponse.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 com.backgu.amaker.api.event.dto.response | ||
|
||
import com.backgu.amaker.api.event.dto.ReactionOptionDto | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class ReactionOptionResponse( | ||
@Schema(description = "선택지 id", example = "1") | ||
val id: Long, | ||
@Schema(description = "이벤트 id", example = "1") | ||
val eventId: Long, | ||
@Schema(description = "내용", example = "옵션 1") | ||
val content: String, | ||
) { | ||
companion object { | ||
fun of(reactionOptionDto: ReactionOptionDto) = | ||
ReactionOptionResponse( | ||
id = reactionOptionDto.id, | ||
eventId = reactionOptionDto.eventId, | ||
content = reactionOptionDto.content, | ||
) | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
api/src/test/kotlin/com/backgu/amaker/api/fixture/ReactionEventFixture.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,30 @@ | ||
package com.backgu.amaker.api.fixture | ||
|
||
import com.backgu.amaker.domain.event.ReactionEvent | ||
import com.backgu.amaker.infra.jpa.event.entity.ReactionEventEntity | ||
import com.backgu.amaker.infra.jpa.event.repository.ReactionEventRepository | ||
import org.springframework.stereotype.Component | ||
import java.time.LocalDateTime | ||
|
||
@Component | ||
class ReactionEventFixture( | ||
val reactionEventRepository: ReactionEventRepository, | ||
) { | ||
fun createPersistedReactionEvent( | ||
id: Long, | ||
eventTitle: String = "$id 번째 이벤트", | ||
deadLine: LocalDateTime = LocalDateTime.now(), | ||
notificationStartTime: LocalDateTime = LocalDateTime.now(), | ||
notificationInterval: Int = id.toInt(), | ||
): ReactionEvent = | ||
reactionEventRepository | ||
.save( | ||
ReactionEventEntity( | ||
id = id, | ||
eventTitle = eventTitle, | ||
deadLine = deadLine, | ||
notificationStartTime = notificationStartTime, | ||
notificationInterval = notificationInterval, | ||
), | ||
).toDomain() | ||
} |
25 changes: 25 additions & 0 deletions
25
api/src/test/kotlin/com/backgu/amaker/api/fixture/ReactionOptionFixture.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.ReactionOption | ||
import com.backgu.amaker.infra.jpa.event.entity.ReactionOptionEntity | ||
import com.backgu.amaker.infra.jpa.event.repository.ReactionOptionRepository | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ReactionOptionFixture( | ||
val reactionOptionRepository: ReactionOptionRepository, | ||
) { | ||
fun createPersistedReactionOptions( | ||
eventId: Long, | ||
options: List<String> = listOf("옵션1", "옵션2", "옵션3"), | ||
): List<ReactionOption> = | ||
reactionOptionRepository | ||
.saveAll( | ||
options.map { | ||
ReactionOptionEntity( | ||
eventId = eventId, | ||
content = it, | ||
) | ||
}, | ||
).map { it.toDomain() } | ||
} |
Oops, something went wrong.