Skip to content

Commit

Permalink
feat: 5.0.7 预发发布
Browse files Browse the repository at this point in the history
bug: 修复已经输出格式不正确的问题
  • Loading branch information
[email protected] committed Apr 12, 2023
1 parent 9f1cf0c commit 961a6d3
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mybatis-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {


group 'com.plugins.mybatislog.agent'
version '1.0.22'
version '1.0.23'

java {
sourceCompatibility = "1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class preAgent {

//JVM 首先尝试在代理类上调用以下方法
public static void premain(String agentArgs, Instrumentation inst) {
final Pair<String, String> with = Pair.with("Mybatis", "Plugins");
final Pair<String, String> with = Pair.with("Start: ", "MyBatis Log EasyPlus");
System.out.println(with.getValue0() + with.getValue1());
final transformer transformer = new transformer(inst);
transformer.transform();
Expand Down
2 changes: 1 addition & 1 deletion mybatis-idea-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
}

group 'com.plugins.mybaitslog.idea.plugin'
version '5.0.7'
version '5.0.7.1'

dependencies {
compileOnly 'org.jetbrains:annotations:24.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static String getJarPathByStartWith() {
if ("lib".equals(listFile.getName())) {
final File[] fileslib = listFile.listFiles();
for (File file : fileslib) {
if ("mybatis-agent-1.0.22-all.jar".equals(file.getName())) {
if ("mybatis-agent-1.0.23-all.jar".equals(file.getName())) {
return file.toPath().toString();
}
}
Expand Down
2 changes: 1 addition & 1 deletion mybatis-idea-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<vendor email="[email protected]" url="https://github.com/Link-Kou/intellij-mybaitslog">linkkou</vendor>

<!-- 插件版本 -->
<version>5.0.7</version>
<version>5.0.7.1</version>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="201"/>
<!-- 插件的描述 -->
Expand Down
2 changes: 1 addition & 1 deletion mybatis-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ allprojects {
}

group 'com.plugins.mybatislog.plugin'
version '1.0.2'
version '1.0.3'

java {
sourceCompatibility = "1.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;
import org.javatuples.Pair;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -103,25 +104,30 @@ private Pair<MappedStatement, Object> getArgs(Invocation invocation) {
MetaObject metaObject = configuration.newMetaObject(parameterObject);
for (ParameterMapping parameterMapping : parameterMappings) {
String propertyName = parameterMapping.getProperty();
final JdbcType jdbcType = parameterMapping.getJdbcType();
String jdbcTypename = "";
if (null != jdbcType) {
jdbcTypename = String.format("\\s*,\\s*jdbcType\\s*=\\s*%s", jdbcType.name());
}
final HashMap<String, Object> stringObjectHashMap = new HashMap<>();
if (metaObject.hasGetter(propertyName)) {
Object obj = metaObject.getValue(propertyName);
final String parameterValue = getParameterValue(obj);
stringObjectHashMap.put(propertyName, parameterValue);
keyvalue.add(stringObjectHashMap);
originalSql = originalSql.replaceFirst("#\\{" + propertyName + "}", parameterValue);
originalSql = originalSql.replaceFirst("#\\{\\s*" + propertyName + jdbcTypename + "\\s*}", parameterValue);
} else if (boundSql.hasAdditionalParameter(propertyName)) {
Object obj = boundSql.getAdditionalParameter(propertyName);
final String parameterValue = getParameterValue(obj);
stringObjectHashMap.put(propertyName, parameterValue);
keyvalue.add(stringObjectHashMap);
originalSql = originalSql.replaceFirst("#\\{" + propertyName + "}", parameterValue);
} else if (size == 1 && !(parameterObject instanceof Map)) {
originalSql = originalSql.replaceFirst("#\\{\\s*" + propertyName + jdbcTypename + "\\s*}", parameterValue);
} else if (!(parameterObject instanceof Map)) {
//单个参数默认组合
final String parameterValue = getParameterValue(metaObject.getOriginalObject());
stringObjectHashMap.put(propertyName, parameterValue);
keyvalue.add(stringObjectHashMap);
originalSql = originalSql.replaceFirst("#\\{" + propertyName + "}", parameterValue);
originalSql = originalSql.replaceFirst("#\\{\\s*" + propertyName + jdbcTypename + "\\s*}", parameterValue);
}
}
}
Expand Down Expand Up @@ -192,6 +198,7 @@ private SqlNode getSqlNode(SqlSource sqlSource) {

/**
* 如果是字符串对象则加上单引号返回,如果是日期则也需要转换成字符串形式,如果是其他则直接转换成字符串返回。
* todo 需要改进为MyBatis内置的数据解析能力
*
* @param obj 对象
* @return String
Expand Down

0 comments on commit 961a6d3

Please sign in to comment.