Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jdk17-update-jwj
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
姜武杰
jdk17-update-jwj
Commits
f691ab20
提交
f691ab20
authored
9月 19, 2024
作者:
王林巧
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加es和easyPoi的替换
上级
82b86147
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
148 行增加
和
6 行删除
+148
-6
FileUpdaterManager.java
src/main/java/com/msl/FileUpdaterManager.java
+7
-4
Main.java
src/main/java/com/msl/Main.java
+16
-1
EasyPoiUpdater.java
src/main/java/com/msl/java/EasyPoiUpdater.java
+60
-0
JavaEsUpdater.java
src/main/java/com/msl/java/JavaEsUpdater.java
+64
-0
JavaNormalUpdater.java
src/main/java/com/msl/java/JavaNormalUpdater.java
+1
-1
没有找到文件。
src/main/java/com/msl/FileUpdaterManager.java
浏览文件 @
f691ab20
package
com
.
msl
;
package
com
.
msl
;
import
com.msl.java.*
;
import
com.msl.xml.XmlNormalUpdater
;
import
com.msl.xml.XmlNormalUpdater
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -15,10 +16,12 @@ public class FileUpdaterManager {
...
@@ -15,10 +16,12 @@ public class FileUpdaterManager {
static
{
static
{
register
(
new
XmlNormalUpdater
());
register
(
new
XmlNormalUpdater
());
// register(new JavaNormalUpdater());
register
(
new
JavaNormalUpdater
());
// register(new FeignClassAnnotationUpdater());
register
(
new
JavaEsUpdater
());
// register(new FeignMethodAnnotationUpdater1());
register
(
new
EasyPoiUpdater
());
// register(new FeignMethodAnnotationUpdater2());
register
(
new
FeignClassAnnotationUpdater
());
register
(
new
FeignMethodAnnotationUpdater1
());
register
(
new
FeignMethodAnnotationUpdater2
());
}
}
public
static
void
register
(
FileUpdater
fileUpdater
)
{
public
static
void
register
(
FileUpdater
fileUpdater
)
{
...
...
src/main/java/com/msl/Main.java
浏览文件 @
f691ab20
...
@@ -2,6 +2,7 @@ package com.msl;
...
@@ -2,6 +2,7 @@ package com.msl;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -13,16 +14,26 @@ import java.util.Set;
...
@@ -13,16 +14,26 @@ import java.util.Set;
*/
*/
public
class
Main
{
public
class
Main
{
public
static
Set
<
String
>
ignorePath
=
Sets
.
newHashSet
();
public
static
Set
<
String
>
ignorePath
=
Sets
.
newHashSet
();
public
static
Set
<
String
>
suffix
=
Sets
.
newHashSet
();
static
{
static
{
ignorePath
.
add
(
".git"
);
ignorePath
.
add
(
".git"
);
ignorePath
.
add
(
".idea"
);
ignorePath
.
add
(
".idea"
);
suffix
.
add
(
"java"
);
suffix
.
add
(
"xml"
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// doReplace("D:\\develop\\clx_projects\\msl-supervise\\supervise-web");
// doReplace("D:\\develop\\clx_projects\\msl-supervise\\supervise-web");
// doReplace("D:\\develop\\clx_projects\\msl-common-starter\\log-spring-boot-starter");
// doReplace("D:\\develop\\clx_projects\\msl-common-starter\\log-spring-boot-starter");
doReplace
(
"D:\\develop\\clx_projects\\msl-quality"
);
// doReplace("D:\\develop\\clx_projects\\msl-quality");
// doReplace("D:\\develop\\clx_projects\\msl-message");
// doReplace("D:\\develop\\clx_projects\\esign-non-standard-sdk");
// doReplace("D:\\develop\\clx_projects\\msl-document\\document-api");
// doReplace("D:\\develop\\clx_projects\\trade\\trade-settlement");
doReplace
(
"D:\\develop\\clx_projects\\trade\\trade-fund"
);
// doReplace("D:\\develop\\clx_projects\\trade\\trade-performance\\trade-performance-api");
}
}
public
static
void
doReplace
(
String
path
)
throws
Exception
{
public
static
void
doReplace
(
String
path
)
throws
Exception
{
...
@@ -35,6 +46,10 @@ public class Main {
...
@@ -35,6 +46,10 @@ public class Main {
public
static
void
doReplace
(
File
file
)
throws
Exception
{
public
static
void
doReplace
(
File
file
)
throws
Exception
{
if
(
file
.
isFile
())
{
if
(
file
.
isFile
())
{
String
extension
=
FilenameUtils
.
getExtension
(
file
.
getName
());
if
(!
suffix
.
contains
(
extension
))
{
return
;
}
FileContext
context
=
new
FileContext
(
file
);
FileContext
context
=
new
FileContext
(
file
);
System
.
out
.
println
(
"处理文件:"
+
file
.
getName
());
System
.
out
.
println
(
"处理文件:"
+
file
.
getName
());
FileUpdaterManager
.
update
(
context
);
FileUpdaterManager
.
update
(
context
);
...
...
src/main/java/com/msl/java/EasyPoiUpdater.java
0 → 100644
浏览文件 @
f691ab20
package
com
.
msl
.
java
;
import
com.msl.FileContext
;
import
com.msl.FileUpdater
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* @author wanglq
* Date 2024/9/18
* Time 17:25
*/
public
class
EasyPoiUpdater
implements
FileUpdater
{
// 定义正则表达式
private
final
Pattern
pattern
=
Pattern
.
compile
(
"@Excel\\s*\\(\\s*name\\s*=\\s*\"([^\"]*)\",\\s*orderNum\\s*=\\s*\"(\\d+)\"\\s*\\)"
);
/**
* 能否更新文件
*
* @param context 文件上下文
* @return 能否更新
*/
@Override
public
boolean
canApply
(
FileContext
context
)
{
return
context
.
getFileName
().
endsWith
(
".java"
);
}
/**
* 更新文件上下文
*
* @param context 文件上下文
*/
@Override
public
void
update
(
FileContext
context
)
{
String
content
=
context
.
getContent
().
replace
(
"import cn.afterturn.easypoi.excel.annotation.Excel;"
,
"import com.alibaba.excel.annotation.ExcelProperty;"
);
context
.
setContent
(
replaceAnnotation
(
content
));
}
private
String
replaceAnnotation
(
String
content
)
{
Matcher
matcher
=
pattern
.
matcher
(
content
);
StringBuffer
sb
=
new
StringBuffer
();
while
(
matcher
.
find
())
{
// 获取第一个捕获组的值,即 字段名
String
nameValue
=
matcher
.
group
(
1
);
// 获取第二个捕获组的值,即 字段序号
String
indexValue
=
matcher
.
group
(
2
);
// 构造替换后的注解内容
String
replaced
=
String
.
format
(
"@ExcelProperty(value = \"%s\", index = %s)"
,
nameValue
,
indexValue
);
// 替换原始文本中匹配的部分
matcher
.
appendReplacement
(
sb
,
replaced
);
}
// 将剩余部分追加到结果中
matcher
.
appendTail
(
sb
);
return
sb
.
toString
();
}
}
src/main/java/com/msl/java/JavaEsUpdater.java
0 → 100644
浏览文件 @
f691ab20
package
com
.
msl
.
java
;
import
com.google.common.collect.Lists
;
import
com.msl.FileContext
;
import
com.msl.NormalUpdater
;
import
org.javatuples.Pair
;
import
java.util.List
;
/**
* @author wanglq
* Date 2024/9/9
* Time 17:08
*/
public
class
JavaEsUpdater
extends
NormalUpdater
{
static
List
<
Pair
<
String
,
String
>>
replaceList
=
Lists
.
newArrayList
();
static
List
<
Pair
<
String
,
String
>>
replaceAllList
=
Lists
.
newArrayList
();
static
{
replaceList
.
add
(
Pair
.
with
(
"import org.springframework.data.elasticsearch.annotations.*;"
,
"import org.dromara.easyes.annotation.*;\r\nimport org.dromara.easyes.annotation.rely.FieldType;"
));
replaceList
.
add
(
Pair
.
with
(
"@Document(indexName = \""
,
"@IndexName(value = \""
));
replaceList
.
add
(
Pair
.
with
(
"@Field(type = FieldType.Integer)"
,
"@IndexField(fieldType = FieldType.INTEGER)"
));
replaceList
.
add
(
Pair
.
with
(
"@Field(type = FieldType.Long)"
,
"@IndexField(fieldType = FieldType.LONG)"
));
replaceList
.
add
(
Pair
.
with
(
"@Field(type = FieldType.Double)"
,
"@IndexField(fieldType = FieldType.DOUBLE)"
));
replaceList
.
add
(
Pair
.
with
(
"@Field(type = FieldType.Text)"
,
"@IndexField(fieldType = FieldType.TEXT)"
));
replaceList
.
add
(
Pair
.
with
(
"@Field(type = FieldType.Date, format = {}, pattern = LocalDateTimeUtils.DATETIME_FORMATTER)"
,
"@IndexField(fieldType = FieldType.DATE, dateFormat = LocalDateTimeUtils.DATETIME_FORMATTER)"
));
replaceAllList
.
add
(
Pair
.
with
(
"@MultiField.+\\r\\n.+\\r\\n.+\\)"
,
"@IndexField(fieldType = FieldType.KEYWORD_TEXT)"
));
}
@Override
protected
List
<
Pair
<
String
,
String
>>
replaceList
()
{
return
replaceList
;
}
/**
* 更新文件上下文
*
* @param context 文件上下文
*/
@Override
public
void
update
(
FileContext
context
)
{
super
.
update
(
context
);
String
content
=
context
.
getContent
();
for
(
Pair
<
String
,
String
>
pair
:
replaceAllList
)
{
content
=
content
.
replaceAll
(
pair
.
getValue0
(),
pair
.
getValue1
());
}
context
.
setContent
(
content
);
}
/**
* 能否更新文件
*
* @param context 文件上下文
* @return 能否更新
*/
@Override
public
boolean
canApply
(
FileContext
context
)
{
return
context
.
getFileName
().
endsWith
(
".java"
);
}
}
src/main/java/com/msl/java/JavaNormalUpdater.java
浏览文件 @
f691ab20
...
@@ -19,6 +19,7 @@ public class JavaNormalUpdater extends NormalUpdater {
...
@@ -19,6 +19,7 @@ public class JavaNormalUpdater extends NormalUpdater {
// javax 相关
// javax 相关
LIST
.
add
(
Pair
.
with
(
"import javax.servlet"
,
"import jakarta.servlet"
));
LIST
.
add
(
Pair
.
with
(
"import javax.servlet"
,
"import jakarta.servlet"
));
LIST
.
add
(
Pair
.
with
(
"import javax.validation"
,
"import jakarta.validation"
));
LIST
.
add
(
Pair
.
with
(
"import javax.validation"
,
"import jakarta.validation"
));
LIST
.
add
(
Pair
.
with
(
"import javax.annotation"
,
"import jakarta.annotation"
));
LIST
.
add
(
Pair
.
with
(
"import org.apache.commons.lang.ObjectUtils;"
,
"import org.apache.commons.lang3.ObjectUtils;"
));
LIST
.
add
(
Pair
.
with
(
"import org.apache.commons.lang.ObjectUtils;"
,
"import org.apache.commons.lang3.ObjectUtils;"
));
LIST
.
add
(
Pair
.
with
(
"import org.apache.commons.lang.StringUtils;"
,
"import org.apache.commons.lang3.StringUtils;"
));
LIST
.
add
(
Pair
.
with
(
"import org.apache.commons.lang.StringUtils;"
,
"import org.apache.commons.lang3.StringUtils;"
));
...
@@ -56,7 +57,6 @@ public class JavaNormalUpdater extends NormalUpdater {
...
@@ -56,7 +57,6 @@ public class JavaNormalUpdater extends NormalUpdater {
LIST
.
add
(
Pair
.
with
(
"import org.springframework.test.context.junit4.SpringRunner;"
,
"import org.springframework.test.context.junit.jupiter.SpringExtension;"
));
LIST
.
add
(
Pair
.
with
(
"import org.springframework.test.context.junit4.SpringRunner;"
,
"import org.springframework.test.context.junit.jupiter.SpringExtension;"
));
LIST
.
add
(
Pair
.
with
(
"@org.junit.Test"
,
"@org.junit.jupiter.api.Test"
));
LIST
.
add
(
Pair
.
with
(
"@org.junit.Test"
,
"@org.junit.jupiter.api.Test"
));
LIST
.
add
(
Pair
.
with
(
"@RunWith(SpringRunner.class)"
,
"@ExtendWith(SpringExtension.class)"
));
LIST
.
add
(
Pair
.
with
(
"@RunWith(SpringRunner.class)"
,
"@ExtendWith(SpringExtension.class)"
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论