修复端口号不能正常替换的bug
This commit is contained in:
parent
5846f5f22f
commit
e0a720714a
@ -33,8 +33,8 @@ public class HthMsgEntity {
|
|||||||
String startWith = msgAnnotation.startWith();
|
String startWith = msgAnnotation.startWith();
|
||||||
String val = "";
|
String val = "";
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
//如果以开头字符开头并且字符长度大于startWith,认为在一行
|
//如果以开头字符开头并且字符长度大于startWith,认为在一行 并且不包含新字
|
||||||
if (array[i].startsWith(startWith) && StrUtil.cleanBlank(array[i]).length() > startWith.length()) {
|
if (array[i].startsWith(startWith) && !array[i].contains(Constant.PREFER) && StrUtil.cleanBlank(array[i]).length() > startWith.length()) {
|
||||||
val = ReUtil.getGroup1(Constant.URL_PATTERN, array[i]);
|
val = ReUtil.getGroup1(Constant.URL_PATTERN, array[i]);
|
||||||
} else if (array[i].startsWith(startWith)) {
|
} else if (array[i].startsWith(startWith)) {
|
||||||
val = ReUtil.getGroup1(Constant.URL_PATTERN, array[i + 1]);
|
val = ReUtil.getGroup1(Constant.URL_PATTERN, array[i + 1]);
|
||||||
|
@ -58,7 +58,7 @@ public class KyMsgEntity {
|
|||||||
//优先将包含新字的放到List第一位置
|
//优先将包含新字的放到List第一位置
|
||||||
matched = matched.stream()
|
matched = matched.stream()
|
||||||
.sorted(Comparator.comparing(str -> !str.contains(Constant.PREFER)))
|
.sorted(Comparator.comparing(str -> !str.contains(Constant.PREFER)))
|
||||||
.map(x -> ReUtil.getGroup1(Constant.URL_PATTERN, x))
|
.map(x -> ReUtil.get(Constant.URL_PATTERN, x, 0))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
//断言 list中不含有null值,防止修改数据为空
|
//断言 list中不含有null值,防止修改数据为空
|
||||||
Assert.noNullElements(ArrayUtil.toArray(matched, String.class));
|
Assert.noNullElements(ArrayUtil.toArray(matched, String.class));
|
||||||
@ -67,7 +67,7 @@ public class KyMsgEntity {
|
|||||||
// 如果不是List类型,判断匹配的列表是否为空
|
// 如果不是List类型,判断匹配的列表是否为空
|
||||||
if (!matched.isEmpty()) {
|
if (!matched.isEmpty()) {
|
||||||
// 如果不为空,取第一个元素赋值给该字段
|
// 如果不为空,取第一个元素赋值给该字段
|
||||||
field.set(this, ReUtil.getGroup1(Constant.URL_PATTERN, matched.get(0)));
|
field.set(this, ReUtil.get(Constant.URL_PATTERN, matched.get(0), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
@ -24,8 +24,8 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ChangeUrlServiceImpl implements ChangeUrlService {
|
public class ChangeUrlServiceImpl implements ChangeUrlService {
|
||||||
private static final String KYJS = "/www/wwwroot/cdn.static.cdcseo.com/js/ky.js";
|
private static final String KYJS = "ky.js";
|
||||||
private static final String HTHJS = "/www/wwwroot/cdn.static.cdcseo.com/js/hth.js";
|
private static final String HTHJS = "template";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean change(String text) {
|
public Boolean change(String text) {
|
||||||
@ -46,7 +46,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService {
|
|||||||
"kyPc2",
|
"kyPc2",
|
||||||
"kyH51",
|
"kyH51",
|
||||||
"kyH52",
|
"kyH52",
|
||||||
"/www/wwwroot/cdn.static.cdcseo.com/template/ky.js.template",
|
"ky.js.template",
|
||||||
kyTargets);
|
kyTargets);
|
||||||
//读取模板文件
|
//读取模板文件
|
||||||
String template = loadTemplate(kyTemplate.getTemplatePath());
|
String template = loadTemplate(kyTemplate.getTemplatePath());
|
||||||
@ -69,7 +69,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService {
|
|||||||
HthMsgEntity hthMsg = new HthMsgEntity(arr);
|
HthMsgEntity hthMsg = new HthMsgEntity(arr);
|
||||||
List<String> hthTargets = new ArrayList<>();
|
List<String> hthTargets = new ArrayList<>();
|
||||||
hthTargets.add(HTHJS);
|
hthTargets.add(HTHJS);
|
||||||
HthTemplateEntity hthTemplate = new HthTemplateEntity("hthApp", "hthtyApp", "hthPc", "hthH5", "/www/wwwroot/cdn.static.cdcseo.com/template/ky.js.template/hth.js.template", hthTargets);
|
HthTemplateEntity hthTemplate = new HthTemplateEntity("hthApp", "hthtyApp", "hthPc", "hthH5", "hth.js.template", hthTargets);
|
||||||
//读取模板文件
|
//读取模板文件
|
||||||
String template = loadTemplate(hthTemplate.getTemplatePath());
|
String template = loadTemplate(hthTemplate.getTemplatePath());
|
||||||
template = template
|
template = template
|
||||||
@ -107,12 +107,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService {
|
|||||||
public List<File> modifyFile(String text, List<String> paths) {
|
public List<File> modifyFile(String text, List<String> paths) {
|
||||||
List<File> files = new ArrayList<>();
|
List<File> files = new ArrayList<>();
|
||||||
for (String target : paths) {
|
for (String target : paths) {
|
||||||
if (FileUtil.exist(target)) {
|
files.add(FileUtil.writeString(text, target, "UTF-8"));
|
||||||
FileUtil.del(target);
|
|
||||||
} else {
|
|
||||||
File file = FileUtil.newFile(target);
|
|
||||||
files.add(FileUtil.writeString(text, file, "UTF-8"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user