import org.springframework.stereotype.Service
import java.time.LocalDateTime
interface GetLogsByOptionalListsUseCase {
suspend operator fun invoke(
boardId: String,
partnerList: Array<String>?,
contentList: Array<String>?,
labelList: Array<String>?,
fromDate: LocalDateTime,
toDate: LocalDateTime?
): Collection<ContentLog>
}
@Serviceinternal class GetLogsByOptionalListsUseCaseImpl(
private val logService: LogService
) : GetLogsByOptionalListsUseCase {
override suspend fun invoke(
boardId: String,
partnerList: Array<String>?,
contentList: Array<String>?,
labelList: Array<String>?,
fromDate: LocalDateTime,
toDate: LocalDateTime?
): Collection<ContentLog> {
return when {
(partnerList != null && contentList != null && labelList != null && toDate != null) ->
return logService.getByBoardAndLists(
boardId,
partnerList,
contentList,
labelList,
fromDate,
toDate
)
(partnerList != null && toDate != null) ->
return logService.getByBoardAndPartnersFromDate(
boardId,
partnerList,
fromDate,
toDate
)
(partnerList != null) ->
return logService.getByBoardAndPartnerList(
boardId,
partnerList,
fromDate
)
(contentList != null) ->
return logService.getByBoardAndContents(
boardId,
contentList,
fromDate
)
(labelList != null) ->
return logService.getByBoardAndLabels(
boardId,
labelList,
fromDate
)
(toDate != null) ->
return logService.getByBoardAndToDate(
boardId,
fromDate,
toDate
)
else -> logService.getByBoardAndFromDate(boardId, fromDate)
}
}
}