diff --git a/build.gradle b/build.gradle index 3a9580df..edfa69cb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'com.epages.restdocs-api-spec' version '0.16.2' + id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10' } subprojects { @@ -108,6 +109,8 @@ project(':keewe-core') { project(':keewe-domain') { + apply plugin: 'com.ewerk.gradle.plugins.querydsl' + bootJar { enabled = false } @@ -116,6 +119,16 @@ project(':keewe-domain') { enabled = true } + configurations { + querydsl { + extendsFrom compileClasspath + } + } + + ext { + queryDslVersion = "5.0.0" + } + dependencies { implementation project(path: ':keewe-core', configuration: 'default') implementation project(path: ':keewe-infra', configuration: 'default') @@ -123,8 +136,26 @@ project(':keewe-domain') { implementation 'mysql:mysql-connector-java' implementation group: 'com.h2database', name: 'h2', version: '2.1.214' implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8' + implementation "com.querydsl:querydsl-jpa:${queryDslVersion}" + implementation "com.querydsl:querydsl-apt:${queryDslVersion}" // todo ::jpa, redis import } + + + def querydslSrcDir = "$buildDir/generated/querydsl" + + querydsl { + jpa = true + querydslSourcesDir = querydslSrcDir + } + + sourceSets { + main.java.srcDir querydslSrcDir + } + + compileQuerydsl { + options.annotationProcessorPath = configurations.querydsl + } } project(':keewe-api') { diff --git a/keewe-api/src/test/java/ccc/keeweapi/service/user/ProfileServiceTest.java b/keewe-api/src/test/java/ccc/keeweapi/service/user/ProfileServiceTest.java index 4801b816..a89c6eb6 100644 --- a/keewe-api/src/test/java/ccc/keeweapi/service/user/ProfileServiceTest.java +++ b/keewe-api/src/test/java/ccc/keeweapi/service/user/ProfileServiceTest.java @@ -47,7 +47,7 @@ void test1() { User user = SecurityUtil.getUser(); userRepository.save(user); System.out.println("user = " + user.getId()); - Profile profile = Profile.init().user(user).build(); + Profile profile = Profile.of(user); Nest nest = new Nest(); nestRepository.save(nest); diff --git a/keewe-domain/src/main/java/ccc/keewedomain/domain/user/Profile.java b/keewe-domain/src/main/java/ccc/keewedomain/domain/user/Profile.java index c7bb26e6..57775e42 100644 --- a/keewe-domain/src/main/java/ccc/keewedomain/domain/user/Profile.java +++ b/keewe-domain/src/main/java/ccc/keewedomain/domain/user/Profile.java @@ -81,17 +81,6 @@ public class Profile extends BaseTimeEntity { public static final int NICKNAME_MAX_LENGTH = 10; public static final int SOCIAL_LINKS_MAX_SIZE = 5; - public static ProfileBuilder init() { - return Profile.builder() - .privacy(PUBLIC) - .profileStatus(NICKNAME_NEEDED) - .activities(new ArrayList<>()) - .followers(new ArrayList<>()) - .followees(new ArrayList<>()) - .socialLinks(new ArrayList<>()) - .deleted(false); - } - public static Profile of(User user) { Profile profile = new Profile(); profile.connectWithUser(user); @@ -152,4 +141,5 @@ private void checkLinkPatternOrElseThrow(String link) { if (!matcher.matches()) throw new IllegalArgumentException("링크 패턴이 일치하지 않습니다."); } + } diff --git a/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileDomainServiceTest.java b/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileDomainServiceTest.java index 29fc2e79..513f4b00 100644 --- a/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileDomainServiceTest.java +++ b/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileDomainServiceTest.java @@ -28,7 +28,8 @@ public class ProfileDomainServiceTest { @Test @DisplayName("닉네임 생성 제약조건 테스트") void nickname_constraint_test() { - Profile profile = Profile.init().build(); + Profile profile = new Profile(); + when(profileRepository.findById(any())) .thenReturn(Optional.of(profile)); diff --git a/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileTest.java b/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileTest.java index 39a93e6b..d246a51e 100644 --- a/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileTest.java +++ b/keewe-domain/src/test/java/ccc/keewedomain/domain/user/ProfileTest.java @@ -8,8 +8,7 @@ class ProfileTest { @Test @DisplayName("링크 패턴 정규식 테스트") void test1() { - Profile profile = Profile.init().build(); - + Profile profile = new Profile(); // 정상적인 링크 profile.createLink("_hello._.world_");