Skip to content
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 : 도메인 모듈 web 의존성 제거 #133

Merged
merged 8 commits into from
May 22, 2024
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bamyanggang.domainmodule.domain.bookmark.config
package com.bamyanggang.apimodule.domain.bookmark.config

import com.bamyanggang.domainmodule.domain.bookmark.repository.BookmarkRepository
import com.bamyanggang.domainmodule.domain.bookmark.service.BookmarkAppender
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.bamyanggang.apimodule.domain.experience.config

import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceAppender
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceModifier
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceReader
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceRemover
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class ExperienceServiceConfiguration(
private val experienceRepository: ExperienceRepository
) {

@Bean
fun experienceAppender(): ExperienceAppender {
return ExperienceAppender(experienceRepository)
}

@Bean
fun experienceModifier(): ExperienceModifier {
return ExperienceModifier(experienceRepository)
}

@Bean
fun experienceReader(): ExperienceReader {
return ExperienceReader(experienceRepository)
}

@Bean
fun experienceRemover(): ExperienceRemover {
return ExperienceRemover(experienceRepository)
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bamyanggang.domainmodule.domain.jobDescription.config
package com.bamyanggang.apimodule.domain.jobDescription.config

import com.bamyanggang.domainmodule.domain.jobDescription.repository.ApplyRepository
import com.bamyanggang.domainmodule.domain.jobDescription.repository.JobDescriptionRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.bamyanggang.apimodule.domain.strongpoint.config

import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointAppender
import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointReader
import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointRemover
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class StrongPointServiceConfiguration(
private val strongPointRepository: StrongPointRepository
) {

@Bean
fun strongPointAppender(): StrongPointAppender {
return StrongPointAppender(strongPointRepository)
}

@Bean
fun strongPointReader(): StrongPointReader {
return StrongPointReader(strongPointRepository)
}

@Bean
fun strongPointModifier(): StrongPointRemover{
return StrongPointRemover(strongPointRepository)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.bamyanggang.apimodule.domain.tag.config

import com.bamyanggang.domainmodule.domain.tag.repository.TagRepository
import com.bamyanggang.domainmodule.domain.tag.service.TagAppender
import com.bamyanggang.domainmodule.domain.tag.service.TagReader
import com.bamyanggang.domainmodule.domain.tag.service.TagRemover
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class TagServiceConfiguration(
private val tagRepository: TagRepository
) {

@Bean
fun tagAppender(): TagAppender {
return TagAppender(tagRepository)
}

@Bean
fun tagReader(): TagReader {
return TagReader(tagRepository)
}

@Bean
fun tagModifier(): TagRemover {
return TagRemover(tagRepository)
}

}
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package com.bamyanggang.apimodule.domain.user.application.exception

import com.bamyanggang.commonmodule.exception.CustomException
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode

sealed class AuthException (
errorCode: Int,
httpStatusCode: HttpStatusCode,
message: String,
) : CustomException(CODE_PREFIX, errorCode, httpStatusCode , message) {
) : CustomException(CODE_PREFIX, errorCode, message) {

class OAuthFailed(message: String = "OAuth 인증에 실패하였습니다.") :
AuthException(errorCode = 1, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
AuthException(errorCode = 1, message = message)

class KakaoUserInfoRetrievalException(message: String = "카카오 사용자 정보를 가져오는데 실패했습니다.") :
AuthException(errorCode = 2, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
AuthException(errorCode = 2, message = message)

class GoogleUserInfoRetrievalException(message: String = "구글 사용자 정보를 가져오는데 실패했습니다.") :
AuthException(errorCode = 3, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
AuthException(errorCode = 3, message = message)

companion object {
const val CODE_PREFIX = "AUTH"
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.bamyanggang.domainmodule.domain.user.config
package com.bamyanggang.apimodule.domain.user.config

import com.bamyanggang.domainmodule.domain.user.repository.TokenRepository
import com.bamyanggang.domainmodule.domain.user.repository.UserRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class TagControllerTest : BaseRestDocsTest() {
val result = mockMvc.perform(request)

//then
result.andExpect(status().isNotFound)
result.andExpect(status().isBadRequest)
.andDo(resultHandler.document(
requestHeaders(
headerWithName("Authorization").description("엑세스 토큰")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package com.bamyanggang.commonmodule.exception

import org.springframework.http.HttpStatusCode

abstract class CustomException(
codePrefix: String = DEFAULT_CODE_PREFIX,
errorCode: Int,
httpStatusCode: HttpStatusCode,
override val message: String = DEFAULT_MESSAGE,
) : RuntimeException(message) {

val code: String = "$codePrefix-${
errorCode.toString().padStart(DEFAULT_CODE_NUMBER_LENGTH, DEFAULT_CODE_NUMBER_PAD_CHAR)
}"

val httpStatusCode: HttpStatusCode = httpStatusCode

companion object {
const val DEFAULT_CODE_PREFIX = "UNKNOWN"
const val DEFAULT_MESSAGE = "예상하지 못한 오류가 발생했습니다."
const val DEFAULT_CODE_NUMBER_LENGTH = 3
const val DEFAULT_CODE_NUMBER_PAD_CHAR = '0'
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ExceptionHandler {
private val logger = LoggerFactory.getLogger(ExceptionHandler::class.java)
@ExceptionHandler(CustomException::class)
fun handleJwtException(e: CustomException): ResponseEntity<ErrorResponse> {
return ResponseEntity(ErrorResponse(e.code, e.message), e.httpStatusCode)
return ResponseEntity(ErrorResponse(e.code, e.message), HttpStatus.BAD_REQUEST)
}

@ExceptionHandler(Exception::class)
Expand Down
2 changes: 0 additions & 2 deletions Domain-Module/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
dependencies {
implementation(project(":Common-Module"))
//web
implementation("org.springframework.boot:spring-boot-starter-web")
implementation(project(":Support-Module:uuid"))
testImplementation(testFixtures(project(":Common-Module")))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import com.bamyanggang.domainmodule.domain.experience.aggregate.Experience
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceStrongPoint
import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository
import org.springframework.stereotype.Service
import java.time.LocalDateTime
import java.util.*

@Service
class ExperienceAppender(
private val experienceRepository: ExperienceRepository,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import com.bamyanggang.domainmodule.domain.experience.aggregate.Experience
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent
import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceStrongPoint
import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository
import org.springframework.stereotype.Service
import java.time.LocalDateTime
import java.util.*

@Service
class ExperienceModifier(
private val experienceRepository: ExperienceRepository
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.experience.service

import com.bamyanggang.domainmodule.domain.experience.aggregate.Experience
import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class ExperienceReader(
private val experienceRepository: ExperienceRepository
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.bamyanggang.domainmodule.domain.experience.service

import com.bamyanggang.domainmodule.domain.experience.repository.ExperienceRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class ExperienceRemover(
private val experienceRepository: ExperienceRepository,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package com.bamyanggang.domainmodule.domain.jobDescription.exception

import com.bamyanggang.commonmodule.exception.CustomException
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode

sealed class JobDescriptionException (
errorCode: Int,
httpStatusCode: HttpStatusCode,
message: String,
) : CustomException(CODE_PREFIX, errorCode, httpStatusCode , message) {
) : CustomException(CODE_PREFIX, errorCode, message) {

class ModifyWriteStatusFailed(message: String = "쓰기 상태 변경에 실패하였습니다.") :
JobDescriptionException(errorCode = 1, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
JobDescriptionException(errorCode = 1, message = message)

companion object {
const val CODE_PREFIX = "AUTH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ package com.bamyanggang.domainmodule.domain.strongpoint.exception

import com.bamyanggang.commonmodule.exception.CustomException
import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode

sealed class StrongPointException(
errorCode: Int,
httpStatusCode: HttpStatusCode,
message: String,
) : CustomException(CODE_PREFIX, errorCode, httpStatusCode , message) {
) : CustomException(CODE_PREFIX, errorCode, message) {

class OverCountLimit (message: String = "역량 키워드는 최대 ${StrongPoint.LIMIT}개까지 등록 가능합니다.") :
StrongPointException(errorCode = 3, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
StrongPointException(errorCode = 3, message = message)

companion object {
const val CODE_PREFIX = "STRONG_POINT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class StrongPointAppender(
private val strongPointRepository: StrongPointRepository
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.strongpoint.aggregate.StrongPoint
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class StrongPointReader(
private val strongPointRepository: StrongPointRepository
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.strongpoint.service

import com.bamyanggang.domainmodule.domain.strongpoint.exception.StrongPointExceptionMessage
import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class StrongPointRemover(
private val strongPointRepository: StrongPointRepository
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package com.bamyanggang.domainmodule.domain.tag.exception

import com.bamyanggang.commonmodule.exception.CustomException
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode

sealed class TagException(
errorCode: Int,
httpStatusCode: HttpStatusCode,
message: String,
) : CustomException(CODE_PREFIX, errorCode, httpStatusCode , message) {
) : CustomException(CODE_PREFIX, errorCode, message) {

class DuplicatedTagName(message: String = "태그 이름이 중복됩니다.") :
TagException(errorCode = 1, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
TagException(errorCode = 1, message = message)

class OverTagCountLimit(message: String = "태그 개수가 제한 개수보다 많습니다.") :
TagException(errorCode = 2, httpStatusCode = HttpStatus.BAD_REQUEST, message = message)
TagException(errorCode = 2, message = message)

class NotFoundTag(message: String = "존재하지 않는 태그 입니다.") :
TagException(errorCode = 3, httpStatusCode = HttpStatus.NOT_FOUND, message = message)
TagException(errorCode = 3, message = message)

companion object {
const val CODE_PREFIX = "TAG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.tag.service

import com.bamyanggang.domainmodule.domain.tag.aggregate.Tag
import com.bamyanggang.domainmodule.domain.tag.repository.TagRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class TagAppender(
private val tagRepository: TagRepository
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.tag.service

import com.bamyanggang.domainmodule.domain.tag.aggregate.Tag
import com.bamyanggang.domainmodule.domain.tag.repository.TagRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class TagReader(
private val tagRepository: TagRepository
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.bamyanggang.domainmodule.domain.tag.service

import com.bamyanggang.domainmodule.domain.tag.exception.TagException
import com.bamyanggang.domainmodule.domain.tag.repository.TagRepository
import org.springframework.stereotype.Service
import java.util.*

@Service
class TagRemover(
private val tagRepository: TagRepository
) {
Expand Down
Loading
Loading