diff --git a/src/main/java/com/cm/news/pojo/util/TemplateUtil.java b/src/main/java/com/cm/news/pojo/util/TemplateUtil.java index 3c1b333..046e665 100644 --- a/src/main/java/com/cm/news/pojo/util/TemplateUtil.java +++ b/src/main/java/com/cm/news/pojo/util/TemplateUtil.java @@ -9,6 +9,7 @@ import com.cm.news.pojo.dtos.newscontent.NewsContentDTO; import com.cm.news.pojo.dtos.newstemplate.NewsTemplateDTO; import com.cm.news.pojo.vos.newstemplaterecord.NewsTemplateRecordVO; import com.cm.news.service.newscontent.INewsContentService; +import com.cm.news.service.newstemplate.INewsTemplateService; import com.cm.news.service.newstemplaterecord.INewsTemplateRecordService; import freemarker.cache.StringTemplateLoader; import org.apache.commons.lang3.StringUtils; @@ -50,11 +51,19 @@ public class TemplateUtil { private static INewsContentService iNewsContentStaticService; + + @Autowired + private INewsTemplateService iNewsTemplateService; + + private static INewsTemplateService iNewsTemplateStaticService; + @PostConstruct public void init() { iNewsTemplateRecordStaticService = this.iNewsTemplateRecordService; iNewsContentStaticService = this.iNewsContentService; templateStaticProperties = this.templateProperties; + iNewsTemplateStaticService = this.iNewsTemplateService; + } /** @@ -156,9 +165,9 @@ public class TemplateUtil { if(saveFile.exists()) { saveFile.delete(); } - Writer out = new FileWriter(saveFile); - temp.process(params, out); - out.flush(); + BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (saveFile,true),"UTF-8")); + temp.process(params, writer); + writer.flush(); /** * 做生成模板记录 */ @@ -167,7 +176,7 @@ public class TemplateUtil { recordVo.setNewsTemplateId(newsTemplate.getNewsTemplateDTO().getNewsTemplateId()); recordVo.setTemplateRecordBuilderTime(DateUtil.getTime()); recordVo.setTemplateRecordPath(fileName); - recordVo.setTemplateRecordUrl("news/" + templateUrl + "/" + dateTime.getYear()+ "/" + dateTime.getMonthOfYear() + "/" + newsContentId + ".html"); + recordVo.setTemplateRecordUrl(newsTemplate.getNewsTemplateDTO().getTemplateUrl() + dateTime.getYear()+ "/" + dateTime.getMonthOfYear() + "/" + newsContentId + ".html"); iNewsTemplateRecordStaticService.saveNewsTemplateRecord(recordVo); } diff --git a/src/main/java/com/cm/news/pojo/vos/newstemplate/NewsTemplateVO.java b/src/main/java/com/cm/news/pojo/vos/newstemplate/NewsTemplateVO.java index 17f3450..9479d0f 100644 --- a/src/main/java/com/cm/news/pojo/vos/newstemplate/NewsTemplateVO.java +++ b/src/main/java/com/cm/news/pojo/vos/newstemplate/NewsTemplateVO.java @@ -19,7 +19,8 @@ public class NewsTemplateVO { @ApiModelProperty(name = "templateCode", value = "模板编码") @CheckEmptyAnnotation(name = "模板编码") private String templateCode; - @ApiModelProperty(name = "templateUrl", value = "模板路径") + @ApiModelProperty(name = "templateUrl", value = "访问路径") + @CheckEmptyAnnotation(name = "访问路径") private String templateUrl; @ApiModelProperty(name = "templateName", value = "模板名称") @CheckEmptyAnnotation(name = "模板名称") diff --git a/src/main/resources/static/route/newstemplate/save-newstemplate.html b/src/main/resources/static/route/newstemplate/save-newstemplate.html index 49b9bee..66056d4 100644 --- a/src/main/resources/static/route/newstemplate/save-newstemplate.html +++ b/src/main/resources/static/route/newstemplate/save-newstemplate.html @@ -44,18 +44,18 @@ -
+
+ +
+ +
+
diff --git a/src/main/resources/static/route/newstemplate/update-newstemplate.html b/src/main/resources/static/route/newstemplate/update-newstemplate.html index 3be0192..e822c16 100644 --- a/src/main/resources/static/route/newstemplate/update-newstemplate.html +++ b/src/main/resources/static/route/newstemplate/update-newstemplate.html @@ -44,18 +44,18 @@
-
+
+ +
+ +
+