mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 16:26:41 +08:00
JeecgBoot 3.6.0大版本发布
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
package org.jeecg.smallTools;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 测试sql分割、替换等操作
|
||||
*
|
||||
* @author: scott
|
||||
* @date: 2023年09月05日 16:13
|
||||
*/
|
||||
public class TestSqlHandle {
|
||||
|
||||
/**
|
||||
* Where 分割测试
|
||||
*/
|
||||
@Test
|
||||
public void testSqlSplitWhere() {
|
||||
String tableFilterSql = " select * from data.sys_user Where name='12312' and age>100";
|
||||
String[] arr = tableFilterSql.split(" (?i)where ");
|
||||
for (String sql : arr) {
|
||||
System.out.println("sql片段:" + sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Where 替换
|
||||
*/
|
||||
@Test
|
||||
public void testSqlWhereReplace() {
|
||||
String input = " Where name='12312' and age>100";
|
||||
String pattern = "(?i)where "; // (?i) 表示不区分大小写
|
||||
|
||||
String replacedString = input.replaceAll(pattern, "");
|
||||
|
||||
System.out.println("替换前的字符串:" + input);
|
||||
System.out.println("替换后的字符串:" + replacedString);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.jeecg.smallTools;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 字符串处理测试
|
||||
*
|
||||
* @author: scott
|
||||
* @date: 2023年03月30日 15:27
|
||||
*/
|
||||
public class TestStr {
|
||||
|
||||
/**
|
||||
* 测试参数格式化的问题,数字值有问题
|
||||
*/
|
||||
@Test
|
||||
public void testParameterFormat() {
|
||||
String url = "/pages/lowApp/process/taskDetail?tenantId={0}&procInsId={1}&taskId={2}&taskDefKey={3}";
|
||||
String cc = MessageFormat.format(url, "6364", "111", "22", "333");
|
||||
System.out.println("参数是字符串:" + cc);
|
||||
|
||||
String cc2 = MessageFormat.format(url, 6364, 111, 22, 333);
|
||||
System.out.println("参数是数字(出问题):" + cc2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStringSplitError() {
|
||||
String conditionValue = "qweqwe";
|
||||
String[] conditionValueArray = conditionValue.split(",");
|
||||
System.out.println("length = "+ conditionValueArray.length);
|
||||
Arrays.stream(conditionValueArray).forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJSONArrayJoin() {
|
||||
JSONArray valArray = new JSONArray();
|
||||
valArray.add("123");
|
||||
valArray.add("qwe");
|
||||
System.out.println("值: " + StringUtils.join(valArray, ","));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user