Skip to content

Commit

Permalink
Fix seprated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mkSpace committed Jun 24, 2024
1 parent afc8ced commit 67ef367
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 62 deletions.
31 changes: 10 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
plugins {
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
id("application")
kotlin("jvm") version "1.9.20"
kotlin("plugin.spring") version "1.9.20"
kotlin("plugin.jpa") version "1.9.20"
kotlin("kapt") version "1.6.21"
kotlin("plugin.spring") version "1.9.20" apply false
kotlin("plugin.jpa") version "1.9.20" apply false
id("org.springframework.boot") version "3.2.0" apply false
id("io.spring.dependency-management") version "1.1.4" apply false
jacoco
}

Expand All @@ -20,33 +19,23 @@ allprojects {
}
}

application {
mainClass = "com.whatever.raisedragon.RaiseDragonApiApplicationKt"
}

subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "kotlin-kapt")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
apply(plugin = "org.springframework.boot")
apply(plugin = "kotlin")
apply(plugin = "java-library")
apply(plugin = "kotlin-jpa")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "kotlin-kapt")
apply(plugin = "application")
apply(plugin = "jacoco")
apply(plugin = "io.spring.dependency-management")

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.github.microutils:kotlin-logging:2.0.8")
implementation("org.jetbrains.kotlin:kotlin-reflect")

// SpringMockk
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("com.ninja-squad:springmockk:3.1.1")

testRuntimeOnly("com.h2database:h2")
}

jacoco {
Expand Down Expand Up @@ -146,11 +135,11 @@ subprojects {
}
}

tasks.bootJar {
tasks.getByName("bootJar") {
enabled = false
}

tasks.jar {
tasks.getByName("jar") {
enabled = true
}
}
}
5 changes: 4 additions & 1 deletion raisedragon-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ dependencies {
implementation(project(":raisedragon-common"))
implementation(project(":raisedragon-core"))
implementation(project(":raisedragon-external"))
api("org.springframework.boot:spring-boot-starter-data-jpa:3.0.4")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-validation:3.0.4")
implementation("org.springframework.boot:spring-boot-starter-aop:3.0.4")
implementation("org.springframework.boot:spring-boot-starter-security:3.0.4")
implementation("org.springframework:spring-tx:6.1.1")

// Swagger
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$swaggerVersion")
Expand All @@ -27,4 +28,6 @@ dependencies {
implementation("io.jsonwebtoken:jjwt-jackson:0.11.5")

testImplementation("org.springframework.security:spring-security-test")
testRuntimeOnly("com.h2database:h2")
testApi("org.springframework.boot:spring-boot-starter-data-jpa:3.0.4")
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ApiExceptionHandler {
@ExceptionHandler(BaseException::class)
private fun handleBaseException(exception: BaseException): ResponseEntity<Response<Unit>> {
return ResponseEntity
.status(exception.exceptionCode.httpStatus)
.status(exception.exceptionCode.httpStatusCode)
.body(Response.fail(exception))
}

Expand All @@ -90,4 +90,4 @@ class ApiExceptionHandler {
companion object {
const val DETAIL_MESSAGE_BY_PARAMETER_EXCEPTION = "Please Check Your Request Parameter"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class Response<T>(
return Response(
isSuccess = false,
errorResponse = ErrorResponse(
code = exceptionCode.code,
code = exceptionCode.errorCode,
detailMessage = detailMessage ?: exceptionCode.message
)
)
Expand All @@ -34,7 +34,7 @@ data class Response<T>(
return Response(
isSuccess = false,
errorResponse = ErrorResponse(
code = exception.exceptionCode.code,
code = exception.exceptionCode.errorCode,
detailMessage = exception.message
)
)
Expand All @@ -45,4 +45,4 @@ data class Response<T>(
data class ErrorResponse(
val code: String,
val detailMessage: String?
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package com.whatever.raisedragon.common.aop.auth

import com.whatever.raisedragon.common.exception.BaseException
import com.whatever.raisedragon.common.exception.ExceptionCode
import com.whatever.raisedragon.domain.user.UserRepository
import com.whatever.raisedragon.domain.user.toDto
import com.whatever.raisedragon.domain.user.UserService
import com.whatever.raisedragon.security.jwt.JwtAgent
import jakarta.servlet.http.HttpServletRequest
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Component
import org.springframework.util.StringUtils

@Aspect
@Component
class AuthAspect(
private val httpServletRequest: HttpServletRequest,
private val userRepository: UserRepository,
private val userService: UserService,
private val jwtAgent: JwtAgent
) {

Expand All @@ -29,11 +27,7 @@ class AuthAspect(
)

val userId = jwtAgent.extractUserId(token).toString().toLong()
val user = userRepository.findByIdOrNull(userId)?.toDto()
?: throw BaseException.of(
exceptionCode = ExceptionCode.E404_NOT_FOUND,
executionMessage = "존재하지 않는 유저입니다."
)
val user = userService.findById(userId)

AuthContext.USER_CONTEXT.set(user)
return pjp.proceed(pjp.args)
Expand All @@ -53,4 +47,4 @@ class AuthAspect(
private const val PREFIX_BEARER = "Bearer "
private const val BASE_PACKAGE = "com.whatever.raisedragon.common.aop.auth.Auth"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import com.whatever.raisedragon.domain.goal.GoalType.*
import com.whatever.raisedragon.domain.user.Nickname
import com.whatever.raisedragon.domain.user.UserEntity
import com.whatever.raisedragon.domain.user.UserRepository
import jakarta.transaction.Transactional
import org.assertj.core.api.Assertions.*
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime

@Transactional
Expand Down Expand Up @@ -363,4 +363,4 @@ class BettingApplicationServiceTest : ApplicationServiceTestSupport {
endDate = endDateTime
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import com.whatever.raisedragon.domain.user.UserEntity
import com.whatever.raisedragon.domain.user.UserRepository
import com.whatever.raisedragon.domain.winner.WinnerEntity
import com.whatever.raisedragon.domain.winner.WinnerRepository
import jakarta.transaction.Transactional
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatThrownBy
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime

@Transactional
Expand Down Expand Up @@ -389,4 +389,4 @@ class GoalGifticonApplicationServiceTest : ApplicationServiceTestSupport {
endDate = endDateTime
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
package com.whatever.raisedragon.common.exception

import org.springframework.http.HttpStatus

enum class ExceptionCode(
val httpStatus: HttpStatus,
val code: String,
val httpStatusCode: Int,
val message: String,
) {

E400_BAD_REQUEST(HttpStatus.BAD_REQUEST, "400", "필수 파라미터 값이 없거나 잘못된 값으로 요청을 보낸 경우 발생"),
E400_BAD_REQUEST( 400, "필수 파라미터 값이 없거나 잘못된 값으로 요청을 보낸 경우 발생"),

// ------------------------------ 401 ------------------------------
E401_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "401", "유효하지 않은 인증 토큰을 사용한 경우 발생"),
E401_UNAUTHORIZED(401, "유효하지 않은 인증 토큰을 사용한 경우 발생"),

// ------------------------------ 403 ------------------------------
E403_FORBIDDEN(HttpStatus.FORBIDDEN, "403", "사용 권한이 없는 경우 발생"),
E403_FORBIDDEN(403, "사용 권한이 없는 경우 발생"),

// ------------------------------ 404 ------------------------------
E404_NOT_FOUND(HttpStatus.NOT_FOUND, "404", "요청한 리소스가 존재하지 않는 경우 발생"),
E404_NOT_FOUND(404, "요청한 리소스가 존재하지 않는 경우 발생"),

// ------------------------------ 405 ------------------------------
E405_METHOD_NOT_ALLOWED(HttpStatus.METHOD_NOT_ALLOWED, "405", "HTTP Method가 잘못된 경우"),
E405_METHOD_NOT_ALLOWED(405, "HTTP Method가 잘못된 경우"),

// ------------------------------ 409 ------------------------------
E409_CONFLICT(HttpStatus.CONFLICT, "409", "요청한 리소스가 중복된 경우 발생"),
E409_CONFLICT(409, "요청한 리소스가 중복된 경우 발생"),

// ------------------------------ 500 ------------------------------
E500_INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "500", "서버 내부에 문제 발생"),
E500_INTERNAL_SERVER_ERROR(500, "서버 내부에 문제 발생"),

// ------------------------------ 501 ------------------------------
E501_NOT_IMPLEMENTED(HttpStatus.NOT_IMPLEMENTED, "501", "지원하지 않는 타입의 요청"),
}
E501_NOT_IMPLEMENTED(501, "지원하지 않는 타입의 요청");

fun ExceptionCode.throwAsException() {
throw BaseException.of(
exceptionCode = this,
executionMessage = message
)
}
val errorCode: String
get() = httpStatusCode.toString()
}
6 changes: 5 additions & 1 deletion raisedragon-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apply(plugin = "kotlin-jpa")

dependencies {
implementation(project(":raisedragon-common"))
implementation("org.springframework.boot:spring-boot-starter-data-jpa:3.0.4")
runtimeOnly("com.mysql:mysql-connector-j:8.0.32")
runtimeOnly("com.mysql:mysql-connector-j:8.2.0")

// querydsl
implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
Expand All @@ -11,6 +13,8 @@ dependencies {

// jasypt
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5")

testRuntimeOnly("com.h2database:h2")
}

allOpen {
Expand Down
5 changes: 4 additions & 1 deletion raisedragon-external/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dependencies {
// aws
implementation("org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE")
}

// RestTemplate
implementation("org.springframework:spring-webmvc")
}

0 comments on commit 67ef367

Please sign in to comment.