Skip to content

Commit

Permalink
Merge pull request #95 from makevook/issue/94
Browse files Browse the repository at this point in the history
refactor: spring modulith 도입 및 패키지 리팩토링
  • Loading branch information
seungyeop-lee authored Jun 24, 2024
2 parents e77c496 + 9e94cf4 commit 86aac18
Show file tree
Hide file tree
Showing 148 changed files with 574 additions and 439 deletions.
19 changes: 17 additions & 2 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id 'io.spring.dependency-management' version '1.1.5'
}

ext {
springModulithVersion = "1.2.1"
}

group = 'vook.server'
version = '0.0.1-SNAPSHOT'

Expand Down Expand Up @@ -33,6 +37,11 @@ dependencies {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}

// spring modulith
implementation 'org.springframework.modulith:spring-modulith-starter-core'
implementation 'org.springframework.modulith:spring-modulith-starter-jpa'
testImplementation 'org.springframework.modulith:spring-modulith-starter-test'

// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand All @@ -50,8 +59,8 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-api:2.5.0'

// QueryDsl
implementation "com.querydsl:querydsl-jpa:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
implementation "com.querydsl:querydsl-jpa:5.0.0:jakarta"
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"

Expand All @@ -66,6 +75,12 @@ bootJar {
archiveFileName = "${project.name}.jar"
}

dependencyManagement {
imports {
mavenBom "org.springframework.modulith:spring-modulith-bom:$springModulithVersion"
}
}

tasks.named('test') {
useJUnitPlatform()
}
2 changes: 2 additions & 0 deletions api/src/main/java/vook/server/api/ApiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.modulith.Modulithic;

@Modulithic(systemName = "Vook API")
@SpringBootApplication
public class ApiApplication {

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions api/src/main/java/vook/server/api/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import org.springframework.security.oauth2.client.web.OAuth2AuthorizationRequestResolver;
import org.springframework.security.oauth2.client.web.OAuth2LoginAuthenticationFilter;
import org.springframework.security.web.SecurityFilterChain;
import vook.server.api.web.auth.app.TokenService;
import vook.server.api.web.auth.jwt.JWTFilter;
import vook.server.api.web.auth.oauth2.LoginSuccessHandler;
import vook.server.api.web.auth.oauth2.VookOAuth2UserService;
import vook.server.api.web.common.auth.app.TokenService;
import vook.server.api.web.common.auth.jwt.JWTFilter;
import vook.server.api.web.common.auth.oauth2.LoginSuccessHandler;
import vook.server.api.web.common.auth.oauth2.VookOAuth2UserService;

@Configuration
@EnableWebSecurity
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/vook/server/api/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.springdoc.core.customizers.GlobalOperationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import vook.server.api.web.swagger.GlobalOpenApiCustomizerImpl;
import vook.server.api.web.swagger.GlobalOperationCustomizerImpl;
import vook.server.api.web.common.swagger.GlobalOpenApiCustomizerImpl;
import vook.server.api.web.common.swagger.GlobalOperationCustomizerImpl;

@Configuration
public class SwaggerConfig {
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/vook/server/api/config/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ApplicationModule(
type = ApplicationModule.Type.OPEN
)
package vook.server.api.config;

import org.springframework.modulith.ApplicationModule;
16 changes: 8 additions & 8 deletions api/src/main/java/vook/server/api/devhelper/app/InitService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vook.server.api.app.contexts.demo.domain.DemoTerm;
import vook.server.api.app.contexts.demo.domain.DemoTermRepository;
import vook.server.api.app.contexts.demo.domain.DemoTermSynonymRepository;
import vook.server.api.app.contexts.user.domain.SocialUserRepository;
import vook.server.api.app.contexts.user.domain.UserInfoRepository;
import vook.server.api.app.contexts.user.domain.UserRepository;
import vook.server.api.app.contexts.vocabulary.domain.VocabularyRepository;
import vook.server.api.app.infra.search.demo.MeilisearchDemoTermSearchService;
import vook.server.api.domain.demo.model.DemoTerm;
import vook.server.api.domain.demo.model.DemoTermRepository;
import vook.server.api.domain.demo.model.DemoTermSynonymRepository;
import vook.server.api.domain.user.model.SocialUserRepository;
import vook.server.api.domain.user.model.UserInfoRepository;
import vook.server.api.domain.user.model.UserRepository;
import vook.server.api.domain.vocabulary.model.VocabularyRepository;
import vook.server.api.infra.search.demo.MeilisearchDemoTermSearchService;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
import vook.server.api.app.contexts.demo.domain.DemoTerm;
import vook.server.api.devhelper.helper.CsvReader;
import vook.server.api.domain.demo.model.DemoTerm;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import vook.server.api.app.contexts.demo.domain.DemoTermRepository;
import vook.server.api.devhelper.app.InitService;
import vook.server.api.domain.demo.model.DemoTermRepository;

@Slf4j
@Profile("local")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import vook.server.api.web.common.CommonApiResponse;
import vook.server.api.web.common.response.CommonApiResponse;

@Tag(name = "init", description = "초기화 API")
public interface InitApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vook.server.api.devhelper.app.InitService;
import vook.server.api.web.common.CommonApiResponse;
import vook.server.api.web.common.response.CommonApiResponse;

@Profile({"local", "dev", "stag"})
@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package vook.server.api.domain.common.exception;

import vook.server.api.globalcommon.exception.AppException;

public class DomainException extends AppException {
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package vook.server.api.app.common.exception;
package vook.server.api.domain.common.exception;

import jakarta.validation.ConstraintViolationException;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import vook.server.api.globalcommon.exception.ParameterValidateException;

@Aspect
@Component
public class ExceptionAdvisor {
// vook.server.api.app 패키지 이하의 모든 메서드에 대해 실행
@Around("execution(* vook.server.api.app..*.*(..))")
// vook.server.api.domain 패키지 이하의 모든 메서드에 대해 실행
@Around("execution(* vook.server.api.domain..*.*(..))")
public Object convertException(ProceedingJoinPoint joinPoint) throws Throwable {
try {
return joinPoint.proceed();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.common.entity;
package vook.server.api.domain.common.model;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ApplicationModule(
type = ApplicationModule.Type.OPEN,
displayName = "Domain Common"
)
package vook.server.api.domain.common;

import org.springframework.modulith.ApplicationModule;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package vook.server.api.app.contexts.demo.domain;
package vook.server.api.domain.demo.model;

import jakarta.persistence.*;
import lombok.Getter;
import vook.server.api.app.common.entity.BaseEntity;
import vook.server.api.domain.common.model.BaseEntity;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.demo.domain;
package vook.server.api.domain.demo.model;

import org.springframework.data.jpa.repository.JpaRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.demo.domain;
package vook.server.api.domain.demo.model;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.demo.domain;
package vook.server.api.domain.demo.model;

import org.springframework.data.jpa.repository.JpaRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@ApplicationModule(
type = ApplicationModule.Type.OPEN,
allowedDependencies = {
"common"
}
)
package vook.server.api.domain.demo;

import org.springframework.modulith.ApplicationModule;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package vook.server.api.app.contexts.demo.application;
package vook.server.api.domain.demo.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import vook.server.api.app.contexts.demo.application.data.DemoTermSearchParams;
import vook.server.api.app.contexts.demo.application.data.DemoTermSearchResult;
import vook.server.api.domain.demo.service.data.DemoTermSearchParams;
import vook.server.api.domain.demo.service.data.DemoTermSearchResult;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package vook.server.api.domain.demo.service;

import vook.server.api.domain.demo.service.data.DemoTermSearchParams;
import vook.server.api.domain.demo.service.data.DemoTermSearchResult;

public interface DemoTermSearchService {
DemoTermSearchResult search(DemoTermSearchParams params);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.demo.application.data;
package vook.server.api.domain.demo.service.data;

import com.meilisearch.sdk.SearchRequest;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.demo.application.data;
package vook.server.api.domain.demo.service.data;

import com.meilisearch.sdk.model.Searchable;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package vook.server.api.domain.term.exception;

import vook.server.api.domain.common.exception.DomainException;

public class TermLimitExceededException extends DomainException {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package vook.server.api.app.contexts.term.domain;
package vook.server.api.domain.term.model;

import jakarta.persistence.*;
import lombok.Getter;
import vook.server.api.app.common.entity.BaseEntity;
import vook.server.api.domain.common.model.BaseEntity;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.term.domain;
package vook.server.api.domain.term.model;

import org.springframework.data.jpa.repository.JpaRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.term.domain;
package vook.server.api.domain.term.model;

import jakarta.persistence.*;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package vook.server.api.app.contexts.term.domain;
package vook.server.api.domain.term.model;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
Expand Down
Loading

0 comments on commit 86aac18

Please sign in to comment.