From a9f423e014169be5686edf84c4b912cdbccbe551 Mon Sep 17 00:00:00 2001 From: zayac Date: Sat, 30 Sep 2023 02:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=E6=98=AF=E4=BB=8E=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=AF=BB=E5=8F=96=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ChangeUrlServiceImpl.java | 22 +++++++++---- src/main/resources/application-dev.yml | 32 +++---------------- src/main/resources/application-ky.yml | 9 ------ src/main/resources/application-prod.yml | 17 ++++++++++ src/main/resources/application.yml | 2 +- 5 files changed, 38 insertions(+), 44 deletions(-) delete mode 100644 src/main/resources/application-ky.yml create mode 100644 src/main/resources/application-prod.yml diff --git a/src/main/java/com/zayac/changeurl/service/ChangeUrlServiceImpl.java b/src/main/java/com/zayac/changeurl/service/ChangeUrlServiceImpl.java index 06db832..2e082ab 100644 --- a/src/main/java/com/zayac/changeurl/service/ChangeUrlServiceImpl.java +++ b/src/main/java/com/zayac/changeurl/service/ChangeUrlServiceImpl.java @@ -9,6 +9,7 @@ import com.zayac.changeurl.entity.KyMsgEntity; import com.zayac.changeurl.entity.KyTemplateEntity; import com.zayac.changeurl.exception.BizException; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -24,8 +25,15 @@ import java.util.List; @Slf4j @Service public class ChangeUrlServiceImpl implements ChangeUrlService { - private static final String KYJS = "/www/wwwroot/cdn.static.cdcseo.com/js/ky.js"; - private static final String HTHJS = "/www/wwwroot/cdn.static.cdcseo.com/js/hth.js"; + @Value("${path.ky.target}") + private String kyjs; + @Value("${path.hth.target}") + private String hthjs; + + @Value("${path.ky.template}") + private String kyjsTemplate; + @Value("${path.hth.template}") + private String hthjsTemplate; @Override public Boolean change(String text) { @@ -36,7 +44,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService { if (text.contains("SEO 专用域名")) { KyMsgEntity kyMsg = new KyMsgEntity(arr); List kyTargets = new ArrayList<>(); - kyTargets.add(KYJS); + kyTargets.add(kyjs); KyTemplateEntity kyTemplate = new KyTemplateEntity( @@ -46,7 +54,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService { "kyPc2", "kyH51", "kyH52", - "/www/wwwroot/cdn.static.cdcseo.com/js/ky.js.template", + kyjsTemplate, kyTargets); //读取模板文件 String template = loadTemplate(kyTemplate.getTemplatePath()); @@ -60,7 +68,7 @@ public class ChangeUrlServiceImpl implements ChangeUrlService { modifyFile(template, kyTemplate.getTargets()); //读取修改过的文件 校验修改成功失败 - String result = FileUtil.readUtf8String(KYJS); + String result = FileUtil.readUtf8String(kyjs); if (ReUtil.count(Constant.URL_PATTERN, result) < 6) { throw new BizException(500, "开云链接更新失败,请手动检查文件"); } @@ -68,8 +76,8 @@ public class ChangeUrlServiceImpl implements ChangeUrlService { } else { HthMsgEntity hthMsg = new HthMsgEntity(arr); List hthTargets = new ArrayList<>(); - hthTargets.add(HTHJS); - HthTemplateEntity hthTemplate = new HthTemplateEntity("hthApp", "hthtyApp", "hthPc", "hthH5", "/www/wwwroot/cdn.static.cdcseo.com/js/hth.js.template", hthTargets); + hthTargets.add(hthjs); + HthTemplateEntity hthTemplate = new HthTemplateEntity("hthApp", "hthtyApp", "hthPc", "hthH5", hthjsTemplate, hthTargets); //读取模板文件 String template = loadTemplate(hthTemplate.getTemplatePath()); template = template diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 16c0ce7..ec16e32 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,32 +1,10 @@ -msg: +path: ky: - startWith: - web: "WEB" - h5: "H5" - app: "全站" + template: "ky.js.template" + target: "C:\\Users\\Administrator\\Desktop\\js\\ky.js" hth: - startWith: - web: "" - h5: "" - app1: "" - app2: "" -js: - ky: - kyweb1: "kyPc1" - kyweb2: "kyPc2" - kyh51: "kyH5" - kyh52: "" - kyApp1: "kyApp" - kyApp2: "" - hth: - hthweb: "" - hthh5: "" - hthApp1: "" - hthApp2: "" - path: - template: "link.js.template" - targets: "link.js" - + template: "hth.js.template" + target: "C:\\Users\\Administrator\\Desktop\\js\\hth.js" server: port: 8888 spring: diff --git a/src/main/resources/application-ky.yml b/src/main/resources/application-ky.yml deleted file mode 100644 index 5336d45..0000000 --- a/src/main/resources/application-ky.yml +++ /dev/null @@ -1,9 +0,0 @@ -server: - port: 8888 -spring: - cache: - type: CAFFEINE - caffeine: - spec: maximumSize=100,expireAfterWrite=10m -ip: - white: "127.0.0.1" \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..e3dfbd3 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,17 @@ +server: + port: 8359 +spring: + cache: + type: CAFFEINE + caffeine: + spec: maximumSize=100,expireAfterWrite=10m +ip: + white: "127.0.0.1" + +path: + ky: + template: "/www/wwwroot/cdn.static.cdcseo.com/template/ky.js.template" + target: "/www/wwwroot/cdn.static.cdcseo.com/js/ky.js" + hth: + template: "/www/wwwroot/cdn.static.cdcseo.com/template/hth.js.template" + target: "/www/wwwroot/cdn.static.cdcseo.com/js/hth.js" \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 171640a..a906822 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,7 @@ spring: caffeine: spec: maximumSize=100,expireAfterWrite=10m profiles: - active: "ky" + active: "prod" logging: logback: