Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
[WEAV-000] MeetingDomain ApplicationService, UseCase 네이밍 변경 (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterfogSW authored Apr 20, 2024
1 parent 0285197 commit ca13952
Show file tree
Hide file tree
Showing 35 changed files with 221 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.port.inbound

import java.util.*

fun interface CancelAllMeetingUseCase {
fun interface CancelAllMeeting {

fun invoke(command: Command)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.studentcenter.weave.application.meeting.port.inbound

fun interface CancelEndedPendingMeetingUseCase {
fun interface CancelEndedPendingMeeting {

fun invoke()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.studentcenter.weave.application.meeting.port.inbound
import com.studentcenter.weave.domain.meeting.entity.Meeting
import java.util.*

fun interface FindMyRequestMeetingByReceivingTeamIdUseCase {
fun interface FindMyRequestMeetingByReceivingTeamId {

fun invoke(receivingTeamId: UUID) : Meeting?
fun invoke(receivingTeamId: UUID): Meeting?

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.studentcenter.weave.application.meeting.port.inbound
import com.studentcenter.weave.application.meetingTeam.vo.MemberInfo
import java.util.*

fun interface GetAllOtherTeamMemberInfoUseCase {
fun interface GetAllOtherTeamMemberInfo {

fun invoke(meetingId: UUID) : List<MemberInfo>
fun invoke(meetingId: UUID): List<MemberInfo>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.studentcenter.weave.application.meeting.port.inbound
import com.studentcenter.weave.domain.meeting.entity.MeetingAttendance
import java.util.*

fun interface GetMeetingAttendancesUseCase {
fun interface GetMeetingAttendances {

fun invoke(meetingId: UUID) : List<MeetingAttendance>
fun invoke(meetingId: UUID): List<MeetingAttendance>

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.port.inbound

import java.util.*

fun interface MeetingRequestUseCase {
fun interface RequestMeeting {

fun invoke(command: Command)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import com.studentcenter.weave.domain.meeting.enums.TeamType
import com.studentcenter.weave.support.common.dto.ScrollResponse
import java.util.*

fun interface ScrollPendingMeetingUseCase {
fun interface ScrollPendingMeeting {

fun invoke(command: Command) :Result
fun invoke(query: Query): Result

data class Command(
data class Query(
val teamType: TeamType,
val next: UUID?,
val limit: Int,
)

data class Result(
override val items: List<PendingMeetingInfo>,
override val next: UUID?
override val next: UUID?,
) : ScrollResponse<PendingMeetingInfo, UUID?>(
items = items,
next = next,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import com.studentcenter.weave.support.common.dto.ScrollRequest
import com.studentcenter.weave.support.common.dto.ScrollResponse
import java.util.*

fun interface ScrollPreparedMeetingUseCase {
fun interface ScrollPreparedMeeting {

fun invoke(command: Command) :Result
fun invoke(query: Query): Result

data class Command(
data class Query(
override val next: UUID?,
override val limit: Int,
) : ScrollRequest<UUID?>(next, limit)

data class Result(
override val items: List<PreparedMeetingInfo>,
override val next: UUID?
override val next: UUID?,
) : ScrollResponse<PreparedMeetingInfo, UUID?>(
items = items,
next = next,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.meeting.port.inbound.CancelAllMeetingUseCase
import com.studentcenter.weave.application.meeting.port.inbound.CancelAllMeeting
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class CancelAllMeetingApplicationService(
class CancelAllMeetingService(
private val meetingDomainService: MeetingDomainService,
) : CancelAllMeetingUseCase {
) : CancelAllMeeting {

@Transactional
override fun invoke(command: CancelAllMeetingUseCase.Command) {
override fun invoke(command: CancelAllMeeting.Command) {
meetingDomainService.cancelAllNotFinishedMeetingByTeamId(command.teamId)
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.meeting.port.inbound.CancelEndedPendingMeetingUseCase
import com.studentcenter.weave.application.meeting.port.inbound.CancelEndedPendingMeeting
import com.studentcenter.weave.application.meeting.port.outbound.MeetingRepository
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
@Transactional
class CancelEndedPendingMeetingApplicationService(
class CancelEndedPendingMeetingService(
private val meetingRepository: MeetingRepository,
) : CancelEndedPendingMeetingUseCase {
) : CancelEndedPendingMeeting {

override fun invoke() {
meetingRepository.cancelEndedPendingMeeting()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.common.exception.MeetingExceptionType
import com.studentcenter.weave.application.common.security.context.getCurrentUserAuthentication
import com.studentcenter.weave.application.meeting.port.inbound.FindMyRequestMeetingByReceivingTeamIdUseCase
import com.studentcenter.weave.application.meeting.port.inbound.FindMyRequestMeetingByReceivingTeamId
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import com.studentcenter.weave.application.meetingTeam.port.inbound.GetMeetingTeam
import com.studentcenter.weave.domain.meeting.entity.Meeting
Expand All @@ -11,10 +11,10 @@ import org.springframework.stereotype.Service
import java.util.*

@Service
class FindMyRequestMeetingByReceivingTeamIdApplicationService(
class FindMyRequestMeetingByReceivingTeamIdService(
private val meetingDomainService: MeetingDomainService,
private val getMeetingTeam: GetMeetingTeam,
) : FindMyRequestMeetingByReceivingTeamIdUseCase {
) : FindMyRequestMeetingByReceivingTeamId {

override fun invoke(receivingTeamId: UUID): Meeting? {
val userId = getCurrentUserAuthentication().userId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.common.exception.MeetingExceptionType
import com.studentcenter.weave.application.common.security.context.getCurrentUserAuthentication
import com.studentcenter.weave.application.meeting.port.inbound.GetAllOtherTeamMemberInfoUseCase
import com.studentcenter.weave.application.meeting.port.inbound.GetAllOtherTeamMemberInfo
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import com.studentcenter.weave.application.meetingTeam.port.inbound.GetMeetingTeam
import com.studentcenter.weave.application.meetingTeam.vo.MemberInfo
Expand All @@ -15,12 +15,12 @@ import org.springframework.stereotype.Service
import java.util.*

@Service
class GetAllOtherTeamMemberInfoApplicationService(
class GetAllOtherTeamMemberInfoService(
private val meetingDomainService: MeetingDomainService,
private val getMeetingTeam: GetMeetingTeam,
private val getUser: GetUser,
private val getUniversity: GetUniversity,
) : GetAllOtherTeamMemberInfoUseCase {
) : GetAllOtherTeamMemberInfo {

override fun invoke(meetingId: UUID): List<MemberInfo> {
val meeting = meetingDomainService.getById(meetingId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.meeting.port.inbound.GetMeetingAttendancesUseCase
import com.studentcenter.weave.application.meeting.port.inbound.GetMeetingAttendances
import com.studentcenter.weave.application.meeting.service.domain.MeetingAttendanceDomainService
import com.studentcenter.weave.domain.meeting.entity.MeetingAttendance
import org.springframework.stereotype.Service
import java.util.*

@Service
class GetMeetingAttendancesApplicationService(
class GetMeetingAttendancesService(
private val meetingAttendanceDomainService: MeetingAttendanceDomainService,
) : GetMeetingAttendancesUseCase {
) : GetMeetingAttendances {

override fun invoke(meetingId: UUID): List<MeetingAttendance> {
return meetingAttendanceDomainService.findAllByMeetingId(meetingId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.studentcenter.weave.application.meeting.service.application
import com.studentcenter.weave.application.common.exception.MeetingExceptionType
import com.studentcenter.weave.application.common.exception.MeetingTeamExceptionType
import com.studentcenter.weave.application.common.security.context.getCurrentUserAuthentication
import com.studentcenter.weave.application.meeting.port.inbound.MeetingRequestUseCase
import com.studentcenter.weave.application.meeting.port.inbound.RequestMeeting
import com.studentcenter.weave.application.meeting.service.domain.MeetingAttendanceDomainService
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import com.studentcenter.weave.application.meetingTeam.port.inbound.GetMeetingTeam
Expand All @@ -19,15 +19,15 @@ import org.springframework.transaction.annotation.Transactional
import java.util.*

@Service
class MeetingRequestApplicationService(
class RequestMeetingService(
private val getUser: GetUser,
private val getMeetingTeam: GetMeetingTeam,
private val meetingDomainService: MeetingDomainService,
private val meetingAttendanceDomainService: MeetingAttendanceDomainService,
) : MeetingRequestUseCase {
) : RequestMeeting {

@Transactional
override fun invoke(command: MeetingRequestUseCase.Command) {
override fun invoke(command: RequestMeeting.Command) {
val myMeetingTeam: MeetingTeam = getMyMeetingTeam()
.also {
validateMyMeetingTeamStatus(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.common.exception.MeetingExceptionType
import com.studentcenter.weave.application.common.security.context.getCurrentUserAuthentication
import com.studentcenter.weave.application.meeting.port.inbound.ScrollPendingMeetingUseCase
import com.studentcenter.weave.application.meeting.port.inbound.ScrollPendingMeeting
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import com.studentcenter.weave.application.meeting.vo.PendingMeetingInfo
import com.studentcenter.weave.application.meetingTeam.port.inbound.GetAllMeetingTeamInfo
Expand All @@ -15,14 +15,14 @@ import org.springframework.transaction.annotation.Transactional
import java.util.*

@Service
class ScrollPendingMeetingApplicationService(
class ScrollPendingMeetingService(
private val meetingDomainService: MeetingDomainService,
private val getMeetingTeam: GetMeetingTeam,
private val meetingTeamInfoGetAllByIdsUseCase: GetAllMeetingTeamInfo,
) : ScrollPendingMeetingUseCase {
private val meetingTeamInfoGetAllByIds: GetAllMeetingTeamInfo,
) : ScrollPendingMeeting {

@Transactional(readOnly = true)
override fun invoke(command: ScrollPendingMeetingUseCase.Command): ScrollPendingMeetingUseCase.Result {
override fun invoke(query: ScrollPendingMeeting.Query): ScrollPendingMeeting.Result {
val myTeam = getMeetingTeam.findByMemberUserId(getCurrentUserAuthentication().userId)
?: throw CustomException(
MeetingExceptionType.NOT_FOUND_MY_MEETING_TEAM,
Expand All @@ -31,13 +31,13 @@ class ScrollPendingMeetingApplicationService(

val (items, next) = scrollByPendingMeetingByTeamId(
teamId = myTeam.id,
teamType = command.teamType,
next = command.next,
limit = command.limit,
teamType = query.teamType,
next = query.next,
limit = query.limit,
)

return ScrollPendingMeetingUseCase.Result(
items = createPendingMeetingInfos(items, command.teamType),
return ScrollPendingMeeting.Result(
items = createPendingMeetingInfos(items, query.teamType),
next = next,
)
}
Expand All @@ -62,7 +62,7 @@ class ScrollPendingMeetingApplicationService(
private fun createPendingMeetingInfos(
items: List<Meeting>,
teamType: TeamType,
) : List<PendingMeetingInfo> {
): List<PendingMeetingInfo> {
val teamIds = getUniqueTeamIds(items)
val teamIdToTeamInfo = mapTeamIdToTeamInfo(teamIds)

Expand All @@ -84,11 +84,11 @@ class ScrollPendingMeetingApplicationService(
}

private fun mapTeamIdToTeamInfo(teamIds: List<UUID>) =
meetingTeamInfoGetAllByIdsUseCase.invoke(teamIds)
meetingTeamInfoGetAllByIds.invoke(teamIds)
.associateBy { it.team.id }

private fun getUniqueTeamIds(items: List<Meeting>) = items
.flatMap { listOf(it.receivingTeamId, it.requestingTeamId) }
.distinct()
.flatMap { listOf(it.receivingTeamId, it.requestingTeamId) }
.distinct()

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.studentcenter.weave.application.meeting.service.application

import com.studentcenter.weave.application.common.exception.MeetingExceptionType
import com.studentcenter.weave.application.common.security.context.getCurrentUserAuthentication
import com.studentcenter.weave.application.meeting.port.inbound.ScrollPreparedMeetingUseCase
import com.studentcenter.weave.application.meeting.port.inbound.ScrollPreparedMeeting
import com.studentcenter.weave.application.meeting.service.domain.MeetingDomainService
import com.studentcenter.weave.application.meeting.vo.PreparedMeetingInfo
import com.studentcenter.weave.application.meetingTeam.port.inbound.GetAllMeetingTeamInfo
Expand All @@ -14,14 +14,14 @@ import org.springframework.transaction.annotation.Transactional
import java.util.*

@Service
class ScrollPreparedMeetingApplicationService(
class ScrollPreparedMeetingService(
private val meetingDomainService: MeetingDomainService,
private val getMeetingTeam: GetMeetingTeam,
private val meetingTeamInfoGetAllByIdsUseCase: GetAllMeetingTeamInfo,
) : ScrollPreparedMeetingUseCase {
private val meetingTeamInfoGetAllByIds: GetAllMeetingTeamInfo,
) : ScrollPreparedMeeting {

@Transactional(readOnly = true)
override fun invoke(command: ScrollPreparedMeetingUseCase.Command): ScrollPreparedMeetingUseCase.Result {
override fun invoke(query: ScrollPreparedMeeting.Query): ScrollPreparedMeeting.Result {
val myTeam = getMeetingTeam.findByMemberUserId(getCurrentUserAuthentication().userId)
?: throw CustomException(
MeetingExceptionType.NOT_FOUND_MY_MEETING_TEAM,
Expand All @@ -30,11 +30,11 @@ class ScrollPreparedMeetingApplicationService(

val (items, next) = scrollByPreparedMeetingByTeamId(
teamId = myTeam.id,
next = command.next,
limit = command.limit,
next = query.next,
limit = query.limit,
)

return ScrollPreparedMeetingUseCase.Result(
return ScrollPreparedMeeting.Result(
items = createPreparedMeetingInfos(items, myTeam.id),
next = next,
)
Expand All @@ -58,12 +58,13 @@ class ScrollPreparedMeetingApplicationService(
private fun createPreparedMeetingInfos(
items: List<Meeting>,
myTeamId: UUID,
) : List<PreparedMeetingInfo> {
): List<PreparedMeetingInfo> {
val teamIds = getUniqueTeamIds(items)
val teamIdToTeamInfo = mapTeamIdToTeamInfo(teamIds)

return items.map {
val otherTeamId = if (it.requestingTeamId != myTeamId) it.requestingTeamId else it.receivingTeamId
val otherTeamId =
if (it.requestingTeamId != myTeamId) it.requestingTeamId else it.receivingTeamId
val otherTeamInfo = teamIdToTeamInfo[otherTeamId]
?: throw IllegalArgumentException()
PreparedMeetingInfo(
Expand All @@ -77,11 +78,11 @@ class ScrollPreparedMeetingApplicationService(
}

private fun mapTeamIdToTeamInfo(teamIds: List<UUID>) =
meetingTeamInfoGetAllByIdsUseCase.invoke(teamIds)
meetingTeamInfoGetAllByIds.invoke(teamIds)
.associateBy { it.team.id }

private fun getUniqueTeamIds(items: List<Meeting>) = items
.flatMap { listOf(it.receivingTeamId, it.requestingTeamId) }
.distinct()
.flatMap { listOf(it.receivingTeamId, it.requestingTeamId) }
.distinct()

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import java.util.*

fun interface GetListMeetingTeam {

fun invoke(command: Command): Result
fun invoke(query: Query): Result

data class Command(
data class Query(
val memberCount: Int?,
val youngestMemberBirthYear: Int,
val oldestMemberBirthYear: Int,
Expand Down
Loading

0 comments on commit ca13952

Please sign in to comment.