mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
commit
29d82efa64
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
@ -122,7 +122,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
@ -136,7 +136,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
|
|||||||
@ -25,13 +25,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
<artifactId>mybatis-flex-annotation</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -100,13 +100,6 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mybatis-flex</groupId>
|
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -97,11 +97,12 @@ public class AuditManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@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();
|
AuditMessage auditMessage = messageFactory.create();
|
||||||
if (auditMessage == null) {
|
if (auditMessage == null) {
|
||||||
return supplier.execute();
|
return supplier.execute();
|
||||||
}
|
}
|
||||||
|
auditMessage.setStmtId(stmtId);
|
||||||
String key = DataSourceKey.get();
|
String key = DataSourceKey.get();
|
||||||
if (StringUtil.noText(key)) {
|
if (StringUtil.noText(key)) {
|
||||||
key = FlexGlobalConfig.getDefaultConfig()
|
key = FlexGlobalConfig.getDefaultConfig()
|
||||||
|
|||||||
@ -95,6 +95,11 @@ public class AuditMessage implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private long elapsedTime;
|
private long elapsedTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MappedStatement ID
|
||||||
|
*/
|
||||||
|
private String stmtId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库名称。
|
* 数据库名称。
|
||||||
*/
|
*/
|
||||||
@ -270,6 +275,14 @@ public class AuditMessage implements Serializable {
|
|||||||
metas.put(key, value);
|
metas.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStmtId() {
|
||||||
|
return stmtId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStmtId(String stmtId) {
|
||||||
|
this.stmtId = stmtId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDsName() {
|
public String getDsName() {
|
||||||
return dsName;
|
return dsName;
|
||||||
}
|
}
|
||||||
@ -293,6 +306,7 @@ public class AuditMessage implements Serializable {
|
|||||||
", queryCount=" + queryCount +
|
", queryCount=" + queryCount +
|
||||||
", queryTime=" + queryTime +
|
", queryTime=" + queryTime +
|
||||||
", elapsedTime=" + elapsedTime +
|
", elapsedTime=" + elapsedTime +
|
||||||
|
", stmtId=" + stmtId +
|
||||||
", dsName=" + dsName +
|
", dsName=" + dsName +
|
||||||
", metas=" + metas +
|
", metas=" + metas +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@ -46,9 +46,11 @@ public class FlexStatementHandler implements StatementHandler {
|
|||||||
private final BoundSql boundSql;
|
private final BoundSql boundSql;
|
||||||
private final boolean auditEnable = AuditManager.isAuditEnable();
|
private final boolean auditEnable = AuditManager.isAuditEnable();
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
|
private final String stmtId;
|
||||||
|
|
||||||
public FlexStatementHandler(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
public FlexStatementHandler(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
|
||||||
configuration = ms.getConfiguration();
|
configuration = ms.getConfiguration();
|
||||||
|
stmtId = ms.getId();
|
||||||
switch (ms.getStatementType()) {
|
switch (ms.getStatementType()) {
|
||||||
case STATEMENT:
|
case STATEMENT:
|
||||||
delegate = new SimpleStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
|
delegate = new SimpleStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
|
||||||
@ -83,7 +85,7 @@ public class FlexStatementHandler implements StatementHandler {
|
|||||||
AuditManager.startAudit(() -> {
|
AuditManager.startAudit(() -> {
|
||||||
delegate.batch(statement);
|
delegate.batch(statement);
|
||||||
return null;
|
return null;
|
||||||
}, statement, boundSql, configuration);
|
}, stmtId, statement, boundSql, configuration);
|
||||||
} else {
|
} else {
|
||||||
delegate.batch(statement);
|
delegate.batch(statement);
|
||||||
}
|
}
|
||||||
@ -91,19 +93,19 @@ public class FlexStatementHandler implements StatementHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int update(Statement statement) throws SQLException {
|
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);
|
: delegate.update(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> List<E> query(Statement statement, ResultHandler resultHandler) throws SQLException {
|
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);
|
: delegate.query(statement, resultHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> Cursor<E> queryCursor(Statement statement) throws SQLException {
|
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);
|
: delegate.queryCursor(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>mybatis-flex-dependencies</artifactId>
|
<artifactId>mybatis-flex-dependencies</artifactId>
|
||||||
<version>${revision}</version>
|
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
@ -61,42 +60,42 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
<artifactId>mybatis-flex-annotation</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-codegen</artifactId>
|
<artifactId>mybatis-flex-codegen</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -13,8 +13,6 @@
|
|||||||
<name>mybatis-flex-processor</name>
|
<name>mybatis-flex-processor</name>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>${revision}</version>
|
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
@ -25,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-annotation</artifactId>
|
<artifactId>mybatis-flex-annotation</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -106,7 +106,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.mybatis</groupId>
|
<groupId>org.mybatis</groupId>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-loveqq-starter</artifactId>
|
<artifactId>mybatis-flex-loveqq-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
<artifactId>mybatis-flex-solon-plugin</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -97,7 +97,7 @@
|
|||||||
<path>
|
<path>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -85,7 +85,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring-test</artifactId>
|
<artifactId>mybatis-flex-spring-test</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -95,6 +95,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
@ -24,13 +24,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-core</artifactId>
|
<artifactId>mybatis-flex-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-spring</artifactId>
|
<artifactId>mybatis-flex-spring</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -18,6 +18,9 @@ package com.mybatisflex.test.mapper;
|
|||||||
|
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
import com.mybatisflex.test.model.Account;
|
import com.mybatisflex.test.model.Account;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 王帅
|
* @author 王帅
|
||||||
@ -25,4 +28,7 @@ import com.mybatisflex.test.model.Account;
|
|||||||
*/
|
*/
|
||||||
public interface AccountMapper extends BaseMapper<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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -77,7 +77,7 @@
|
|||||||
<path>
|
<path>
|
||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${project.version}</version>
|
||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
3
pom.xml
3
pom.xml
@ -62,6 +62,9 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<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.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user