feat: 暂存
This commit is contained in:
parent
67db4da315
commit
a2ebeb1526
@ -37,6 +37,7 @@
|
||||
<groupId>group.flyfish.framework</groupId>
|
||||
<artifactId>fluent-sql-core</artifactId>
|
||||
<version>0.0.5</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -0,0 +1,80 @@
|
||||
package dev.flyfish.framework.r2dbc.config;
|
||||
|
||||
import dev.flyfish.framework.r2dbc.operations.R2dbcFluentOperations;
|
||||
import group.flyfish.fluent.chain.common.ExecutableSql;
|
||||
import group.flyfish.fluent.entity.SQLEntity;
|
||||
import group.flyfish.fluent.operations.FluentSQLOperations;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.r2dbc.core.DatabaseClient;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* fluent风格的sql编写支持
|
||||
* 基于fluent sql
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@ConditionalOnClass(FluentSQLOperations.class)
|
||||
@ConditionalOnBean(DatabaseClient.class)
|
||||
class FluentR2dbcAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public R2dbcFluentOperations r2dbcFluentOperations(DatabaseClient databaseClient) {
|
||||
return new DefaultFluentOperations(databaseClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认的实现
|
||||
*
|
||||
* @author wangyu
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
private static class DefaultFluentOperations implements R2dbcFluentOperations {
|
||||
|
||||
private final DatabaseClient databaseClient;
|
||||
|
||||
@Override
|
||||
public <T> Mono<T> findOne(ExecutableSql sql) {
|
||||
SQLEntity entity = new SQLEntity();
|
||||
DatabaseClient.GenericExecuteSpec spec = databaseClient.sql(entity::getSql);
|
||||
Object[] bindings = entity.getParameters();
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
spec.bind(i, bindings[i]);
|
||||
}
|
||||
return spec.mapValue()
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Flux<T> find(ExecutableSql sql) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Mono<Page<T>> find(ExecutableSql sql, Pageable pageable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Mono<T> findOne(ExecutableSql sql, Class<T> resultType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Flux<T> find(ExecutableSql sql, Class<T> resultType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Mono<Page<T>> find(ExecutableSql sql, Pageable pageable, Class<T> resultType) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,20 +16,22 @@ public interface R2dbcFluentOperations {
|
||||
/**
|
||||
* 查询单个
|
||||
*
|
||||
* @param sql 可执行sql
|
||||
* @param <T> 泛型
|
||||
* @param sql 可执行sql
|
||||
* @param resultType 结果类型
|
||||
* @param <T> 泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<T> Mono<T> findOne(ExecutableSql sql);
|
||||
<T> Mono<T> findOne(ExecutableSql sql, Class<T> resultType);
|
||||
|
||||
/**
|
||||
* 查询单个
|
||||
*
|
||||
* @param sql 可执行sql
|
||||
* @param <T> 泛型
|
||||
* @param sql 可执行sql
|
||||
* @param resultType 结果类型
|
||||
* @param <T> 泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<T> Flux<T> find(ExecutableSql sql);
|
||||
<T> Flux<T> find(ExecutableSql sql, Class<T> resultType);
|
||||
|
||||
/**
|
||||
* 查询分页对象
|
||||
@ -38,5 +40,5 @@ public interface R2dbcFluentOperations {
|
||||
* @param <T> 泛型
|
||||
* @return 结果
|
||||
*/
|
||||
<T> Mono<Page<T>> find(ExecutableSql sql, Pageable pageable);
|
||||
<T> Mono<Page<T>> find(ExecutableSql sql, Pageable pageable, Class<T> resultType);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user