Skip to content

Commit

Permalink
refactor: Service DTO 네이밍 통일 (InDto)
Browse files Browse the repository at this point in the history
  • Loading branch information
hun-ca committed Jul 9, 2024
1 parent 83bbd84 commit ed2d659
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.few.api.domain.admin.document.service

import com.few.api.domain.admin.document.service.dto.GetUrlQuery
import com.few.api.domain.admin.document.service.dto.GetUrlInDto
import com.few.api.domain.admin.document.service.dto.getPreSignedUrlServiceKey
import com.few.api.exception.common.ExternalIntegrationException
import com.few.storage.GetPreSignedObjectUrlService
Expand All @@ -11,15 +11,15 @@ import java.net.URL
import java.util.*

interface GetUrlService {
fun execute(query: GetUrlQuery): URL
fun execute(query: GetUrlInDto): URL
}

@Profile("local")
@Service
class GetLocalUrlService(
private val services: Map<String, GetPreSignedObjectUrlService>
) : GetUrlService {
override fun execute(query: GetUrlQuery): URL {
override fun execute(query: GetUrlInDto): URL {
val service = services.keys.stream().filter { key ->
key.lowercase(Locale.getDefault())
.contains(query.getPreSignedUrlServiceKey())
Expand All @@ -39,7 +39,7 @@ class GetLocalUrlService(
class GetCdnUrlService(
private val cdnProperty: CdnProperty
) : GetUrlService {
override fun execute(query: GetUrlQuery): URL {
override fun execute(query: GetUrlInDto): URL {
return URL(cdnProperty.url + "/" + query.`object`)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.few.api.domain.admin.document.service.dto
import java.util.*

/** query.object example: images/2024-07-01/14789db.png */
fun GetUrlQuery.getPreSignedUrlServiceKey(): String {
fun GetUrlInDto.getPreSignedUrlServiceKey(): String {
return this.`object`.split("/")[0].lowercase(Locale.getDefault()).replace("s", "")
}
data class GetUrlQuery(
data class GetUrlInDto(
val `object`: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.few.api.domain.admin.document.usecase
import com.few.api.domain.admin.document.usecase.dto.AddArticleUseCaseIn
import com.few.api.domain.admin.document.usecase.dto.AddArticleUseCaseOut
import com.few.api.domain.admin.document.service.GetUrlService
import com.few.api.domain.admin.document.service.dto.GetUrlQuery
import com.few.api.domain.admin.document.service.dto.GetUrlInDto
import com.few.api.domain.admin.document.utils.ObjectPathGenerator
import com.few.api.exception.common.ExternalIntegrationException
import com.few.api.exception.common.NotFoundException
Expand Down Expand Up @@ -63,7 +63,7 @@ class AddArticleUseCase(

putDocumentService.execute(documentName, document)?.let { res ->
val source = res.`object`
GetUrlQuery(source).let { query ->
GetUrlInDto(source).let { query ->
getUrlService.execute(query)
}.let { url ->
InsertDocumentIfoCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.few.api.domain.admin.document.usecase
import com.few.api.domain.admin.document.usecase.dto.ConvertContentUseCaseIn
import com.few.api.domain.admin.document.usecase.dto.ConvertContentUseCaseOut
import com.few.api.domain.admin.document.service.GetUrlService
import com.few.api.domain.admin.document.service.dto.GetUrlQuery
import com.few.api.domain.admin.document.service.dto.GetUrlInDto
import com.few.api.domain.admin.document.utils.ObjectPathGenerator
import com.few.api.exception.common.ExternalIntegrationException
import com.few.api.exception.common.InsertException
Expand Down Expand Up @@ -37,7 +37,7 @@ class ConvertContentUseCase(

val originDownloadUrl = putDocumentService.execute(documentName, document)?.let { res ->
val source = res.`object`
GetUrlQuery(source).let { query ->
GetUrlInDto(source).let { query ->
getUrlService.execute(query)
}.let { url ->
InsertDocumentIfoCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.few.api.domain.admin.document.usecase
import com.few.api.domain.admin.document.usecase.dto.PutImageUseCaseIn
import com.few.api.domain.admin.document.usecase.dto.PutImageUseCaseOut
import com.few.api.domain.admin.document.service.GetUrlService
import com.few.api.domain.admin.document.service.dto.GetUrlQuery
import com.few.api.domain.admin.document.service.dto.GetUrlInDto
import com.few.api.domain.admin.document.utils.ObjectPathGenerator
import com.few.api.exception.common.ExternalIntegrationException
import com.few.api.exception.common.InsertException
Expand Down Expand Up @@ -35,7 +35,7 @@ class PutImageUseCase(

val url = putImageService.execute(imageName, image)?.let { res ->
val source = res.`object`
GetUrlQuery(source).let { query ->
GetUrlInDto(source).let { query ->
getUrlService.execute(query)
}.let { url ->
InsertImageIfoCommand(source, url).let { command ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.few.api.domain.article.service

import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsQuery
import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsInDto
import com.few.api.exception.common.NotFoundException
import com.few.api.repo.dao.problem.ProblemDao
import com.few.api.repo.dao.problem.query.SelectProblemsByArticleIdQuery
Expand All @@ -12,7 +12,7 @@ class BrowseArticleProblemsService(
private val problemDao: ProblemDao
) {

fun execute(query: BrowseArticleProblemIdsQuery): ProblemIdsRecord {
fun execute(query: BrowseArticleProblemIdsInDto): ProblemIdsRecord {
SelectProblemsByArticleIdQuery(query.articleId).let { query: SelectProblemsByArticleIdQuery ->
return problemDao.selectProblemsByArticleId(query) ?: throw NotFoundException("problem.notfound.articleId")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.few.api.domain.article.service

import com.few.api.domain.article.service.dto.ReadWriterRecordQuery
import com.few.api.domain.article.service.dto.ReadWriterRecordInDto
import com.few.api.repo.dao.member.MemberDao
import com.few.api.repo.dao.member.query.SelectWriterQuery
import com.few.api.repo.dao.member.record.WriterRecord
Expand All @@ -13,7 +13,7 @@ class ReadArticleWriterRecordService(
) {

@Transactional(readOnly = true)
fun execute(query: ReadWriterRecordQuery): WriterRecord? {
fun execute(query: ReadWriterRecordInDto): WriterRecord? {
SelectWriterQuery(query.writerId).let { query: SelectWriterQuery ->
return memberDao.selectWriter(query)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.article.service.dto

data class BrowseArticleProblemIdsQuery(
data class BrowseArticleProblemIdsInDto(
val articleId: Long
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.article.service.dto

data class ReadWriterRecordQuery(
data class ReadWriterRecordInDto(
val writerId: Long
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.few.api.domain.article.usecase.dto.ReadArticleUseCaseOut
import com.few.api.domain.article.usecase.dto.WriterDetail
import com.few.api.domain.article.service.BrowseArticleProblemsService
import com.few.api.domain.article.service.ReadArticleWriterRecordService
import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsQuery
import com.few.api.domain.article.service.dto.ReadWriterRecordQuery
import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsInDto
import com.few.api.domain.article.service.dto.ReadWriterRecordInDto
import com.few.api.exception.common.NotFoundException
import com.few.api.repo.dao.article.ArticleDao
import com.few.api.repo.dao.article.query.SelectArticleRecordQuery
Expand All @@ -27,11 +27,11 @@ class ReadArticleUseCase(
articleDao.selectArticleRecord(query)
} ?: throw NotFoundException("article.notfound.id")

val writerRecord = ReadWriterRecordQuery(articleRecord.writerId).let { query: ReadWriterRecordQuery ->
val writerRecord = ReadWriterRecordInDto(articleRecord.writerId).let { query: ReadWriterRecordInDto ->
readArticleWriterRecordService.execute(query) ?: throw NotFoundException("writer.notfound.id")
}

val problemIds = BrowseArticleProblemIdsQuery(articleRecord.articleId).let { query: BrowseArticleProblemIdsQuery ->
val problemIds = BrowseArticleProblemIdsInDto(articleRecord.articleId).let { query: BrowseArticleProblemIdsInDto ->
browseArticleProblemsService.execute(query)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.few.api.client.subscription.SubscriptionClient
import com.few.api.client.subscription.dto.WorkbookSubscriptionArgs
import com.few.api.domain.subscription.event.dto.WorkbookSubscriptionEvent
import com.few.api.domain.subscription.service.WorkbookService
import com.few.api.domain.subscription.service.dto.ReadWorkbookTitleDto
import com.few.api.domain.subscription.service.dto.ReadWorkbookTitleInDto
import com.few.api.exception.common.NotFoundException
import com.few.api.repo.dao.subscription.SubscriptionDao
import org.springframework.context.event.EventListener
Expand All @@ -21,7 +21,7 @@ class WorkbookSubscriptionEventListener(
@Async
@EventListener
fun handleWorkbookSubscriptionEvent(event: WorkbookSubscriptionEvent) {
val title = ReadWorkbookTitleDto(event.workbookId).let { dto ->
val title = ReadWorkbookTitleInDto(event.workbookId).let { dto ->
workbookService.readWorkbookTitle(dto)
?: throw NotFoundException("workbook.notfound.id")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.domain.subscription.service

import com.few.api.domain.subscription.service.dto.InsertMemberDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdDto
import com.few.api.domain.subscription.service.dto.InsertMemberInDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdInDto
import com.few.api.exception.common.InsertException
import com.few.api.repo.dao.member.MemberDao
import com.few.api.repo.dao.member.command.InsertMemberCommand
Expand All @@ -14,11 +14,11 @@ class MemberService(
private val memberDao: MemberDao
) {

fun readMemberId(dto: ReadMemberIdDto): MemberIdRecord? {
fun readMemberId(dto: ReadMemberIdInDto): MemberIdRecord? {
return memberDao.selectMemberByEmail(SelectMemberByEmailQuery(dto.email))
}

fun insertMember(dto: InsertMemberDto): Long {
fun insertMember(dto: InsertMemberInDto): Long {
return memberDao.insertMember(InsertMemberCommand(dto.email, dto.memberType)) ?: throw InsertException("member.insertfail.record")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.few.api.domain.subscription.service

import com.few.api.domain.subscription.service.dto.ReadWorkbookTitleDto
import com.few.api.domain.subscription.service.dto.ReadWorkbookTitleInDto
import com.few.api.repo.dao.workbook.WorkbookDao
import com.few.api.repo.dao.workbook.query.SelectWorkBookRecordQuery
import org.springframework.stereotype.Service
Expand All @@ -10,7 +10,7 @@ class WorkbookService(
private val workbookDao: WorkbookDao
) {

fun readWorkbookTitle(dto: ReadWorkbookTitleDto): String? {
fun readWorkbookTitle(dto: ReadWorkbookTitleInDto): String? {
return SelectWorkBookRecordQuery(dto.workbookId).let { query ->
workbookDao.selectWorkBook(query)?.title
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.few.api.domain.subscription.service.dto

import com.few.data.common.code.MemberType

data class InsertMemberDto(
data class InsertMemberInDto(
val email: String,
val memberType: MemberType
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.subscription.service.dto

data class ReadMemberIdDto(
data class ReadMemberIdInDto(
val email: String
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.subscription.service.dto

data class ReadWorkbookTitleDto(
data class ReadWorkbookTitleInDto(
val workbookId: Long
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.few.api.domain.subscription.usecase

import com.few.api.domain.subscription.event.dto.WorkbookSubscriptionEvent
import com.few.api.domain.subscription.service.MemberService
import com.few.api.domain.subscription.service.dto.InsertMemberDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdDto
import com.few.api.domain.subscription.service.dto.InsertMemberInDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdInDto
import com.few.api.repo.dao.subscription.SubscriptionDao
import com.few.api.repo.dao.subscription.command.InsertWorkbookSubscriptionCommand
import com.few.api.repo.dao.subscription.query.SelectAllWorkbookSubscriptionStatusNotConsiderDeletedAtQuery
Expand All @@ -27,8 +27,8 @@ class SubscribeWorkbookUseCase(
fun execute(useCaseIn: SubscribeWorkbookUseCaseIn) {
// TODO: request sending email

val memberId = memberService.readMemberId(ReadMemberIdDto(useCaseIn.email))?.memberId ?: memberService.insertMember(
InsertMemberDto(email = useCaseIn.email, memberType = MemberType.NORMAL)
val memberId = memberService.readMemberId(ReadMemberIdInDto(useCaseIn.email))?.memberId ?: memberService.insertMember(
InsertMemberInDto(email = useCaseIn.email, memberType = MemberType.NORMAL)
)

val subTargetWorkbookId = useCaseIn.workbookId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.domain.subscription.usecase

import com.few.api.domain.subscription.service.MemberService
import com.few.api.domain.subscription.service.dto.ReadMemberIdDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdInDto
import com.few.api.domain.subscription.usecase.dto.UnsubscribeAllUseCaseIn
import com.few.api.exception.common.NotFoundException
import com.few.api.repo.dao.subscription.SubscriptionDao
Expand All @@ -20,7 +20,7 @@ class UnsubscribeAllUseCase(
// TODO: request sending email

val memberId =
memberService.readMemberId(ReadMemberIdDto(useCaseIn.email))?.memberId ?: throw NotFoundException("member.notfound.email")
memberService.readMemberId(ReadMemberIdInDto(useCaseIn.email))?.memberId ?: throw NotFoundException("member.notfound.email")

subscriptionDao.updateDeletedAtInAllSubscription(
UpdateDeletedAtInAllSubscriptionCommand(memberId = memberId, opinion = useCaseIn.opinion)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.domain.subscription.usecase

import com.few.api.domain.subscription.service.MemberService
import com.few.api.domain.subscription.service.dto.ReadMemberIdDto
import com.few.api.domain.subscription.service.dto.ReadMemberIdInDto
import com.few.api.repo.dao.subscription.SubscriptionDao
import com.few.api.repo.dao.subscription.command.UpdateDeletedAtInWorkbookSubscriptionCommand
import com.few.api.domain.subscription.usecase.dto.UnsubscribeWorkbookUseCaseIn
Expand All @@ -20,7 +20,7 @@ class UnsubscribeWorkbookUseCase(
// TODO: request sending email

val memberId =
memberService.readMemberId(ReadMemberIdDto(useCaseIn.email))?.memberId ?: throw NotFoundException("member.notfound.email")
memberService.readMemberId(ReadMemberIdInDto(useCaseIn.email))?.memberId ?: throw NotFoundException("member.notfound.email")

subscriptionDao.updateDeletedAtInWorkbookSubscription(
UpdateDeletedAtInWorkbookSubscriptionCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.few.api.domain.workbook.article.usecase

import com.few.api.domain.article.service.BrowseArticleProblemsService
import com.few.api.domain.article.service.ReadArticleWriterRecordService
import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsQuery
import com.few.api.domain.article.service.dto.ReadWriterRecordQuery
import com.few.api.domain.article.service.dto.BrowseArticleProblemIdsInDto
import com.few.api.domain.article.service.dto.ReadWriterRecordInDto
import com.few.api.domain.workbook.article.dto.ReadWorkBookArticleUseCaseIn
import com.few.api.domain.workbook.article.dto.ReadWorkBookArticleOut
import com.few.api.domain.workbook.article.dto.WriterDetail
Expand All @@ -30,12 +30,12 @@ class ReadWorkBookArticleUseCase(
} ?: throw NotFoundException("article.notfound.articleidworkbookid")

val writerRecord =
ReadWriterRecordQuery(articleRecord.writerId).let { query: ReadWriterRecordQuery ->
ReadWriterRecordInDto(articleRecord.writerId).let { query: ReadWriterRecordInDto ->
readArticleWriterRecordService.execute(query) ?: throw NotFoundException("writer.notfound.id")
}

val problemIds =
BrowseArticleProblemIdsQuery(articleRecord.articleId).let { query: BrowseArticleProblemIdsQuery ->
BrowseArticleProblemIdsInDto(articleRecord.articleId).let { query: BrowseArticleProblemIdsInDto ->
browseArticleProblemsService.execute(query)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.domain.workbook.service

import com.few.api.domain.workbook.usecase.dto.ArticleDetail
import com.few.api.domain.workbook.service.dto.BrowseWorkbookArticlesQuery
import com.few.api.domain.workbook.service.dto.BrowseWorkbookArticlesInDto
import com.few.api.repo.dao.article.ArticleDao
import com.few.api.repo.dao.article.query.SelectWorkbookMappedArticleRecordsQuery
import com.few.api.repo.dao.article.record.SelectWorkBookMappedArticleRecord
Expand All @@ -19,7 +19,7 @@ fun List<SelectWorkBookMappedArticleRecord>.toArticleDetails(): List<ArticleDeta
class WorkbookArticleService(
private val articleDao: ArticleDao
) {
fun browseWorkbookArticles(query: BrowseWorkbookArticlesQuery): List<SelectWorkBookMappedArticleRecord> {
fun browseWorkbookArticles(query: BrowseWorkbookArticlesInDto): List<SelectWorkBookMappedArticleRecord> {
return SelectWorkbookMappedArticleRecordsQuery(query.workbookId).let { query ->
articleDao.selectWorkbookMappedArticleRecords(query)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.domain.workbook.service

import com.few.api.domain.workbook.usecase.dto.WriterDetail
import com.few.api.domain.workbook.service.dto.BrowseWriterRecordsQuery
import com.few.api.domain.workbook.service.dto.BrowseWriterRecordsInDto
import com.few.api.repo.dao.member.MemberDao
import com.few.api.repo.dao.member.query.SelectWritersQuery
import com.few.api.repo.dao.member.record.WriterRecord
Expand All @@ -15,7 +15,7 @@ fun List<WriterRecord>.toWriterDetails(): List<WriterDetail> {
class WorkbookMemberService(
private val memberDao: MemberDao
) {
fun browseWriterRecords(query: BrowseWriterRecordsQuery): List<WriterRecord> {
fun browseWriterRecords(query: BrowseWriterRecordsInDto): List<WriterRecord> {
return SelectWritersQuery(query.writerIds).let { query ->
memberDao.selectWriters(query)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.workbook.service.dto

data class BrowseWorkbookArticlesQuery(
data class BrowseWorkbookArticlesInDto(
val workbookId: Long
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.few.api.domain.workbook.service.dto

data class BrowseWriterRecordsQuery(
data class BrowseWriterRecordsInDto(
val writerIds: List<Long>
)
Loading

0 comments on commit ed2d659

Please sign in to comment.