Compare commits

..

3 Commits

Author SHA1 Message Date
00c3ed537a feat: 正式版发布 2024-07-13 13:59:13 +08:00
e5b2fba283 feat: 正式版发布 2024-07-13 13:54:50 +08:00
f0b48ba785 feat: spring boot 2.x封版 2024-07-13 13:00:48 +08:00
12 changed files with 50 additions and 29 deletions

View File

@ -5,14 +5,14 @@
<parent> <parent>
<artifactId>fluent-sql</artifactId> <artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId> <groupId>group.flyfish.framework</groupId>
<version>0.1.0</version> <version>1.0.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>fluent-sql-annotations</artifactId> <artifactId>fluent-sql-annotations</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
</project> </project>

View File

@ -5,15 +5,15 @@
<parent> <parent>
<artifactId>fluent-sql</artifactId> <artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId> <groupId>group.flyfish.framework</groupId>
<version>0.1.0</version> <version>1.0.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>fluent-sql-core</artifactId> <artifactId>fluent-sql-core</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>

View File

@ -369,7 +369,7 @@ final class SQLImpl extends ConcatSegment<SQLImpl> implements SQLOperations, Pre
} }
@Override @Override
public Mono<Integer> execute() { public Mono<Long> execute() {
return SHARED_REACTIVE_OPERATIONS.execute(entity); return SHARED_REACTIVE_OPERATIONS.execute(entity);
} }
} }

View File

@ -44,5 +44,5 @@ public interface ReactiveBoundEntitySpec<T> {
* *
* @return 更新行数 * @return 更新行数
*/ */
Mono<Integer> execute(); Mono<Long> execute();
} }

View File

@ -2,7 +2,6 @@ package group.flyfish.fluent.operations;
import group.flyfish.fluent.entity.BoundSQLEntity; import group.flyfish.fluent.entity.BoundSQLEntity;
import group.flyfish.fluent.entity.DataPage; import group.flyfish.fluent.entity.DataPage;
import group.flyfish.fluent.entity.SQLEntity;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -50,5 +49,5 @@ public interface ReactiveFluentSQLOperations {
* @param entity sql实体 * @param entity sql实体
* @return 更新行数 * @return 更新行数
*/ */
<T> Mono<Integer> execute(BoundSQLEntity<T> entity); <T> Mono<Long> execute(BoundSQLEntity<T> entity);
} }

View File

@ -4,6 +4,7 @@ import group.flyfish.fluent.utils.cache.LRUCache;
import group.flyfish.fluent.utils.context.AliasComposite; import group.flyfish.fluent.utils.context.AliasComposite;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -27,6 +28,9 @@ import static group.flyfish.fluent.utils.sql.SqlNameUtils.wrap;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class EntityNameUtils { public final class EntityNameUtils {
private static final String JPA_TABLE = "javax.persistence.Table";
private static final String SPRING_DATA_TABLE = "org.springframework.data.relational.core.mapping.Table";
// SerializedLambda 反序列化缓存 // SerializedLambda 反序列化缓存
private static final Map<String, WeakReference<SerializedLambda>> FUNC_CACHE = new ConcurrentHashMap<>(); private static final Map<String, WeakReference<SerializedLambda>> FUNC_CACHE = new ConcurrentHashMap<>();
@ -57,9 +61,18 @@ public final class EntityNameUtils {
*/ */
public static String getTableName(Class<?> entityClass) { public static String getTableName(Class<?> entityClass) {
return TABLE_CACHE.computeIfAbsent(entityClass, k -> { return TABLE_CACHE.computeIfAbsent(entityClass, k -> {
Table table = entityClass.getAnnotation(Table.class); MergedAnnotations annotations = MergedAnnotations.from(entityClass);
if (null != table && StringUtils.hasText(table.name())) { if (annotations.isPresent(JPA_TABLE)) {
return table.name(); String tableName = annotations.get(JPA_TABLE).getString("name");
if (StringUtils.hasText(tableName)) {
return tableName;
}
}
if (annotations.isPresent(SPRING_DATA_TABLE)) {
String tableName = annotations.get(SPRING_DATA_TABLE).getString("name");
if (StringUtils.hasText(tableName)) {
return tableName;
}
} }
return wrap(SqlNameUtils.camelToUnderline(entityClass.getSimpleName())); return wrap(SqlNameUtils.camelToUnderline(entityClass.getSimpleName()));
}); });

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>fluent-sql</artifactId> <artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId> <groupId>group.flyfish.framework</groupId>
<version>0.1.0</version> <version>1.0.0</version>
</parent> </parent>
<description>spring boot 快速集成组件</description> <description>spring boot 快速集成组件</description>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -13,8 +13,8 @@
<artifactId>fluent-sql-spring-boot-starter</artifactId> <artifactId>fluent-sql-spring-boot-starter</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>

View File

@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
@ -23,11 +24,11 @@ import javax.sql.DataSource;
* *
* @author wangyu * @author wangyu
*/ */
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@Import({R2dbcFluentSqlAutoConfigure.class, JdbcFluentSqlAutoConfigure.class}) @Import({R2dbcFluentSqlAutoConfigure.class, JdbcFluentSqlAutoConfigure.class})
public class FluentSqlAutoConfiguration { public class FluentSqlAutoConfiguration {
@ConditionalOnClass(DatabaseClient.class) @ConditionalOnClass(DatabaseClient.class)
@AutoConfigureAfter(R2dbcAutoConfiguration.class)
static class R2dbcFluentSqlAutoConfigure { static class R2dbcFluentSqlAutoConfigure {
/** /**
@ -44,6 +45,7 @@ public class FluentSqlAutoConfiguration {
} }
@ConditionalOnClass(DataSource.class) @ConditionalOnClass(DataSource.class)
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
static class JdbcFluentSqlAutoConfigure { static class JdbcFluentSqlAutoConfigure {
/** /**

View File

@ -5,15 +5,15 @@
<parent> <parent>
<artifactId>fluent-sql</artifactId> <artifactId>fluent-sql</artifactId>
<groupId>group.flyfish.framework</groupId> <groupId>group.flyfish.framework</groupId>
<version>0.1.0</version> <version>1.0.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>fluent-sql-spring</artifactId> <artifactId>fluent-sql-spring</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
@ -49,7 +49,6 @@
<dependency> <dependency>
<groupId>io.asyncer</groupId> <groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId> <artifactId>r2dbc-mysql</artifactId>
<version>0.9.7</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,5 +1,6 @@
package group.flyfish.fluent.mapping; package group.flyfish.fluent.mapping;
import io.r2dbc.spi.ColumnMetadata;
import io.r2dbc.spi.Row; import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata; import io.r2dbc.spi.RowMetadata;
import org.springframework.dao.DataRetrievalFailureException; import org.springframework.dao.DataRetrievalFailureException;
@ -48,7 +49,8 @@ public class ReactiveSQLMappedRowMapper<T> implements BiFunction<Row, RowMetadat
public T apply(Row row, RowMetadata rowMetadata) { public T apply(Row row, RowMetadata rowMetadata) {
MappingBean<T> bean = descriptor.create(); MappingBean<T> bean = descriptor.create();
for (String column : rowMetadata.getColumnNames()) { for (ColumnMetadata metadata : rowMetadata.getColumnMetadatas()) {
String column = metadata.getName();
try { try {
bean.setValue(column, type -> row.get(column, type)); bean.setValue(column, type -> row.get(column, type));
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -61,7 +61,7 @@ public class R2dbcFluentSQLOperations implements ReactiveFluentSQLOperations {
* @return 更新行数 * @return 更新行数
*/ */
@Override @Override
public <T> Mono<Integer> execute(BoundSQLEntity<T> entity) { public <T> Mono<Long> execute(BoundSQLEntity<T> entity) {
return resolve(entity).fetch().rowsUpdated(); return resolve(entity).fetch().rowsUpdated();
} }

18
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>group.flyfish.framework</groupId> <groupId>group.flyfish.framework</groupId>
<artifactId>fluent-sql</artifactId> <artifactId>fluent-sql</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.1.0</version> <version>1.0.0</version>
<name>fluent-sql</name> <name>fluent-sql</name>
<description>A very fast sql generation engine using fluent-style api. Help you start your work without mybatis</description> <description>A very fast sql generation engine using fluent-style api. Help you start your work without mybatis</description>
@ -35,12 +35,12 @@
</modules> </modules>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
<lombok.version>1.18.24</lombok.version> <lombok.version>1.18.24</lombok.version>
<jackson.version>2.17.2</jackson.version> <jackson.version>2.17.2</jackson.version>
<spring-boot.version>2.7.18</spring-boot.version> <spring-boot.version>3.3.1</spring-boot.version>
<spring.version>5.3.22</spring.version> <spring.version>6.1.10</spring.version>
</properties> </properties>
<!-- 开发人员信息 --> <!-- 开发人员信息 -->
@ -158,6 +158,12 @@
<version>8.0.29</version> <version>8.0.29</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>io.projectreactor</groupId> <groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId> <artifactId>reactor-core</artifactId>
@ -204,7 +210,7 @@
<plugin> <plugin>
<groupId>org.sonatype.plugins</groupId> <groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId> <artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version> <version>1.7.0</version>
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<serverId>ossrh</serverId> <serverId>ossrh</serverId>