mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 08:38:26 +08:00
Compare commits
14 Commits
3967aac363
...
41b52fa6c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41b52fa6c2 | ||
|
|
29d82efa64 | ||
|
|
9afcb9514d | ||
|
|
c65a3608f8 | ||
|
|
324810803b | ||
|
|
be7d089264 | ||
|
|
c19896750c | ||
|
|
c3346a4aac | ||
|
|
3cb3563508 | ||
|
|
aa08da881a | ||
|
|
aaa2566b12 | ||
|
|
66c1cd0850 | ||
|
|
7289b15478 | ||
|
|
ecbd87a1ae |
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -24,7 +25,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
@ -121,7 +122,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
@ -135,7 +136,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -24,13 +25,13 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-annotation</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -99,13 +100,6 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-annotation</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -97,11 +97,12 @@ public class AuditManager {
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static <T> T startAudit(AuditRunnable<T> supplier, Statement statement, BoundSql boundSql, Configuration configuration) throws SQLException {
|
||||
public static <T> T startAudit(AuditRunnable<T> supplier, String stmtId, Statement statement, BoundSql boundSql, Configuration configuration) throws SQLException {
|
||||
AuditMessage auditMessage = messageFactory.create();
|
||||
if (auditMessage == null) {
|
||||
return supplier.execute();
|
||||
}
|
||||
auditMessage.setStmtId(stmtId);
|
||||
String key = DataSourceKey.get();
|
||||
if (StringUtil.noText(key)) {
|
||||
key = FlexGlobalConfig.getDefaultConfig()
|
||||
|
||||
@ -95,6 +95,11 @@ public class AuditMessage implements Serializable {
|
||||
*/
|
||||
private long elapsedTime;
|
||||
|
||||
/**
|
||||
* MappedStatement ID
|
||||
*/
|
||||
private String stmtId;
|
||||
|
||||
/**
|
||||
* 数据库名称。
|
||||
*/
|
||||
@ -270,6 +275,14 @@ public class AuditMessage implements Serializable {
|
||||
metas.put(key, value);
|
||||
}
|
||||
|
||||
public String getStmtId() {
|
||||
return stmtId;
|
||||
}
|
||||
|
||||
public void setStmtId(String stmtId) {
|
||||
this.stmtId = stmtId;
|
||||
}
|
||||
|
||||
public String getDsName() {
|
||||
return dsName;
|
||||
}
|
||||
@ -293,6 +306,7 @@ public class AuditMessage implements Serializable {
|
||||
", queryCount=" + queryCount +
|
||||
", queryTime=" + queryTime +
|
||||
", elapsedTime=" + elapsedTime +
|
||||
", stmtId=" + stmtId +
|
||||
", dsName=" + dsName +
|
||||
", metas=" + metas +
|
||||
'}';
|
||||
|
||||
@ -144,6 +144,9 @@ public class FuncName {
|
||||
public static final String WEEKOFYEAR = "WEEKOFYEAR";
|
||||
public static final String YEAR = "YEAR";
|
||||
public static final String GROUP_CONCAT = "GROUP_CONCAT";
|
||||
public static final String STRING_AGG = "STRING_AGG";
|
||||
public static final String LISTAGG = "LISTAGG";
|
||||
|
||||
private FuncName() {
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ package com.mybatisflex.core.dialect;
|
||||
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum DbType {
|
||||
|
||||
@ -208,4 +209,44 @@ public enum DbType {
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有数据库类型
|
||||
*
|
||||
* @return 包含所有数据库类型的列表
|
||||
*/
|
||||
public static List<DbType> all() {
|
||||
return Arrays.asList(DbType.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前数据库语法是否与MySQL属于同一类型
|
||||
*/
|
||||
public boolean mysqlSameType() {
|
||||
return this == MYSQL || this == MARIADB || this == GBASE || this == OSCAR || this == XUGU || this == CLICK_HOUSE || this == OCEAN_BASE || this == CUBRID || this == SUNDB || this == GOLDENDB || this == YASDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前数据库语法是否与Oracle属于同一类型
|
||||
*/
|
||||
public boolean oracleSameType() {
|
||||
return this == ORACLE || this == DM;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前数据库语法是否与PostgreSQL属于同一类型
|
||||
*/
|
||||
public boolean postgresqlSameType() {
|
||||
return this == POSTGRE_SQL || this == H2 || this == LEALONE || this == SQLITE || this == HSQL || this == KINGBASE_ES || this == PHOENIX || this == SAP_HANA || this == IMPALA || this == HIGH_GO || this == VERTICA || this == REDSHIFT || this == GAUSS || this == OPENGAUSS || this == TDENGINE || this == UXDB || this == GBASE_8S_PG || this == GBASE_8C || this == VASTBASE || this == DUCKDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为已兼容的数据库类型
|
||||
* 允许的数据库类型包括MySQL系列、Oracle系列和PostgreSQL系列
|
||||
*
|
||||
* @return 如果是允许的数据库类型返回true,否则返回false
|
||||
*/
|
||||
public boolean isSupportDb() {
|
||||
return mysqlSameType() || oracleSameType() || postgresqlSameType();
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
package com.mybatisflex.core.dialect;
|
||||
|
||||
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.exception.FlexExceptions;
|
||||
import com.mybatisflex.core.exception.locale.LocalizedFormats;
|
||||
import com.mybatisflex.core.util.StringUtil;
|
||||
@ -37,6 +38,20 @@ public class DbTypeUtil {
|
||||
private DbTypeUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前数据库类型
|
||||
* <p>首先从全局配置中获取数据库类型,如果全局配置中未设置,则尝试从方言工厂中获取线程局部变量设置的数据库类型
|
||||
*
|
||||
* @return 当前数据库类型,可能为null
|
||||
*/
|
||||
public static DbType getCurrentDbType() {
|
||||
DbType dbType = FlexGlobalConfig.getDefaultConfig().getDbType();
|
||||
if (dbType == null) {
|
||||
dbType = DialectFactory.getHintDbType();
|
||||
}
|
||||
return dbType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前配置的 DbType
|
||||
*/
|
||||
|
||||
@ -46,9 +46,11 @@ public class FlexStatementHandler implements StatementHandler {
|
||||
private final BoundSql boundSql;
|
||||
private final boolean auditEnable = AuditManager.isAuditEnable();
|
||||
private final Configuration configuration;
|
||||
private final String stmtId;
|
||||
|
||||
public FlexStatementHandler(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
||||
configuration = ms.getConfiguration();
|
||||
stmtId = ms.getId();
|
||||
switch (ms.getStatementType()) {
|
||||
case STATEMENT:
|
||||
delegate = new SimpleStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
|
||||
@ -83,7 +85,7 @@ public class FlexStatementHandler implements StatementHandler {
|
||||
AuditManager.startAudit(() -> {
|
||||
delegate.batch(statement);
|
||||
return null;
|
||||
}, statement, boundSql, configuration);
|
||||
}, stmtId, statement, boundSql, configuration);
|
||||
} else {
|
||||
delegate.batch(statement);
|
||||
}
|
||||
@ -91,19 +93,19 @@ public class FlexStatementHandler implements StatementHandler {
|
||||
|
||||
@Override
|
||||
public int update(Statement statement) throws SQLException {
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.update(statement), statement, boundSql, configuration)
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.update(statement), stmtId, statement, boundSql, configuration)
|
||||
: delegate.update(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> List<E> query(Statement statement, ResultHandler resultHandler) throws SQLException {
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.query(statement, resultHandler), statement, boundSql, configuration)
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.query(statement, resultHandler), stmtId, statement, boundSql, configuration)
|
||||
: delegate.query(statement, resultHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> Cursor<E> queryCursor(Statement statement) throws SQLException {
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.queryCursor(statement), statement, boundSql, configuration)
|
||||
return auditEnable ? AuditManager.startAudit(() -> delegate.queryCursor(statement), stmtId, statement, boundSql, configuration)
|
||||
: delegate.queryCursor(statement);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024, Mybatis-Flex (fuhai999@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.mybatisflex.core.query;
|
||||
|
||||
import com.mybatisflex.core.FlexConsts;
|
||||
import com.mybatisflex.core.dialect.IDialect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CAST函数查询列
|
||||
*/
|
||||
public class CastQueryColumn extends QueryColumn implements HasParamsColumn {
|
||||
|
||||
private QueryColumn column;
|
||||
private final String dataType;
|
||||
|
||||
public CastQueryColumn(QueryColumn column, String dataType) {
|
||||
this.column = column;
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public CastQueryColumn(String column, String dataType) {
|
||||
this.column = new QueryColumn(column);
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toConditionSql(List<QueryTable> queryTables, IDialect dialect) {
|
||||
return " CAST(" + column.toConditionSql(queryTables, dialect) + " AS " + dataType + ") ";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toSelectSql(List<QueryTable> queryTables, IDialect dialect) {
|
||||
return " CAST(" + column.toSelectSql(queryTables, dialect) + " AS " + dataType + ") " + WrapperUtil.buildColumnAlias(alias, dialect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastQueryColumn clone() {
|
||||
CastQueryColumn clone = (CastQueryColumn) super.clone();
|
||||
clone.column = column.clone();
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CastQueryColumn{" +
|
||||
"column=" + column +
|
||||
", dataType='" + dataType + '\'' +
|
||||
", alias='" + alias + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getParamValues() {
|
||||
if (column instanceof HasParamsColumn) {
|
||||
return ((HasParamsColumn) column).getParamValues();
|
||||
}
|
||||
return FlexConsts.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
@ -955,6 +955,10 @@ public class QueryColumn implements CloneSupport<QueryColumn>, Conditional<Query
|
||||
return new ArithmeticQueryColumn(this).divide(number);
|
||||
}
|
||||
|
||||
public QueryColumn cast(String dataType) {
|
||||
return new CastQueryColumn(this, dataType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成列用于构建查询条件的 SQL 语句。
|
||||
*
|
||||
|
||||
@ -2678,6 +2678,51 @@ public class QueryMethods {
|
||||
return new FunctionQueryColumn(GROUP_CONCAT, columnX);
|
||||
}
|
||||
|
||||
/**
|
||||
* STRING_AGG 聚合函数
|
||||
*/
|
||||
public static QueryColumn stringAgg(QueryColumn columnX, String separator) {
|
||||
return new FunctionQueryColumn(STRING_AGG, columnX, string(separator));
|
||||
}
|
||||
|
||||
public static QueryColumn stringAgg(String columnX, String separator) {
|
||||
return new FunctionQueryColumn(STRING_AGG, columnX, separator);
|
||||
}
|
||||
|
||||
public static <T> QueryColumn stringAgg(LambdaGetter<T> columnX, String separator) {
|
||||
return new FunctionQueryColumn(STRING_AGG, LambdaUtil.getQueryColumn(columnX), string(separator));
|
||||
}
|
||||
|
||||
/**
|
||||
* LISTAGG 聚合函数
|
||||
*/
|
||||
public static QueryColumn listAgg(QueryColumn column, String separator) {
|
||||
return new FunctionQueryColumn(LISTAGG, column, string(separator));
|
||||
}
|
||||
|
||||
public static QueryColumn listAgg(String column, String separator) {
|
||||
return new FunctionQueryColumn(STRING_AGG, column, separator);
|
||||
}
|
||||
|
||||
public static <T> QueryColumn listAgg(LambdaGetter<T> column, String separator) {
|
||||
return new FunctionQueryColumn(STRING_AGG, LambdaUtil.getQueryColumn(column), string(separator));
|
||||
}
|
||||
|
||||
/**
|
||||
* CAST函数查询列
|
||||
*/
|
||||
public static <T> QueryColumn cast(QueryColumn column, String dataType) {
|
||||
return new CastQueryColumn(column, dataType);
|
||||
}
|
||||
|
||||
public static <T> QueryColumn cast(String column, String dataType) {
|
||||
return new CastQueryColumn(column, dataType);
|
||||
}
|
||||
|
||||
public static <T> QueryColumn cast(LambdaGetter<T> column, String dataType) {
|
||||
return new CastQueryColumn(LambdaUtil.getQueryColumn(column), dataType);
|
||||
}
|
||||
|
||||
/**
|
||||
* date 函数
|
||||
* @return
|
||||
|
||||
@ -4,9 +4,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<parent>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>mybatis-flex-dependencies</artifactId>
|
||||
<version>1.11.1</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@ -48,7 +53,6 @@
|
||||
</developer>
|
||||
</developers>
|
||||
<properties>
|
||||
<mybatis-flex.version>1.11.1</mybatis-flex.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@ -56,42 +60,42 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-annotation</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-codegen</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
@ -185,6 +189,115 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>flatten-maven-plugin</artifactId>
|
||||
<version>${flatten-maven-plugin.version}</version>
|
||||
<inherited>false</inherited>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Create an effective POM (with versions expanded) for the CLI and
|
||||
documentation -->
|
||||
<id>flatten-effective-pom</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>flatten</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<updatePomFile>false</updatePomFile>
|
||||
<outputDirectory>${project.build.directory}/effective-pom</outputDirectory>
|
||||
<flattenMode>resolveCiFriendliesOnly</flattenMode>
|
||||
<pomElements>
|
||||
<dependencyManagement>expand</dependencyManagement>
|
||||
<pluginManagement>expand</pluginManagement>
|
||||
<properties>remove</properties>
|
||||
<repositories>remove</repositories>
|
||||
</pomElements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<!-- Flatten and simplify our own POM for install/deploy -->
|
||||
<id>flatten</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>flatten</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<updatePomFile>true</updatePomFile>
|
||||
<flattenMode>bom</flattenMode>
|
||||
<pomElements>
|
||||
<pluginManagement>keep</pluginManagement>
|
||||
<properties>keep</properties>
|
||||
<repositories>remove</repositories>
|
||||
</pomElements>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>flatten-clean</id>
|
||||
<phase>clean</phase>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<version>${xml-maven-plugin.version}</version>
|
||||
<inherited>false</inherited>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Cleanup the effective POM -->
|
||||
<id>post-process-effective-pom</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${project.build.directory}/effective-pom</dir>
|
||||
<outputDir>${project.build.directory}/effective-pom</outputDir>
|
||||
<stylesheet>src/main/xslt/post-process-flattened-pom.xsl</stylesheet>
|
||||
<outputProperties>
|
||||
<outputProperty>
|
||||
<name>indent</name>
|
||||
<value>yes</value>
|
||||
</outputProperty>
|
||||
</outputProperties>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<!-- Cleanup the flattened project POM -->
|
||||
<id>post-process-flattened-pom</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformationSets>
|
||||
<transformationSet>
|
||||
<dir>${project.basedir}</dir>
|
||||
<outputDir>${project.basedir}</outputDir>
|
||||
<includes>.flattened-pom.xml</includes>
|
||||
<stylesheet>src/main/xslt/post-process-flattened-pom.xsl</stylesheet>
|
||||
<outputProperties>
|
||||
<outputProperty>
|
||||
<name>indent</name>
|
||||
<value>yes</value>
|
||||
</outputProperty>
|
||||
</outputProperties>
|
||||
</transformationSet>
|
||||
</transformationSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://maven.apache.org/POM/4.0.0"
|
||||
exclude-result-prefixes="m">
|
||||
<xsl:output method="xml" encoding="utf-8" indent="yes"
|
||||
xslt:indent-amount="2" xmlns:xslt="http://xml.apache.org/xslt" />
|
||||
<xsl:strip-space elements="*" />
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template match="/m:project/m:properties">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="node()">
|
||||
<xsl:sort select="name()" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template
|
||||
match="/m:project/m:dependencyManagement/m:dependencies/m:dependency/m:version/text()[. = '${revision}']">
|
||||
<xsl:value-of select="/m:project/m:version/text()" />
|
||||
</xsl:template>
|
||||
<xsl:template
|
||||
match="/m:project/m:build/m:pluginManagement/m:plugins/m:plugin/m:version/text()[. = '${revision}']">
|
||||
<xsl:value-of select="/m:project/m:version/text()" />
|
||||
</xsl:template>
|
||||
<xsl:template match="/m:project/m:properties/m:revision" />
|
||||
<xsl:template match="/m:project/m:properties/m:main.basedir" />
|
||||
</xsl:stylesheet>
|
||||
@ -6,7 +6,8 @@
|
||||
<parent>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>mybatis-flex-loveqq-starter</name>
|
||||
@ -34,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -5,15 +5,14 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<name>mybatis-flex-processor</name>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.11.1</version>
|
||||
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
@ -24,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-annotation</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -29,7 +30,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -24,7 +25,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -105,7 +106,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
<parent>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>mybatis-flex-spring-boot3-starter</name>
|
||||
@ -21,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.mybatis</groupId>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>1.11.1</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -44,11 +45,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.batch</groupId>
|
||||
<artifactId>spring-batch-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.batch</groupId>
|
||||
<artifactId>spring-batch-infrastructure</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.0</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>mybatis-flex-loveqq-test</name>
|
||||
@ -28,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-loveqq-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -21,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -25,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -96,7 +97,7 @@
|
||||
<path>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -57,7 +58,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -84,7 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring-test</artifactId>
|
||||
<version>1.10.9</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -94,6 +95,7 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>mybatis-flex-test</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -23,13 +24,13 @@
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-core</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-spring</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -18,6 +18,9 @@ package com.mybatisflex.test.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.mybatisflex.test.model.Account;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 王帅
|
||||
@ -25,4 +28,7 @@ import com.mybatisflex.test.model.Account;
|
||||
*/
|
||||
public interface AccountMapper extends BaseMapper<Account> {
|
||||
|
||||
@Select("select * from tb_account")
|
||||
List<Account> selectAccounts();
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
package com.mybatisflex.test;
|
||||
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.audit.AuditMessage;
|
||||
import com.mybatisflex.core.audit.MessageCollector;
|
||||
import com.mybatisflex.test.mapper.AccountMapper;
|
||||
import com.mybatisflex.test.mapper.TbClassMapper;
|
||||
import lombok.Getter;
|
||||
import org.assertj.core.api.WithAssertions;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = AppConfig.class)
|
||||
public class AuditTest implements WithAssertions {
|
||||
@Autowired
|
||||
AccountMapper accountMapper;
|
||||
@Autowired
|
||||
TbClassMapper tbClassMapper;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
TestMsgCollector collector = new TestMsgCollector();
|
||||
AuditManager.setMessageCollector(collector);
|
||||
AuditManager.setAuditEnable(true);
|
||||
accountMapper.selectAccounts();
|
||||
tbClassMapper.selectAll();
|
||||
List<AuditMessage> messages = collector.getMessages();
|
||||
assertThat(messages.size()).isEqualTo(2);
|
||||
assertThat(messages.get(0).getStmtId()).isEqualTo("com.mybatisflex.test.mapper.AccountMapper.selectAccounts");
|
||||
assertThat(messages.get(1).getStmtId()).isEqualTo("com.mybatisflex.test.mapper.TbClassMapper.selectListByQuery");
|
||||
}
|
||||
|
||||
static class TestMsgCollector implements MessageCollector {
|
||||
@Getter
|
||||
private final List<AuditMessage> messages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void collect(AuditMessage message) {
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,8 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -76,7 +77,7 @@
|
||||
<path>
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
<version>${mybatis-flex.version}</version>
|
||||
<version>${project.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
|
||||
11
pom.xml
11
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.11.1</version>
|
||||
<version>${revision}</version>
|
||||
|
||||
<name>mybatis-flex</name>
|
||||
<url>https://mybatis-flex.com</url>
|
||||
@ -62,10 +62,17 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
||||
<mybatis-flex.version>1.11.1</mybatis-flex.version>
|
||||
<!-- Mybatis-Flex 版本 -->
|
||||
<revision>1.11.1</revision>
|
||||
|
||||
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
|
||||
<xml-maven-plugin.version>1.1.0</xml-maven-plugin.version>
|
||||
|
||||
<mybatis.version>3.5.19</mybatis.version>
|
||||
<mybatis-spring.version>2.1.2</mybatis-spring.version>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user