-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Refactor]: 패키지 분리 #97
base: albertimkr
Are you sure you want to change the base?
[Refactor]: 패키지 분리 #97
Conversation
interface UrlShortenService { | ||
|
||
fun getOriginUrl(request: ShortenUrlSearchRequest): OriginUrlResponse | ||
fun saveShortenUrl(request: ShortenUrlCreateRequest): ShortenedUrlResponse | ||
} | ||
|
||
@Service | ||
class DefaultUrlShortenService(private val shortenedUrlRepository: ShortenedUrlRepository) : UrlShortenService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Service 구현체를 한 파일에서 관리하도록 변경했어요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구현체의 종류가 늘어나면 어떻게 하실 생각인가요?
@@ -1,4 +1,4 @@ | |||
package community.whatever.onembackendkotlin | |||
package community.whatever.onembackendkotlin.common.dto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dto를 매 계층마다 관리할 수 있지만 복잡한 프로젝트가 아니라서 코드의 격리보다 코드의 복잡성 증가를 방지하기 위해 Common 패키지에 Dto를 모아두었어요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface UrlShortenService { | ||
|
||
fun getOriginUrl(request: ShortenUrlSearchRequest): OriginUrlResponse | ||
fun saveShortenUrl(request: ShortenUrlCreateRequest): ShortenedUrlResponse | ||
} | ||
|
||
@Service | ||
class DefaultUrlShortenService(private val shortenedUrlRepository: ShortenedUrlRepository) : UrlShortenService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구현체의 종류가 늘어나면 어떻게 하실 생각인가요?
if (shortenedUrlRepository.existsByOriginUrl(originUrl)) { | ||
return ShortenedUrlResponse(shortenedUrlRepository.findByOriginUrl(originUrl)!!.id!!) | ||
} | ||
return ShortenedUrlResponse(shortenedUrlRepository.save(ShortenedUrl(originUrl)).id!!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! 는 지양해야 됩니다.
@@ -1,4 +1,4 @@ | |||
package community.whatever.onembackendkotlin | |||
package community.whatever.onembackendkotlin.common.dto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,4 +1,4 @@ | |||
package community.whatever.onembackendkotlin | |||
package community.whatever.onembackendkotlin.common.exception | |||
|
|||
const val URL_NOT_FOUND_MESSAGE = "해당 키에 대한 URL이 존재하지 않습니다." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception 안에 있고 밖에 있고의 차이가 무엇일까요?
nit
저는 top-level 에 무엇이 있는 것을 선호하지 않지 않습니다.
수정사항