#I6XWLB
This commit is contained in:
@@ -65,14 +65,10 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
|
|||||||
this.resource = null;
|
this.resource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getResource() {
|
public Resource resource() {
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(Resource resource) {
|
|
||||||
this.resource = resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.jeesite.modules.cms.web;
|
package com.jeesite.modules.cms.web;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.io.FileUtils;
|
||||||
|
import com.jeesite.common.io.ResourceUtils;
|
||||||
|
import com.jeesite.common.lang.DateUtils;
|
||||||
|
import com.jeesite.common.lang.StringUtils;
|
||||||
|
import com.jeesite.modules.gen.entity.GenTable;
|
||||||
|
import com.jeesite.modules.gen.utils.GenTableUtils;
|
||||||
|
import com.jeesite.modules.gen.utils.GenUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
@@ -30,12 +40,6 @@ import com.jeesite.modules.cms.service.FileTempleteService;
|
|||||||
@Controller
|
@Controller
|
||||||
@RequestMapping(value = "${adminPath}/cms/template")
|
@RequestMapping(value = "${adminPath}/cms/template")
|
||||||
public class FileTemplateController extends BaseController {
|
public class FileTemplateController extends BaseController {
|
||||||
|
|
||||||
//构想,给一个模板列表,模板下存放一個screenshots1~10.png,做为模版快照。
|
|
||||||
//README.md模版使用与说明文件
|
|
||||||
//zip上传模版文件
|
|
||||||
//模版目录格式:{design:{index.png,list-x.png,detail-x.png},readme.md,shots}
|
|
||||||
//支持在线 安装与卸载 模板 if()是否存在这个主题文件夹, 存在则判断init内配置文件 开启|关闭的配置
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileTempleteService fileTempleteService;
|
private FileTempleteService fileTempleteService;
|
||||||
@@ -62,26 +66,34 @@ public class FileTemplateController extends BaseController {
|
|||||||
return "modules/cms/tplForm";
|
return "modules/cms/tplForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequiresPermissions("cms:template:edit")
|
/*@RequiresPermissions("cms:template:edit")
|
||||||
// @RequestMapping(value = "saveFileTemplate")
|
@RequestMapping(value = "saveFileTemplate")
|
||||||
// @ResponseBody
|
@ResponseBody
|
||||||
// public String saveFileTemplate(String filePath, String fileName, String fileSource, Model model) throws IOException {
|
public String saveFileTemplate(String fileName, String fileContent) throws IOException {
|
||||||
//
|
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
|
||||||
// FileTemplete currentFile = FilesTempleteUtils.getFileTempleteByResource(filePath);
|
String newFileName = FileUtils.path(FileUtils.getWebappPath() + "/WEB-INF/classes/" + fileName);
|
||||||
// //在修改文件之前,开启模版的备份模式
|
File templateFile = template.resource().getFile();
|
||||||
// FileUtils.copyDirectory(currentFile.getFile().getAbsolutePath(),
|
if (templateFile.getAbsoluteFile().exists()) {
|
||||||
// currentFile.getFile().getAbsolutePath().replaceAll(currentFile.getFile().getName(), "") + DateUtils.getDate()
|
String bakFileName = StringUtils.replace(templateFile.getAbsolutePath(), templateFile.getName(),
|
||||||
// + currentFile.getFile());
|
templateFile.getName() + "." + DateUtils.getDate("yyyyMMddHHmmssSSS"));
|
||||||
// FileUtils.writeToFile(currentFile.getFile().getAbsolutePath(), EncodeUtils.decodeHtml(fileSource), false);
|
FileUtils.copyFile(templateFile.getAbsolutePath(), bakFileName);
|
||||||
//
|
}
|
||||||
// if (!currentFile.getFile().getName().equals(fileName)) {
|
FileUtils.writeToFile(newFileName, EncodeUtils.decodeBase64String(fileContent), false);
|
||||||
// String path = currentFile.getFile().getAbsolutePath().replaceAll(currentFile.getFile().getName(), "") + fileName;
|
return renderResult(Global.TRUE, "模版保存成功!");
|
||||||
// currentFile.getFile().renameTo(new File(path));
|
}
|
||||||
// return renderResult(Global.SHOW, "模版保存成功,请左侧菜单刷新后再操作模版!");
|
|
||||||
// }
|
@RequiresPermissions("cms:template:edit")
|
||||||
//
|
@RequestMapping(value = "deleteFileTemplate")
|
||||||
// return renderResult(Global.TRUE, "模版保存成功!");
|
@ResponseBody
|
||||||
// }
|
public String deleteFileTemplate(String fileName) throws IOException {
|
||||||
|
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
|
||||||
|
File templateFile = template.resource().getFile();
|
||||||
|
if (templateFile.getAbsoluteFile().exists()) {
|
||||||
|
FileUtils.deleteFile(templateFile.getAbsolutePath());
|
||||||
|
return renderResult(Global.TRUE, "模版删除成功!");
|
||||||
|
}
|
||||||
|
return renderResult(Global.FALSE, "模版文件不存在!");
|
||||||
|
}*/
|
||||||
|
|
||||||
@RequiresPermissions("cms:template:edit")
|
@RequiresPermissions("cms:template:edit")
|
||||||
@RequestMapping(value = "help")
|
@RequestMapping(value = "help")
|
||||||
@@ -91,21 +103,13 @@ public class FileTemplateController extends BaseController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取树结构数据
|
* 获取树结构数据
|
||||||
* @param excludeCode 排除的Code
|
|
||||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
|
||||||
* @return
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("cms:template:edit")
|
@RequiresPermissions("cms:template:edit")
|
||||||
@RequestMapping(value = "treeData")
|
@RequestMapping(value = "treeData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Map<String, Object>> treeData(String siteCode, String module, String extCode, Boolean isAll, String isShowCode)
|
public List<Map<String, Object>> treeData() throws IOException {
|
||||||
throws IOException {
|
|
||||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||||
//根据系统默认的主题获取模板地址
|
List<FileTemplete> listFileTemplete = fileTempleteService.getFileTempleteListForEdit(Site.TEMPLETE_BASE_DIRECTION);
|
||||||
List<FileTemplete> listFileTemplete = fileTempleteService
|
|
||||||
.getFileTempleteListForEdit(Site.TEMPLETE_BASE_DIRECTION);
|
|
||||||
// 处理转换数据,并返回ztree支持的格式
|
|
||||||
for (int i = 0; i < listFileTemplete.size(); i++) {
|
for (int i = 0; i < listFileTemplete.size(); i++) {
|
||||||
FileTemplete e = listFileTemplete.get(i);
|
FileTemplete e = listFileTemplete.get(i);
|
||||||
Map<String, Object> map = MapUtils.newHashMap();
|
Map<String, Object> map = MapUtils.newHashMap();
|
||||||
|
|||||||
@@ -34,9 +34,10 @@
|
|||||||
<div class="box-footer">
|
<div class="box-footer">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<% if (hasPermi('cms:template:edit')){ %>
|
<% /*if (hasPermi('cms:template:edit')){ %>
|
||||||
<!-- <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit" onclick="saveFile()"><i class="fa fa-check"></i> ${text('保 存')}</button> -->
|
<button type="button" class="btn btn-sm btn-primary" id="btnSave"><i class="fa fa-check"></i> ${text('保 存')}</button>
|
||||||
<% } %>
|
<button type="button" class="btn btn-sm btn-danger" id="btnDelete"><i class="fa fa-trash-o"></i> ${text('删 除')}</button>
|
||||||
|
<% }*/ %>
|
||||||
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -45,13 +46,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% /*if (hasPermi('cms:template:edit')){ %>
|
||||||
<script>
|
<script>
|
||||||
function saveFile() {
|
$('#btnSave').click(function(){
|
||||||
js.ajaxSubmit("${ctx}/cms/template/saveFileTemplate", {filePath: "${template.fileName}",fileName:$("#file_name").val(),fileSource:$("#fileSource").val()}, function(data) {
|
js.confirm('${text("确认要保存当前模板吗?")}', function(){
|
||||||
if(data.result=='1'){
|
js.ajaxSubmit("${ctx}/cms/template/saveFileTemplate", {
|
||||||
window.self.parent.loadTree();
|
fileName: $("#fileName").val(),
|
||||||
}
|
fileContent: Base64.encode($("#fileContent").val())
|
||||||
js.showMessage(data.message);
|
}, function(data) {
|
||||||
|
js.showMessage(data.message);
|
||||||
|
if(data.result == Global.TRUE){
|
||||||
|
window.self.parent.loadTree();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
$('#btnDelete').click(function(){
|
||||||
|
js.confirm('${text("确认要删除当前模板吗?")}', function(){
|
||||||
|
js.ajaxSubmit("${ctx}/cms/template/deleteFileTemplate", {
|
||||||
|
fileName: $("#fileName").val()
|
||||||
|
}, function(data) {
|
||||||
|
js.showMessage(data.message);
|
||||||
|
if(data.result == Global.TRUE){
|
||||||
|
window.self.parent.loadTree();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<% }*/ %>
|
||||||
|
|||||||
Reference in New Issue
Block a user