From 27b9206900a70aa195a99624f07d3178dd4d1779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=88=B5=20nice?= Date: Fri, 12 Oct 2018 17:10:12 +0800 Subject: [PATCH] :bug: fixed #464 --- .../controller/admin/AdminApiController.java | 7 ++++--- .../java/com/tale/model/params/PageParam.java | 2 ++ .../com/tale/model/params/TemplateParam.java | 17 +++++++++++++++++ .../resources/templates/admin/tpl_list.html | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/tale/model/params/TemplateParam.java 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()