diff --git a/boot/platform/build.gradle b/boot/platform/build.gradle index 96af37be..084fe1fb 100644 --- a/boot/platform/build.gradle +++ b/boot/platform/build.gradle @@ -14,6 +14,8 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springframework.boot:spring-boot-starter-data-redis-reactive") + //implementation("org.springframework.boot:spring-boot-starter-jooq") + implementation("org.jooq:jooq") implementation("org.springframework.boot:spring-boot-starter-data-r2dbc") implementation("org.postgresql:r2dbc-postgresql") diff --git a/boot/platform/src/main/java/com/plate/boot/commons/utils/ContextUtils.java b/boot/platform/src/main/java/com/plate/boot/commons/utils/ContextUtils.java index 5b9b20a4..1e4c7bcc 100644 --- a/boot/platform/src/main/java/com/plate/boot/commons/utils/ContextUtils.java +++ b/boot/platform/src/main/java/com/plate/boot/commons/utils/ContextUtils.java @@ -7,6 +7,7 @@ import com.plate.boot.security.SecurityDetails; import com.plate.boot.security.core.user.UsersService; import lombok.extern.log4j.Log4j2; +import org.jooq.DSLContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.http.HttpHeaders; import org.springframework.http.server.reactive.ServerHttpRequest; @@ -34,6 +35,7 @@ @Component public final class ContextUtils implements InitializingBean { + /** * Constant defining the role identifier for administrators within the system. * This role grants access to administrative functionalities and permissions. @@ -105,15 +107,18 @@ public final class ContextUtils implements InitializingBean { */ public static UsersService USERS_SERVICE; + public static DSLContext JOOQDSL; + /** * Initializes the ContextUtils class with necessary dependencies. * * @param objectMapper The ObjectMapper instance used for JSON serialization and deserialization. * @param usersService The UsersService instance to provide access to user-related operations. */ - ContextUtils(ObjectMapper objectMapper, UsersService usersService) { + ContextUtils(ObjectMapper objectMapper, UsersService usersService, DSLContext create) { ContextUtils.OBJECT_MAPPER = objectMapper; ContextUtils.USERS_SERVICE = usersService; + ContextUtils.JOOQDSL = create; } /** diff --git a/boot/platform/src/main/java/com/plate/boot/config/R2dbcConfiguration.java b/boot/platform/src/main/java/com/plate/boot/config/R2dbcConfiguration.java index 955cb4e6..9c5d36b0 100644 --- a/boot/platform/src/main/java/com/plate/boot/config/R2dbcConfiguration.java +++ b/boot/platform/src/main/java/com/plate/boot/config/R2dbcConfiguration.java @@ -6,6 +6,9 @@ import io.r2dbc.spi.ConnectionFactories; import io.r2dbc.spi.ConnectionFactory; import lombok.RequiredArgsConstructor; +import org.jooq.DSLContext; +import org.jooq.SQLDialect; +import org.jooq.impl.DSL; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; @@ -13,6 +16,7 @@ import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration; import org.springframework.data.r2dbc.config.EnableR2dbcAuditing; import org.springframework.lang.NonNull; +import org.springframework.r2dbc.connection.TransactionAwareConnectionFactoryProxy; import org.springframework.transaction.annotation.EnableTransactionManagement; import java.util.List; @@ -71,4 +75,11 @@ public ReactiveAuditorAware userAuditorProvider() { return new UserAuditorAware(); } + @Bean + public DSLContext dslContext(ConnectionFactory connectionFactory) { + return DSL.using( + new TransactionAwareConnectionFactoryProxy(connectionFactory), + SQLDialect.POSTGRES + ); + } } \ No newline at end of file diff --git a/boot/platform/src/test/java/com/plate/boot/commons/utils/query/QueryHelperTest.java b/boot/platform/src/test/java/com/plate/boot/commons/utils/query/QueryHelperTest.java index 78c599fb..ac21f142 100644 --- a/boot/platform/src/test/java/com/plate/boot/commons/utils/query/QueryHelperTest.java +++ b/boot/platform/src/test/java/com/plate/boot/commons/utils/query/QueryHelperTest.java @@ -1,4 +1,10 @@ package com.plate.boot.commons.utils.query; +import org.junit.jupiter.api.Test; + class QueryHelperTest { + + @Test + void jooqTest() { + } } \ No newline at end of file