diff --git a/src/main/java/com/tale/controller/admin/AdminApiController.java b/src/main/java/com/tale/controller/admin/AdminApiController.java index f3a45473..ce6c5929 100644 --- a/src/main/java/com/tale/controller/admin/AdminApiController.java +++ b/src/main/java/com/tale/controller/admin/AdminApiController.java @@ -418,12 +418,13 @@ public RestResponse activeTheme(@BodyParam ThemeParam themeParam) { @SysLog("保存模板") @PostRoute("template/save") - public RestResponse saveTpl(@Param String fileName, @Param String content) throws IOException { - if (StringKit.isBlank(fileName)) { + public RestResponse saveTpl(@BodyParam TemplateParam templateParam) throws IOException { + if (StringKit.isBlank(templateParam.getFileName())) { return RestResponse.fail("缺少参数,请重试"); } + String content = templateParam.getContent(); String themePath = Const.CLASSPATH + File.separatorChar + "templates" + File.separatorChar + "themes" + File.separatorChar + Commons.site_theme(); - String filePath = themePath + File.separatorChar + fileName; + String filePath = themePath + File.separatorChar + templateParam.getFileName(); if (Files.exists(Paths.get(filePath))) { byte[] rf_wiki_byte = content.getBytes("UTF-8"); Files.write(Paths.get(filePath), rf_wiki_byte); diff --git a/src/main/java/com/tale/model/params/PageParam.java b/src/main/java/com/tale/model/params/PageParam.java index 50eed9c8..885e0a73 100644 --- a/src/main/java/com/tale/model/params/PageParam.java +++ b/src/main/java/com/tale/model/params/PageParam.java @@ -3,6 +3,8 @@ import lombok.Data; /** + * 分页基础参数 + * * @author biezhi * @date 2018/6/5 */ diff --git a/src/main/java/com/tale/model/params/TemplateParam.java b/src/main/java/com/tale/model/params/TemplateParam.java new file mode 100644 index 00000000..f1b9c448 --- /dev/null +++ b/src/main/java/com/tale/model/params/TemplateParam.java @@ -0,0 +1,17 @@ +package com.tale.model.params; + +import lombok.Data; + +/** + * 保存模板参数 + * + * @author biezhi + * @date 2018/10/12 + */ +@Data +public class TemplateParam { + + private String fileName; + private String content; + +} diff --git a/src/main/resources/templates/admin/tpl_list.html b/src/main/resources/templates/admin/tpl_list.html index 00ee2027..95d65167 100644 --- a/src/main/resources/templates/admin/tpl_list.html +++ b/src/main/resources/templates/admin/tpl_list.html @@ -80,7 +80,7 @@

编辑模板

var fileName = $('#tplSelect').val(); if (fileName && fileName != '') { tale.post({ - url: '/admin/template/save', + url: '/admin/api/template/save', data: { fileName: fileName, content: $('#tpl-preview').val()