Skip to content

Commit

Permalink
Merge pull request #112 from soma-baekgu/develop
Browse files Browse the repository at this point in the history
V1.3 배포
  • Loading branch information
GGHDMS authored Sep 5, 2024
2 parents 4e8c84e + b3e0f66 commit 0a48034
Show file tree
Hide file tree
Showing 41 changed files with 984 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ChatRoomFacadeService(
val user: User = userService.getById(userId)
val workspace: Workspace = workspaceService.getById(workspaceId)

workspaceUserService.validUserInWorkspace(user, workspace)
workspaceUserService.validateUserWorkspaceInActive(user, workspace)

// 유저의 채팅방 목록 조회
val chatRoomMys: List<ChatRoomUser> = chatRoomUserService.findAllByUser(user)
Expand Down Expand Up @@ -86,7 +86,7 @@ class ChatRoomFacadeService(
): BriefChatRoomViewDto {
val user: User = userService.getById(userId)
val workspace: Workspace = workspaceService.getById(workspaceId)
workspaceUserService.validUserInWorkspace(user, workspace)
workspaceUserService.validateUserWorkspaceInActive(user, workspace)

val chatRooms: List<ChatRoom> = chatRoomService.findChatRoomsByWorkspaceId(workspaceId)
val chatRoomUserMap: Map<Long, List<ChatRoomUser>> =
Expand All @@ -111,7 +111,7 @@ class ChatRoomFacadeService(
): BriefChatRoomViewDto {
val user: User = userService.getById(userId)
val workspace: Workspace = workspaceService.getById(workspaceId)
workspaceUserService.validUserInWorkspace(user, workspace)
workspaceUserService.validateUserWorkspaceInActive(user, workspace)

val chatRooms: List<ChatRoom> = chatRoomService.findNotRegisteredChatRoomsByWorkspaceId(workspaceId, userId)
val chatRoomUserMap: Map<Long, List<ChatRoomUser>> =
Expand Down Expand Up @@ -154,7 +154,7 @@ class ChatRoomFacadeService(
): ChatRoomUser {
val user: User = userService.getById(userId)
val workspace: Workspace = workspaceService.getById(workspaceId)
workspaceUserService.validUserInWorkspace(user, workspace)
workspaceUserService.validateUserWorkspaceInActive(user, workspace)

val chatRoom = chatRoomService.getChatRoomByWorkspaceIdAndChatRoomId(workspaceId, chatRoomId)
chatRoomUserService.validateUserNotInChatRoom(user, chatRoom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package com.backgu.amaker.api.event.config

import com.backgu.amaker.application.event.service.EventAssignedUserService
import com.backgu.amaker.application.event.service.EventService
import com.backgu.amaker.application.event.service.ReactionEventService
import com.backgu.amaker.application.event.service.ReactionOptionService
import com.backgu.amaker.application.event.service.ReplyCommentService
import com.backgu.amaker.application.event.service.ReplyEventService
import com.backgu.amaker.infra.jpa.event.repository.EventAssignedUserRepository
import com.backgu.amaker.infra.jpa.event.repository.EventRepository
import com.backgu.amaker.infra.jpa.event.repository.ReactionEventRepository
import com.backgu.amaker.infra.jpa.event.repository.ReactionOptionRepository
import com.backgu.amaker.infra.jpa.event.repository.ReplyCommentRepository
import com.backgu.amaker.infra.jpa.event.repository.ReplyEventRepository
import org.springframework.context.annotation.Bean
Expand All @@ -26,4 +30,12 @@ class EventServiceConfig {

@Bean
fun eventService(eventRepository: EventRepository): EventService = EventService(eventRepository)

@Bean
fun reactionEventService(reactionEventRepository: ReactionEventRepository): ReactionEventService =
ReactionEventService(reactionEventRepository)

@Bean
fun reactionOptionService(reactionOptionRepository: ReactionOptionRepository): ReactionOptionService =
ReactionOptionService(reactionOptionRepository)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.backgu.amaker.api.event.controller

import com.backgu.amaker.api.event.dto.request.ReactionEventCreateRequest
import com.backgu.amaker.api.event.dto.request.ReplyEventCreateRequest
import com.backgu.amaker.api.event.dto.response.ReactionEventDetailResponse
import com.backgu.amaker.api.event.dto.response.ReplyEventDetailResponse
import com.backgu.amaker.api.event.service.EventFacadeService
import com.backgu.amaker.common.http.ApiHandler
Expand All @@ -23,6 +25,46 @@ class EventController(
private val eventFacadeService: EventFacadeService,
private val apiHandler: ApiHandler,
) : EventSwagger {
@GetMapping("/events/{event-id}/reply")
override fun getReplyEvent(
@AuthenticationPrincipal token: JwtAuthentication,
@PathVariable("chat-room-id") chatRoomId: Long,
@PathVariable("event-id") eventId: Long,
): ResponseEntity<ApiResult<ReplyEventDetailResponse>> =
ResponseEntity
.ok()
.body(
apiHandler.onSuccess(
ReplyEventDetailResponse.of(
eventFacadeService.getReplyEvent(
token.id,
chatRoomId,
eventId,
),
),
),
)

@GetMapping("/events/{event-id}/reaction")
override fun getReactionEvent(
@AuthenticationPrincipal token: JwtAuthentication,
@PathVariable("chat-room-id") chatRoomId: Long,
@PathVariable("event-id") eventId: Long,
): ResponseEntity<ApiResult<ReactionEventDetailResponse>> =
ResponseEntity
.ok()
.body(
apiHandler.onSuccess(
ReactionEventDetailResponse.of(
eventFacadeService.getReactionEvent(
token.id,
chatRoomId,
eventId,
),
),
),
)

@PostMapping("/events/reply")
override fun createReplyEvent(
@AuthenticationPrincipal token: JwtAuthentication,
Expand All @@ -44,23 +86,24 @@ class EventController(
).toUri(),
).build()

@GetMapping("/events/{event-id}/reply")
override fun getReplyEvent(
@PostMapping("/events/reaction")
override fun createReactionEvent(
@AuthenticationPrincipal token: JwtAuthentication,
@PathVariable("chat-room-id") chatRoomId: Long,
@PathVariable("event-id") eventId: Long,
): ResponseEntity<ApiResult<ReplyEventDetailResponse>> =
@RequestBody @Valid request: ReactionEventCreateRequest,
): ResponseEntity<Unit> =
ResponseEntity
.ok()
.body(
apiHandler.onSuccess(
ReplyEventDetailResponse.of(
eventFacadeService.getReplyEvent(
token.id,
chatRoomId,
eventId,
),
),
),
)
.created(
ServletUriComponentsBuilder
.fromCurrentContextPath()
.path("/api/v1/events/{id}/reply")
.buildAndExpand(
eventFacadeService
.createReactionEvent(
token.id,
chatRoomId,
request.toDto(),
).id,
).toUri(),
).build()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.backgu.amaker.api.event.controller

import com.backgu.amaker.api.event.dto.request.ReactionEventCreateRequest
import com.backgu.amaker.api.event.dto.request.ReplyEventCreateRequest
import com.backgu.amaker.api.event.dto.response.ReactionEventDetailResponse
import com.backgu.amaker.api.event.dto.response.ReplyEventDetailResponse
import com.backgu.amaker.common.http.response.ApiResult
import com.backgu.amaker.common.security.jwt.authentication.JwtAuthentication
Expand All @@ -12,10 +14,41 @@ import jakarta.validation.Valid
import org.springframework.http.ResponseEntity
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody

@Tag(name = "event", description = "이벤트 API")
interface EventSwagger {
@Operation(summary = "reply 이벤트 상세조회", description = "reply 이벤트 상세조회합니다.")
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "reply 이벤트 상세조회 성공",
),
],
)
fun getReplyEvent(
@AuthenticationPrincipal token: JwtAuthentication,
@PathVariable("chat-room-id") chatRoomId: Long,
@PathVariable("event-id") eventId: Long,
): ResponseEntity<ApiResult<ReplyEventDetailResponse>>

@Operation(summary = "reaction 이벤트 상세조회", description = "reaction 이벤트 상세조회합니다.")
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "reaction 이벤트 상세조회 성공",
),
],
)
fun getReactionEvent(
token: JwtAuthentication,
chatRoomId: Long,
eventId: Long,
): ResponseEntity<ApiResult<ReactionEventDetailResponse>>

@Operation(summary = "reply 이벤트 생성", description = "reply 이벤트 생성합니다.")
@ApiResponses(
value = [
Expand All @@ -31,18 +64,19 @@ interface EventSwagger {
@RequestBody @Valid request: ReplyEventCreateRequest,
): ResponseEntity<Unit>

@Operation(summary = "reply 이벤트 상세조회", description = "reply 이벤트 상세조회합니다.")
@Operation(summary = "reaction 이벤트 생성", description = "reaction 이벤트 생성합니다.")
@ApiResponses(
value = [
ApiResponse(
responseCode = "200",
description = "reply 이벤트 상세조회 성공",
responseCode = "201",
description = "reaction 이벤트 생성 성공",
),
],
)
fun getReplyEvent(
@AuthenticationPrincipal token: JwtAuthentication,
@PathVariable("chat-room-id") chatRoomId: Long,
@PathVariable("event-id") eventId: Long,
): ResponseEntity<ApiResult<ReplyEventDetailResponse>>
@PostMapping("/events/reaction")
fun createReactionEvent(
token: JwtAuthentication,
chatRoomId: Long,
request: ReactionEventCreateRequest,
): ResponseEntity<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.backgu.amaker.api.event.dto

import java.time.LocalDateTime

data class ReactionEventCreateDto(
val eventTitle: String,
val options: List<String>,
val assignees: List<String>,
val deadLine: LocalDateTime,
val notificationStartHour: Int,
val notificationStartMinute: Int,
val interval: Int,
)
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,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.backgu.amaker.api.event.dto

import com.backgu.amaker.domain.event.ReactionEvent
import com.backgu.amaker.domain.event.ReactionOption
import java.time.LocalDateTime

data class ReactionEventDto(
val id: Long,
val eventTitle: String,
val options: List<String>,
val deadLine: LocalDateTime,
val notificationStartTime: LocalDateTime,
val notificationInterval: Int,
) {
companion object {
fun of(
reactionEvent: ReactionEvent,
options: List<ReactionOption>,
) = ReactionEventDto(
id = reactionEvent.id,
eventTitle = reactionEvent.eventTitle,
options = options.map { it.content },
deadLine = reactionEvent.deadLine,
notificationStartTime = reactionEvent.notificationStartTime,
notificationInterval = reactionEvent.notificationInterval,
)
}
}
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,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.backgu.amaker.api.event.dto.request

import com.backgu.amaker.api.event.dto.ReactionEventCreateDto
import io.swagger.v3.oas.annotations.media.Schema
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Size
import org.springframework.format.annotation.DateTimeFormat
import java.time.LocalDateTime

data class ReactionEventCreateRequest(
@Schema(description = "제목", example = "제목 어때요?")
@field:NotBlank(message = "이벤트 제목을 입력해주세요.")
val eventTitle: String,
@Schema(description = "선택지", example = "[\"\", \"아니오\"]")
val options: List<String>,
@Schema(description = "답변을 요청할 인원", example = "[\"user1\", \"user2\"]")
@field:Size(min = 1, message = "최소 한 명 이상의 인원을 지정해야 합니다.")
val assignees: List<String>,
@Schema(description = "마감 기한", example = "2021-08-01T00:00:00")
@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
val deadLine: LocalDateTime,
@Schema(description = "알림 시작 시간", example = "1")
val notificationStartHour: Int,
@Schema(description = "알림 시작 분", example = "30")
val notificationStartMinute: Int,
@Schema(description = "알림 주기", example = "15")
val interval: Int,
) {
fun toDto() =
ReactionEventCreateDto(
eventTitle = eventTitle,
options = options,
assignees = assignees,
deadLine = deadLine,
notificationStartMinute = notificationStartMinute,
notificationStartHour = notificationStartHour,
interval = interval,
)
}
Loading

0 comments on commit 0a48034

Please sign in to comment.