Skip to content

Commit

Permalink
Update 24.5.22
Browse files Browse the repository at this point in the history
  • Loading branch information
KurenaiRyu committed May 21, 2024
1 parent 42125e0 commit cba3c59
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cq-sdk"]
path = cq-sdk
url = https://github.com/KurenaiRyu/cq-sdk.git
15 changes: 8 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions cq-sdk
Submodule cq-sdk added at 437869
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProject.name = "im-sync-bot"
include(":cq-sdk")
pluginManagement {
repositories {
mavenCentral()
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/kurenai/imsyncbot/domain/UserConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,6 +20,11 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@NamedEntityGraph(
name = "user",
includeAllAttributes = true
)
public class UserConfig {

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
26 changes: 26 additions & 0 deletions src/test/kotlin/kurenai/imsyncbot/UserConfigRepositoryTest.kt
Original file line number Diff line number Diff line change
@@ -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<String>(UserConfig.Fields.bindingName), "kurenai")))
typedQuery.setHint("jakarta.persistence.fetchgraph", entityGraph).resultList as List<UserConfig>
}
}

0 comments on commit cba3c59

Please sign in to comment.