From cba3c59f01ed8220dcea0399acb231d6df4eeb1b Mon Sep 17 00:00:00 2001 From: Kurenai Date: Wed, 22 May 2024 00:27:32 +0800 Subject: [PATCH] Update 24.5.22 --- .gitmodules | 3 +++ build.gradle.kts | 15 ++++++----- cq-sdk | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 1 + .../kurenai/imsyncbot/domain/UserConfig.java | 7 ++++- .../repository/UserConfigRepository.kt | 2 -- .../imsyncbot/UserConfigRepositoryTest.kt | 26 +++++++++++++++++++ 8 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 .gitmodules create mode 160000 cq-sdk create mode 100644 src/test/kotlin/kurenai/imsyncbot/UserConfigRepositoryTest.kt diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..72a8f6e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cq-sdk"] + path = cq-sdk + url = https://github.com/KurenaiRyu/cq-sdk.git diff --git a/build.gradle.kts b/build.gradle.kts index d656ed0..31b9254 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,13 +5,13 @@ plugins { id("org.springframework.boot") version "3.1.0" id("io.spring.dependency-management") version "1.1.0" id("io.freefair.lombok") version "8.1.0" - kotlin("jvm") version "1.9.0" - kotlin("plugin.spring") version "1.9.0" - kotlin("plugin.lombok") version "1.9.0" - kotlin("plugin.serialization") version "1.9.0" - kotlin("plugin.allopen") version "1.9.0" - kotlin("plugin.noarg") version "1.9.0" - kotlin("plugin.jpa") version "1.9.0" + kotlin("jvm") version "1.9.10" + kotlin("plugin.spring") version "1.9.10" + kotlin("plugin.lombok") version "1.9.10" + kotlin("plugin.serialization") version "1.9.10" + kotlin("plugin.allopen") version "1.9.10" + kotlin("plugin.noarg") version "1.9.10" + kotlin("plugin.jpa") version "1.9.10" jacoco } @@ -51,6 +51,7 @@ object Versions { const val LOMBOK = "1.18.28" } dependencies { + implementation(project(":cq-sdk")) implementation("org.jetbrains.kotlin", "kotlin-reflect") implementation("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") diff --git a/cq-sdk b/cq-sdk new file mode 160000 index 0000000..4378697 --- /dev/null +++ b/cq-sdk @@ -0,0 +1 @@ +Subproject commit 43786974eedaef02c4198d95a5e4ea5ca31c82bb diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 84a0b92..e411586 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 74a8974..d77c966 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,5 @@ rootProject.name = "im-sync-bot" +include(":cq-sdk") pluginManagement { repositories { mavenCentral() diff --git a/src/main/java/kurenai/imsyncbot/domain/UserConfig.java b/src/main/java/kurenai/imsyncbot/domain/UserConfig.java index fbd2026..eb60030 100644 --- a/src/main/java/kurenai/imsyncbot/domain/UserConfig.java +++ b/src/main/java/kurenai/imsyncbot/domain/UserConfig.java @@ -1,8 +1,8 @@ package kurenai.imsyncbot.domain; import jakarta.persistence.*; -import kurenai.imsyncbot.service.UserStatus; import kurenai.imsyncbot.configuration.annotation.SnowFlakeGenerator; +import kurenai.imsyncbot.service.UserStatus; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -20,6 +20,11 @@ @Data @NoArgsConstructor @AllArgsConstructor +@FieldNameConstants +@NamedEntityGraph( + name = "user", + includeAllAttributes = true +) public class UserConfig { @Id diff --git a/src/main/kotlin/kurenai/imsyncbot/repository/UserConfigRepository.kt b/src/main/kotlin/kurenai/imsyncbot/repository/UserConfigRepository.kt index 89336e0..7858531 100644 --- a/src/main/kotlin/kurenai/imsyncbot/repository/UserConfigRepository.kt +++ b/src/main/kotlin/kurenai/imsyncbot/repository/UserConfigRepository.kt @@ -1,8 +1,6 @@ package kurenai.imsyncbot.repository -import kurenai.imsyncbot.domain.GroupConfig import kurenai.imsyncbot.domain.UserConfig -import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.JpaSpecificationExecutor diff --git a/src/test/kotlin/kurenai/imsyncbot/UserConfigRepositoryTest.kt b/src/test/kotlin/kurenai/imsyncbot/UserConfigRepositoryTest.kt new file mode 100644 index 0000000..15ad0c5 --- /dev/null +++ b/src/test/kotlin/kurenai/imsyncbot/UserConfigRepositoryTest.kt @@ -0,0 +1,26 @@ +package kurenai.imsyncbot + +import jakarta.persistence.EntityGraph +import jakarta.persistence.EntityManager +import kurenai.imsyncbot.domain.UserConfig +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class UserConfigRepositoryTest { + + @Autowired + private lateinit var em: EntityManager + + @Test + fun test() { + val entityGraph: EntityGraph<*>? = em.getEntityGraph("user") + val cb = em.criteriaBuilder + val criteriaQuery = cb.createQuery() + val root = criteriaQuery.from(UserConfig::class.java) + val typedQuery = + em.createQuery(criteriaQuery.where(cb.equal(root.get(UserConfig.Fields.bindingName), "kurenai"))) + typedQuery.setHint("jakarta.persistence.fetchgraph", entityGraph).resultList as List + } +} \ No newline at end of file