feat: 清理代码
This commit is contained in:
parent
a2ebeb1526
commit
3bd0119fbf
@ -1,80 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package dev.flyfish.framework.r2dbc.operations;
|
|
||||||
|
|
||||||
import group.flyfish.fluent.chain.common.ExecutableSql;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 我们为实际开发提供了响应式链,避免写sql
|
|
||||||
*
|
|
||||||
* @author wangyu
|
|
||||||
*/
|
|
||||||
public interface R2dbcFluentOperations {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询单个
|
|
||||||
*
|
|
||||||
* @param sql 可执行sql
|
|
||||||
* @param resultType 结果类型
|
|
||||||
* @param <T> 泛型
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
<T> Mono<T> findOne(ExecutableSql sql, Class<T> resultType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询单个
|
|
||||||
*
|
|
||||||
* @param sql 可执行sql
|
|
||||||
* @param resultType 结果类型
|
|
||||||
* @param <T> 泛型
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
<T> Flux<T> find(ExecutableSql sql, Class<T> resultType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询分页对象
|
|
||||||
*
|
|
||||||
* @param sql 可执行sql
|
|
||||||
* @param <T> 泛型
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
<T> Mono<Page<T>> find(ExecutableSql sql, Pageable pageable, Class<T> resultType);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user