Skip to content

Commit

Permalink
feat: 5.0.8 预发发布
Browse files Browse the repository at this point in the history
fix: 修复字符串替换特殊字符异常问题
  • Loading branch information
[email protected] committed Aug 20, 2023
1 parent ec7b38a commit 24028df
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.plugins.mybaitslog.monitor;

import com.linkkou.mybatis.log.LogInterceptor;
import com.linkkou.mybatis.log.SubInterceptorChain;
import com.plugins.mybaitslog.IClassFileTransformer;
import javassist.*;

import java.util.Arrays;
import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;

/**
* A <code>DynamicSqlSourceMonitor</code> Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.util.*;
import java.util.regex.Matcher;


/**
Expand Down Expand Up @@ -149,7 +150,7 @@ private Pair<MappedStatement, Object> getArgs(Invocation invocation) {
*/
private String replaceFirst(String originalSql, String propertyName, String parameterValue) {
//(\$|#)\{\s*epNo2((?!\{).)*}
return originalSql.replaceFirst("(\\$|#)\\{\\s*" + propertyName + "((?!\\{).)*}", parameterValue);
return originalSql.replaceFirst("(\\$|#)\\{\\s*" + Matcher.quoteReplacement(propertyName) + "((?!\\{).)*}", Matcher.quoteReplacement(parameterValue));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDate;
import java.util.List;
import java.util.concurrent.CountDownLatch;

Expand Down Expand Up @@ -64,6 +65,20 @@ public void queryByInjectD() {
System.out.println(employees);
}

@Test
public void queryByInjectE() {
final Employees employees = employeesDao.queryByInjectD("[httpServerRequest[ org.springframework.security.web.header.HeaderWriterFilter$HeaderWriterRequest@67b80766]]");
System.out.println(employees);
}


@Test
public void queryByInjectLocalDate() {
final LocalDate now = LocalDate.now();
final Employees employees = employeesDao.queryByInjectLocalDate(now);
System.out.println(employees);
}

@Test
public void queryByInjectThread() throws InterruptedException {
CountDownLatch countDownLatch = new CountDownLatch(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

/**
Expand Down Expand Up @@ -89,6 +90,8 @@ public interface EmployeesDao {
Employees queryByInject(@Param("inject") String inject);
Employees queryByInjectD(@Param("inject") String inject);

Employees queryByInjectLocalDate(@Param("inject") LocalDate inject);

/**
* JSON
* @param inject
Expand Down
12 changes: 12 additions & 0 deletions mybatis-test/src/test/resources/mapper/EmployeesMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@
where emp_no = '#{inject}'
</select>

<!--查询单个-->
<select id="queryByInjectLocalDate" resultMap="EmployeesMap">
select emp_no,
birth_date,
first_name,
last_name,
gender,
hire_date
from employees
where emp_no = #{inject}
</select>

<select id="queryByInjectJson" resultMap="EmployeesMap">
select
COALESCE( sum(substring('trade_way'::jsonb -> 0 ->> 1,'(-?([0-9]*)(.[0-9]+)?)')::NUMERIC ),0) as amount,
Expand Down

0 comments on commit 24028df

Please sign in to comment.