From 08e5cfa5651c15a79bcbcff2b04a1dda6c5c961b Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Thu, 07 Jul 2022 16:19:28 +0800 Subject: [PATCH] fix --- src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java | 5 +++-- src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java | 6 +++--- src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java | 18 +++++++++++------- src/main/resources/application.yml | 4 ++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java index 38c8fcc..27d74e6 100644 --- a/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java +++ b/src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java @@ -71,6 +71,16 @@ return false; } + public void staticPath() { + // 设置img的链接访问 + if ("img".equals(this.element.tagName())) { + String src = this.element.attr("src"); + if (StrUtil.isNotBlank(STATIC_URL)) { + this.element.attr("src", STATIC_URL + src); + } + } + } + public void parser() { // 判断是否为最小节点,如果是且没有特殊标签,则跳过清空 if (!isNeedEmpty()) { @@ -79,13 +89,7 @@ this.element.empty(); - // 设置img的链接访问 - if ("img".equals(this.element.tagName())) { - String src = this.element.attr("src"); - if (StrUtil.isNotBlank(STATIC_URL)) { - this.element.attr("src", STATIC_URL + src); - } - } + staticPath(); Attributes attributes = this.element.attributes(); if (attributes.isEmpty()) { return; diff --git a/src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java b/src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java index dba37a4..7dbc81c 100644 --- a/src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java +++ b/src/main/java/com/xcong/farmer/cms/core/template/TemplateConfiguration.java @@ -33,7 +33,7 @@ this.templateLoader.data(map); Template template = template(templateName); - template.output(this.outputPath); + template.output(outputPath); // 判断是否有分页,有则执行。从第二页开始 int i = 2; @@ -41,13 +41,13 @@ map.put("page", i); this.templateLoader.data(map); Template pageTemplate = template(templateName); - pageTemplate.output(this.outputPath); + pageTemplate.output(outputPath); i++; } } public Template template(String templateName) { - return template(new File(path(this.templatePath) + templateName)); + return template(new File(path(templatePath) + templateName)); } public Template template(File file) { diff --git a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java index dc2c206..c22967f 100644 --- a/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java +++ b/src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/CmsTemplateServiceImpl.java @@ -53,6 +53,7 @@ public void updateTemplate(MultipartFile upload) { String templatePath = properties.getTemplatePath(); String staticPath = properties.getStaticPath(); + Long companyId = LoginUserUtil.getCompanyId(); String filename = upload.getOriginalFilename(); String suffix = filename.substring(filename.lastIndexOf(".")); @@ -94,7 +95,7 @@ Document parse = Jsoup.parse(templateFile, null); String attr = parse.head().attr("name"); CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); - cmsTemplate.setCompanyId(10L); + cmsTemplate.setCompanyId(companyId); if (name.endsWith(".list.html")) { cmsTemplate.setType(2); } else if (name.endsWith(".article.html")) { @@ -116,7 +117,7 @@ Document parse = Jsoup.parse(file, null); String attr = parse.head().attr("name"); CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); - cmsTemplate.setCompanyId(LoginUserUtil.getCompanyId()); + cmsTemplate.setCompanyId(companyId); if (file.getName().endsWith(".list.html")) { cmsTemplate.setType(2); } else if (file.getName().endsWith(".article.html")) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e2ebc6d..fb5980a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -98,8 +98,8 @@ cms: base-url: http://localhost - static-url: http://localhost - template-path: /Users/helius/Desktop/template/upload + static-url: http://localhost/ + template-path: /Users/helius/Desktop/template static-path: /Users/helius/Desktop/static output-path: /Users/helius/Desktop/web/output -- Gitblit v1.9.1