Skip to content

Commit ec49509

Browse files
authored
Merge pull request #128 from soma-baekgu/develop
main 배포
2 parents 0284aba + 63df001 commit ec49509

27 files changed

+729
-2
lines changed

api/src/main/kotlin/com/backgu/amaker/api/event/config/EventServiceConfig.kt

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.backgu.amaker.application.event.service.ReactionEventService
77
import com.backgu.amaker.application.event.service.ReactionOptionService
88
import com.backgu.amaker.application.event.service.ReplyCommentService
99
import com.backgu.amaker.application.event.service.ReplyEventService
10+
import com.backgu.amaker.application.event.service.TaskCommentService
1011
import com.backgu.amaker.application.event.service.TaskEventService
1112
import com.backgu.amaker.infra.jpa.event.repository.EventAssignedUserRepository
1213
import com.backgu.amaker.infra.jpa.event.repository.EventRepository
@@ -15,6 +16,7 @@ import com.backgu.amaker.infra.jpa.event.repository.ReactionEventRepository
1516
import com.backgu.amaker.infra.jpa.event.repository.ReactionOptionRepository
1617
import com.backgu.amaker.infra.jpa.event.repository.ReplyCommentRepository
1718
import com.backgu.amaker.infra.jpa.event.repository.ReplyEventRepository
19+
import com.backgu.amaker.infra.jpa.event.repository.TaskCommentRepository
1820
import com.backgu.amaker.infra.jpa.event.repository.TaskEventRepository
1921
import org.springframework.context.annotation.Bean
2022
import org.springframework.context.annotation.Configuration
@@ -49,4 +51,7 @@ class EventServiceConfig {
4951

5052
@Bean
5153
fun taskEventService(taskEventRepository: TaskEventRepository): TaskEventService = TaskEventService(taskEventRepository)
54+
55+
@Bean
56+
fun taskCommentService(taskCommentRepository: TaskCommentRepository): TaskCommentService = TaskCommentService(taskCommentRepository)
5257
}

api/src/main/kotlin/com/backgu/amaker/api/event/controller/EventCommentController.kt

+53
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package com.backgu.amaker.api.event.controller
22

33
import com.backgu.amaker.api.event.dto.query.ReplyQueryRequest
4+
import com.backgu.amaker.api.event.dto.query.TaskQueryRequest
45
import com.backgu.amaker.api.event.dto.request.ReactionCommentCreateRequest
56
import com.backgu.amaker.api.event.dto.request.ReplyCommentCreateRequest
7+
import com.backgu.amaker.api.event.dto.request.TaskCommentCreateRequest
8+
import com.backgu.amaker.api.event.dto.response.ReactionOptionWithCommentResponse
69
import com.backgu.amaker.api.event.dto.response.ReplyCommentWithUserResponse
710
import com.backgu.amaker.api.event.dto.response.ReplyCommentsViewResponse
11+
import com.backgu.amaker.api.event.dto.response.TaskCommentWithUserResponse
12+
import com.backgu.amaker.api.event.dto.response.TaskCommentsViewResponse
813
import com.backgu.amaker.api.event.service.EventCommentFacadeService
914
import com.backgu.amaker.common.http.ApiHandler
1015
import com.backgu.amaker.common.http.response.ApiResult
@@ -55,6 +60,44 @@ class EventCommentController(
5560
)
5661
}
5762

63+
@GetMapping("/events/{event-id}/task/comments")
64+
override fun findTaskComments(
65+
@AuthenticationPrincipal token: JwtAuthentication,
66+
@PathVariable("event-id") eventId: Long,
67+
@ModelAttribute taskQueryRequest: TaskQueryRequest,
68+
): ResponseEntity<ApiResult<PageResponse<TaskCommentWithUserResponse>>> {
69+
val pageable =
70+
PageRequest.of(
71+
taskQueryRequest.page,
72+
taskQueryRequest.size,
73+
Sort.by("id").ascending(),
74+
)
75+
return ResponseEntity.ok(
76+
apiHandler.onSuccess(
77+
TaskCommentsViewResponse.of(
78+
eventCommentFacadeService.findTaskComments(
79+
token.id,
80+
eventId,
81+
pageable,
82+
),
83+
),
84+
),
85+
)
86+
}
87+
88+
@GetMapping("/events/{event-id}/reaction/comments")
89+
override fun findReactionComments(
90+
@AuthenticationPrincipal token: JwtAuthentication,
91+
@PathVariable("event-id") eventId: Long,
92+
): ResponseEntity<ApiResult<List<ReactionOptionWithCommentResponse>>> =
93+
ResponseEntity.ok(
94+
apiHandler.onSuccess(
95+
eventCommentFacadeService
96+
.findReactionComment(token.id, eventId)
97+
.map { ReactionOptionWithCommentResponse.of(it) },
98+
),
99+
)
100+
58101
@PostMapping("/events/{event-id}/reply/comments")
59102
override fun createReplyComment(
60103
@AuthenticationPrincipal token: JwtAuthentication,
@@ -74,4 +117,14 @@ class EventCommentController(
74117
eventCommentFacadeService.createReactionComment(token.id, eventId, reactionCommentCreateRequest.toDto())
75118
return ResponseEntity.status(HttpStatus.CREATED).build()
76119
}
120+
121+
@PostMapping("/events/{event-id}/task/comments")
122+
override fun createTaskComment(
123+
@AuthenticationPrincipal token: JwtAuthentication,
124+
@PathVariable("event-id") eventId: Long,
125+
@RequestBody @Valid taskCommentCreateRequest: TaskCommentCreateRequest,
126+
): ResponseEntity<Unit> {
127+
eventCommentFacadeService.createTaskComment(token.id, eventId, taskCommentCreateRequest.toDto())
128+
return ResponseEntity.status(HttpStatus.CREATED).build()
129+
}
77130
}

api/src/main/kotlin/com/backgu/amaker/api/event/controller/EventCommentSwagger.kt

+51
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.backgu.amaker.api.event.controller
22

33
import com.backgu.amaker.api.event.dto.query.ReplyQueryRequest
4+
import com.backgu.amaker.api.event.dto.query.TaskQueryRequest
45
import com.backgu.amaker.api.event.dto.request.ReactionCommentCreateRequest
56
import com.backgu.amaker.api.event.dto.request.ReplyCommentCreateRequest
7+
import com.backgu.amaker.api.event.dto.request.TaskCommentCreateRequest
8+
import com.backgu.amaker.api.event.dto.response.ReactionOptionWithCommentResponse
69
import com.backgu.amaker.api.event.dto.response.ReplyCommentWithUserResponse
10+
import com.backgu.amaker.api.event.dto.response.TaskCommentWithUserResponse
711
import com.backgu.amaker.common.http.response.ApiResult
812
import com.backgu.amaker.common.http.response.PageResponse
913
import com.backgu.amaker.common.security.jwt.authentication.JwtAuthentication
@@ -12,6 +16,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
1216
import io.swagger.v3.oas.annotations.responses.ApiResponses
1317
import io.swagger.v3.oas.annotations.tags.Tag
1418
import org.springframework.http.ResponseEntity
19+
import org.springframework.security.core.annotation.AuthenticationPrincipal
20+
import org.springframework.web.bind.annotation.ModelAttribute
21+
import org.springframework.web.bind.annotation.PathVariable
1522

1623
@Tag(name = "eventComment", description = "이벤트 응답 API")
1724
interface EventCommentSwagger {
@@ -30,6 +37,35 @@ interface EventCommentSwagger {
3037
replyQueryRequest: ReplyQueryRequest,
3138
): ResponseEntity<ApiResult<PageResponse<ReplyCommentWithUserResponse>>>
3239

40+
@Operation(summary = "task 이벤트 응답 조회", description = "task 이벤트 응답 조회합니다.")
41+
@ApiResponses(
42+
value = [
43+
ApiResponse(
44+
responseCode = "200",
45+
description = "task 이벤트 응답 조회 성공",
46+
),
47+
],
48+
)
49+
fun findTaskComments(
50+
@AuthenticationPrincipal token: JwtAuthentication,
51+
@PathVariable("event-id") eventId: Long,
52+
@ModelAttribute taskQueryRequest: TaskQueryRequest,
53+
): ResponseEntity<ApiResult<PageResponse<TaskCommentWithUserResponse>>>
54+
55+
@Operation(summary = "reaction 이벤트 응답 조회", description = "reaction 이벤트 응답 조회합니다.")
56+
@ApiResponses(
57+
value = [
58+
ApiResponse(
59+
responseCode = "200",
60+
description = "reaction 이벤트 응답 조회 성공",
61+
),
62+
],
63+
)
64+
fun findReactionComments(
65+
@AuthenticationPrincipal token: JwtAuthentication,
66+
@PathVariable("event-id") eventId: Long,
67+
): ResponseEntity<ApiResult<List<ReactionOptionWithCommentResponse>>>
68+
3369
@Operation(summary = "reply 이벤트 응답 생성", description = "reply 이벤트 응답 생성합니다.")
3470
@ApiResponses(
3571
value = [
@@ -45,6 +81,21 @@ interface EventCommentSwagger {
4581
replyCommentCreateRequest: ReplyCommentCreateRequest,
4682
): ResponseEntity<Unit>
4783

84+
@Operation(summary = "task 이벤트 응답 생성", description = "task 이벤트 응답 생성합니다.")
85+
@ApiResponses(
86+
value = [
87+
ApiResponse(
88+
responseCode = "201",
89+
description = "task 이벤트 응답 생성 성공",
90+
),
91+
],
92+
)
93+
fun createTaskComment(
94+
token: JwtAuthentication,
95+
eventId: Long,
96+
taskCommentCreateRequest: TaskCommentCreateRequest,
97+
): ResponseEntity<Unit>
98+
4899
@Operation(summary = "reaction 이벤트 응답 생성", description = "reaction 이벤트 응답 생성합니다.")
49100
@ApiResponses(
50101
value = [

api/src/main/kotlin/com/backgu/amaker/api/event/controller/EventController.kt

+21
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.backgu.amaker.api.event.dto.request.ReplyEventCreateRequest
55
import com.backgu.amaker.api.event.dto.request.TaskEventCreateRequest
66
import com.backgu.amaker.api.event.dto.response.ReactionEventDetailResponse
77
import com.backgu.amaker.api.event.dto.response.ReplyEventDetailResponse
8+
import com.backgu.amaker.api.event.dto.response.TaskEventDetailResponse
89
import com.backgu.amaker.api.event.service.EventFacadeService
910
import com.backgu.amaker.common.http.ApiHandler
1011
import com.backgu.amaker.common.http.response.ApiResult
@@ -66,6 +67,26 @@ class EventController(
6667
),
6768
)
6869

70+
@GetMapping("/events/{event-id}/task")
71+
override fun geTaskEvent(
72+
@AuthenticationPrincipal token: JwtAuthentication,
73+
@PathVariable("chat-room-id") chatRoomId: Long,
74+
@PathVariable("event-id") eventId: Long,
75+
): ResponseEntity<ApiResult<TaskEventDetailResponse>> =
76+
ResponseEntity
77+
.ok()
78+
.body(
79+
apiHandler.onSuccess(
80+
TaskEventDetailResponse.of(
81+
eventFacadeService.getTaskEvent(
82+
token.id,
83+
chatRoomId,
84+
eventId,
85+
),
86+
),
87+
),
88+
)
89+
6990
@PostMapping("/events/reply")
7091
override fun createReplyEvent(
7192
@AuthenticationPrincipal token: JwtAuthentication,

api/src/main/kotlin/com/backgu/amaker/api/event/controller/EventSwagger.kt

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.backgu.amaker.api.event.dto.request.ReplyEventCreateRequest
55
import com.backgu.amaker.api.event.dto.request.TaskEventCreateRequest
66
import com.backgu.amaker.api.event.dto.response.ReactionEventDetailResponse
77
import com.backgu.amaker.api.event.dto.response.ReplyEventDetailResponse
8+
import com.backgu.amaker.api.event.dto.response.TaskEventDetailResponse
89
import com.backgu.amaker.common.http.response.ApiResult
910
import com.backgu.amaker.common.security.jwt.authentication.JwtAuthentication
1011
import io.swagger.v3.oas.annotations.Operation
@@ -49,6 +50,21 @@ interface EventSwagger {
4950
eventId: Long,
5051
): ResponseEntity<ApiResult<ReactionEventDetailResponse>>
5152

53+
@Operation(summary = "task 이벤트 상세조회", description = "task 이벤트 상세조회합니다.")
54+
@ApiResponses(
55+
value = [
56+
ApiResponse(
57+
responseCode = "200",
58+
description = "task 이벤트 상세조회 성공",
59+
),
60+
],
61+
)
62+
fun geTaskEvent(
63+
@AuthenticationPrincipal token: JwtAuthentication,
64+
@PathVariable("chat-room-id") chatRoomId: Long,
65+
@PathVariable("event-id") eventId: Long,
66+
): ResponseEntity<ApiResult<TaskEventDetailResponse>>
67+
5268
@Operation(summary = "reply 이벤트 생성", description = "reply 이벤트 생성합니다.")
5369
@ApiResponses(
5470
value = [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.backgu.amaker.api.event.dto
2+
3+
import com.backgu.amaker.api.user.dto.UserDto
4+
import com.backgu.amaker.domain.event.ReactionComment
5+
import com.backgu.amaker.domain.user.User
6+
import java.time.LocalDateTime
7+
8+
data class ReactionCommentWithUserDto(
9+
val id: Long,
10+
val eventId: Long,
11+
val createdAt: LocalDateTime = LocalDateTime.now(),
12+
val updatedAt: LocalDateTime = LocalDateTime.now(),
13+
val userDto: UserDto,
14+
) {
15+
companion object {
16+
fun of(
17+
reactionComment: ReactionComment,
18+
user: User,
19+
) = ReactionCommentWithUserDto(
20+
id = reactionComment.id,
21+
eventId = reactionComment.eventId,
22+
createdAt = reactionComment.createdAt,
23+
updatedAt = reactionComment.updatedAt,
24+
userDto = UserDto.of(user),
25+
)
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.backgu.amaker.api.event.dto
2+
3+
import com.backgu.amaker.common.exception.BusinessException
4+
import com.backgu.amaker.common.status.StatusCode
5+
import com.backgu.amaker.domain.event.ReactionComment
6+
import com.backgu.amaker.domain.event.ReactionOption
7+
import com.backgu.amaker.domain.user.User
8+
9+
data class ReactionOptionWithCommentDto(
10+
val id: Long,
11+
val eventId: Long,
12+
val content: String,
13+
val comments: List<ReactionCommentWithUserDto>,
14+
) {
15+
companion object {
16+
fun of(
17+
reactionOption: ReactionOption,
18+
reactionComment: List<ReactionComment>,
19+
userMap: Map<String, User>,
20+
) = ReactionOptionWithCommentDto(
21+
id = reactionOption.id,
22+
eventId = reactionOption.eventId,
23+
content = reactionOption.content,
24+
comments =
25+
reactionComment.map {
26+
ReactionCommentWithUserDto.of(
27+
it,
28+
userMap[it.userId] ?: throw BusinessException(StatusCode.USER_NOT_FOUND),
29+
)
30+
},
31+
)
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.backgu.amaker.api.event.dto
2+
3+
data class TaskCommentCreateDto(
4+
val path: String,
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.backgu.amaker.api.event.dto
2+
3+
import com.backgu.amaker.domain.event.TaskComment
4+
import java.time.LocalDateTime
5+
6+
data class TaskCommentDto(
7+
val id: Long,
8+
val userId: String,
9+
val eventId: Long,
10+
val path: String,
11+
val createdAt: LocalDateTime = LocalDateTime.now(),
12+
val updatedAt: LocalDateTime = LocalDateTime.now(),
13+
) {
14+
companion object {
15+
fun of(taskComment: TaskComment) =
16+
TaskCommentDto(
17+
id = taskComment.id,
18+
userId = taskComment.userId,
19+
eventId = taskComment.eventId,
20+
path = taskComment.path,
21+
createdAt = taskComment.createdAt,
22+
updatedAt = taskComment.updatedAt,
23+
)
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.backgu.amaker.api.event.dto
2+
3+
import com.backgu.amaker.api.user.dto.UserDto
4+
import com.backgu.amaker.domain.event.TaskComment
5+
import com.backgu.amaker.domain.user.User
6+
import java.time.LocalDateTime
7+
8+
data class TaskCommentWithUserDto(
9+
val id: Long,
10+
val userId: String,
11+
val eventId: Long,
12+
val path: String,
13+
val createdAt: LocalDateTime = LocalDateTime.now(),
14+
val updatedAt: LocalDateTime = LocalDateTime.now(),
15+
val userDto: UserDto,
16+
) {
17+
companion object {
18+
fun of(
19+
replyComment: TaskComment,
20+
user: User,
21+
) = TaskCommentWithUserDto(
22+
id = replyComment.id,
23+
userId = replyComment.userId,
24+
eventId = replyComment.eventId,
25+
path = replyComment.path,
26+
createdAt = replyComment.createdAt,
27+
updatedAt = replyComment.updatedAt,
28+
userDto = UserDto.of(user),
29+
)
30+
}
31+
}

0 commit comments

Comments
 (0)