拼写更正 Templete to Template
This commit is contained in:
@@ -7,6 +7,7 @@ package com.jeesite.modules.cms.entity;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -21,16 +22,16 @@ import com.jeesite.common.lang.ExceptionUtils;
|
|||||||
* @author 长春叭哥、ThinkGem
|
* @author 长春叭哥、ThinkGem
|
||||||
* @version 2020-7-7
|
* @version 2020-7-7
|
||||||
*/
|
*/
|
||||||
public class FileTemplete implements Comparable<FileTemplete>, Serializable {
|
public class FileTemplate implements Comparable<FileTemplate>, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Resource resource;
|
private final Resource resource;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private String fileExtension;
|
private String fileExtension;
|
||||||
private String filePath;
|
private String filePath;
|
||||||
private boolean isDirectory;
|
private boolean isDirectory;
|
||||||
|
|
||||||
public FileTemplete(Resource resource, String path) {
|
public FileTemplate(Resource resource, String path) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.fileName = resource.getFilename();
|
this.fileName = resource.getFilename();
|
||||||
this.fileExtension = FileUtils.getFileExtension(this.fileName);
|
this.fileExtension = FileUtils.getFileExtension(this.fileName);
|
||||||
@@ -41,22 +42,22 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
|
|||||||
beginIndex = filePath.indexOf(path);
|
beginIndex = filePath.indexOf(path);
|
||||||
}
|
}
|
||||||
int endIndex = filePath.length();
|
int endIndex = filePath.length();
|
||||||
if (this.fileName.contains(".")){
|
if (this.fileName != null && this.fileName.contains(".")) {
|
||||||
endIndex = filePath.lastIndexOf('/');
|
endIndex = filePath.lastIndexOf('/');
|
||||||
}else if (filePath.endsWith("/")) {
|
|
||||||
endIndex -= 1;
|
|
||||||
}
|
}
|
||||||
this.filePath = filePath.substring(beginIndex, endIndex);
|
this.filePath = filePath.substring(beginIndex, endIndex);
|
||||||
// System.out.println(this.filePath);
|
// System.out.println(this.filePath);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw ExceptionUtils.unchecked(e);
|
throw ExceptionUtils.unchecked(e);
|
||||||
}
|
}
|
||||||
this.isDirectory = !this.fileName.contains(".");
|
if (this.fileName != null) {
|
||||||
|
this.isDirectory = !this.fileName.contains(".");
|
||||||
|
}
|
||||||
// System.out.println(filePath);
|
// System.out.println(filePath);
|
||||||
// System.out.println(fileName);
|
// System.out.println(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileTemplete(FileTemplete source) {
|
public FileTemplate(FileTemplate source) {
|
||||||
int index = source.filePath.lastIndexOf('/');
|
int index = source.filePath.lastIndexOf('/');
|
||||||
this.fileName = source.filePath.substring(index+1);
|
this.fileName = source.filePath.substring(index+1);
|
||||||
this.filePath = source.filePath.substring(0, index);
|
this.filePath = source.filePath.substring(0, index);
|
||||||
@@ -109,14 +110,14 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try(InputStream is = resource.getInputStream()){
|
try(InputStream is = resource.getInputStream()){
|
||||||
return IOUtils.toString(is, EncodeUtils.UTF_8);
|
return IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||||
}catch (IOException e) {
|
}catch (IOException e) {
|
||||||
throw ExceptionUtils.unchecked(e);
|
throw ExceptionUtils.unchecked(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(FileTemplete o) {
|
public int compareTo(FileTemplate o) {
|
||||||
return this.getFileName().compareTo(o.getFileName());
|
return this.getFileName().compareTo(o.getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
|
|||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FileTemplete e = (FileTemplete) o;
|
FileTemplate e = (FileTemplate) o;
|
||||||
return Objects.equals(this.fileName, e.fileName)
|
return Objects.equals(this.fileName, e.fileName)
|
||||||
&& Objects.equals(this.fileExtension, e.fileExtension)
|
&& Objects.equals(this.fileExtension, e.fileExtension)
|
||||||
&& Objects.equals(this.filePath, e.filePath)
|
&& Objects.equals(this.filePath, e.filePath)
|
||||||
@@ -16,6 +16,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +48,7 @@ public class Site extends DataEntity<Site> {
|
|||||||
/**
|
/**
|
||||||
* 模板路径
|
* 模板路径
|
||||||
*/
|
*/
|
||||||
public static final String TEMPLETE_BASE_DIRECTION = "views/modules/cmsfront/themes";
|
public static final String TEMPLATE_BASE_DIRECTION = "views/modules/cmsfront/themes";
|
||||||
/**
|
/**
|
||||||
* 默认模版
|
* 默认模版
|
||||||
*/
|
*/
|
||||||
@@ -189,7 +190,7 @@ public class Site extends DataEntity<Site> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getSolutionPath() {
|
public String getSolutionPath() {
|
||||||
return TEMPLETE_BASE_DIRECTION + "/" + getTheme();
|
return TEMPLATE_BASE_DIRECTION + "/" + getTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCategoryCodes() {
|
public List<String> getCategoryCodes() {
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
* No deletion without permission, or be held responsible to law.
|
||||||
|
*/
|
||||||
|
package com.jeesite.modules.cms.service;
|
||||||
|
|
||||||
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
import com.jeesite.modules.cms.entity.FileTemplate;
|
||||||
|
import com.jeesite.modules.cms.entity.Site;
|
||||||
|
import com.jeesite.modules.cms.utils.CmsUtils;
|
||||||
|
import com.jeesite.modules.cms.utils.FileTemplateUtils;
|
||||||
|
import com.jeesite.modules.sys.entity.DictData;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模版文件Service
|
||||||
|
* @author 长春叭哥、ThinkGem
|
||||||
|
* @version 2020-7-7
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FileTemplateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对应视图模板列表,兼容 Select 字典
|
||||||
|
* @param prefix
|
||||||
|
*/
|
||||||
|
public List<DictData> getTemplateContentDict(String prefix) throws IOException {
|
||||||
|
List<DictData> listSite = ListUtils.newArrayList();
|
||||||
|
String solutionPath = CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath();
|
||||||
|
List<FileTemplate> tplList = FileTemplateUtils.getFileTemplateListByPath(solutionPath);
|
||||||
|
for (FileTemplate tpl : tplList) {
|
||||||
|
if (tpl.getFileName().startsWith(prefix)) {
|
||||||
|
listSite.add(new DictData(tpl.getFileName()
|
||||||
|
.substring(0, tpl.getFileName().indexOf("."))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listSite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取编辑文件列表
|
||||||
|
* @param path 模板路径
|
||||||
|
*/
|
||||||
|
public List<FileTemplate> getFileTemplateListForEdit(String path) throws IOException {
|
||||||
|
return FileTemplateUtils.getFileTemplateListForEdit(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模版文件内容
|
||||||
|
* @param fileName 模板文件
|
||||||
|
*/
|
||||||
|
public FileTemplate getFileTemplate(String fileName) throws IOException {
|
||||||
|
return FileTemplateUtils.getFileTemplateByResource(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
|
||||||
* No deletion without permission, or be held responsible to law.
|
|
||||||
*/
|
|
||||||
package com.jeesite.modules.cms.service;
|
|
||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
|
||||||
import com.jeesite.modules.cms.entity.FileTemplete;
|
|
||||||
import com.jeesite.modules.cms.entity.Site;
|
|
||||||
import com.jeesite.modules.cms.utils.CmsUtils;
|
|
||||||
import com.jeesite.modules.cms.utils.FileTempleteUtils;
|
|
||||||
import com.jeesite.modules.sys.entity.DictData;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模版文件Service
|
|
||||||
* @author 长春叭哥、ThinkGem
|
|
||||||
* @version 2020-7-7
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FileTempleteService {
|
|
||||||
|
|
||||||
// public List<String> getTempleteContent(String prefix) throws IOException {
|
|
||||||
// List<String> tplList = getFileTempleteNameListByPrefix(CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath());
|
|
||||||
// tplList = FilesTempleteUtils.templeteTrim(tplList, prefix, "");
|
|
||||||
// return tplList;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对应视图模板列表,兼容 Select 字典
|
|
||||||
* @param prefix
|
|
||||||
*/
|
|
||||||
public List<DictData> getTempleteContentDict(String prefix) throws IOException {
|
|
||||||
List<DictData> listSite = ListUtils.newArrayList();
|
|
||||||
String solutionPath = CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath();
|
|
||||||
List<FileTemplete> tplList = FileTempleteUtils.getFileTempleteListByPath(solutionPath);
|
|
||||||
for (FileTemplete tpl : tplList) {
|
|
||||||
if (tpl.getFileName().startsWith(prefix)) {
|
|
||||||
listSite.add(new DictData(tpl.getFileName()
|
|
||||||
.substring(0, tpl.getFileName().indexOf("."))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return listSite;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 通过前缀获取文件名集合
|
|
||||||
// * @param filePath
|
|
||||||
// * @return List<String> 文件名集合
|
|
||||||
// * @author 长春叭哥
|
|
||||||
// * @throws IOException
|
|
||||||
// */
|
|
||||||
// public List<String> getFileTempleteNameListByPrefix(String filePath) throws IOException {
|
|
||||||
// return FilesTempleteUtils.getFileTempleteNameListByPrefix(filePath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 获取模版文件列表
|
|
||||||
// * @param path 路径
|
|
||||||
// * @param directory
|
|
||||||
// * @return List<FileTemplete> 模版文件集合
|
|
||||||
// * @author 长春叭哥
|
|
||||||
// * @throws IOException
|
|
||||||
// */
|
|
||||||
// public List<FileTemplete> getFileTempleteListByPath(String path, boolean directory) throws IOException {
|
|
||||||
// return FilesTempleteUtils.getFileTempleteListByPath(path, directory);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取编辑文件列表
|
|
||||||
* @param path 模板路径
|
|
||||||
*/
|
|
||||||
public List<FileTemplete> getFileTempleteListForEdit(String path) throws IOException {
|
|
||||||
return FileTempleteUtils.getFileTempleteListForEdit(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取模版文件内容
|
|
||||||
* @param fileName 模板文件
|
|
||||||
*/
|
|
||||||
public FileTemplete getFileTemplete(String fileName) throws IOException {
|
|
||||||
return FileTempleteUtils.getFileTempleteByResource(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ import com.jeesite.common.collect.ListUtils;
|
|||||||
import com.jeesite.common.collect.SetUtils;
|
import com.jeesite.common.collect.SetUtils;
|
||||||
import com.jeesite.common.io.ResourceUtils;
|
import com.jeesite.common.io.ResourceUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.modules.cms.entity.FileTemplete;
|
import com.jeesite.modules.cms.entity.FileTemplate;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -20,30 +20,30 @@ import java.util.Set;
|
|||||||
* @author 长春叭哥、ThinkGem
|
* @author 长春叭哥、ThinkGem
|
||||||
* @version 2020-7-7
|
* @version 2020-7-7
|
||||||
*/
|
*/
|
||||||
public class FileTempleteUtils {
|
public class FileTemplateUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模版文件
|
* 获取模版文件
|
||||||
* @param fileName
|
* @param fileName
|
||||||
*/
|
*/
|
||||||
public static FileTemplete getFileTempleteByResource(String fileName) {
|
public static FileTemplate getFileTemplateByResource(String fileName) {
|
||||||
if (!StringUtils.startsWith(fileName, "views/modules/cmsfront")) {
|
if (!StringUtils.startsWith(fileName, "views/modules/cmsfront")) {
|
||||||
fileName = "views/modules/cmsfront/themes/default/index.html";
|
fileName = "views/modules/cmsfront/themes/default/index.html";
|
||||||
}
|
}
|
||||||
Resource resource = ResourceUtils.getResource(fileName);
|
Resource resource = ResourceUtils.getResource(fileName);
|
||||||
return new FileTemplete(resource, fileName);
|
return new FileTemplate(resource, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板文件集合
|
* 获取模板文件集合
|
||||||
* @param path 前缀路径
|
* @param path 前缀路径
|
||||||
*/
|
*/
|
||||||
public static List<FileTemplete> getFileTempleteListByPath(String path) throws IOException {
|
public static List<FileTemplate> getFileTemplateListByPath(String path) throws IOException {
|
||||||
List<FileTemplete> list = ListUtils.newArrayList();
|
List<FileTemplate> list = ListUtils.newArrayList();
|
||||||
Resource[] resources = ResourceUtils.getResources("classpath*:" + path + "/**/*.html");
|
Resource[] resources = ResourceUtils.getResources("classpath*:" + path + "/**/*.html");
|
||||||
for (Resource resource : resources) {
|
for (Resource resource : resources) {
|
||||||
if (resource.exists()) {
|
if (resource.exists()) {
|
||||||
list.add(new FileTemplete(resource, path));
|
list.add(new FileTemplate(resource, path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@@ -53,14 +53,14 @@ public class FileTempleteUtils {
|
|||||||
* 获取模板文件相关属性(含目录)
|
* 获取模板文件相关属性(含目录)
|
||||||
* @param path 前缀路径
|
* @param path 前缀路径
|
||||||
*/
|
*/
|
||||||
public static List<FileTemplete> getFileTempleteListForEdit(String path) throws IOException {
|
public static List<FileTemplate> getFileTemplateListForEdit(String path) throws IOException {
|
||||||
|
|
||||||
List<FileTemplete> list = getFileTempleteListByPath(path);
|
List<FileTemplate> list = getFileTemplateListByPath(path);
|
||||||
Set<FileTemplete> set = SetUtils.newLinkedHashSet();
|
Set<FileTemplate> set = SetUtils.newLinkedHashSet();
|
||||||
|
|
||||||
// 获取目录
|
// 获取目录
|
||||||
list.forEach(e -> {
|
list.forEach(e -> {
|
||||||
set.add(new FileTemplete(e));
|
set.add(new FileTemplate(e));
|
||||||
});
|
});
|
||||||
set.addAll(list);
|
set.addAll(list);
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import com.jeesite.modules.cms.entity.Category;
|
|||||||
import com.jeesite.modules.cms.entity.Site;
|
import com.jeesite.modules.cms.entity.Site;
|
||||||
import com.jeesite.modules.cms.service.ArticleService;
|
import com.jeesite.modules.cms.service.ArticleService;
|
||||||
import com.jeesite.modules.cms.service.CategoryService;
|
import com.jeesite.modules.cms.service.CategoryService;
|
||||||
import com.jeesite.modules.cms.service.FileTempleteService;
|
import com.jeesite.modules.cms.service.FileTemplateService;
|
||||||
import com.jeesite.modules.cms.utils.CmsUtils;
|
import com.jeesite.modules.cms.utils.CmsUtils;
|
||||||
import com.jeesite.modules.sys.utils.UserUtils;
|
import com.jeesite.modules.sys.utils.UserUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
@@ -46,7 +46,7 @@ public class ArticleController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileTempleteService fileTempleteService;
|
private FileTemplateService fileTemplateService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据
|
* 获取数据
|
||||||
@@ -135,7 +135,7 @@ public class ArticleController extends BaseController {
|
|||||||
if (StringUtils.isBlank(article.getId())) {
|
if (StringUtils.isBlank(article.getId())) {
|
||||||
article.setStatus(Article.STATUS_DRAFT);
|
article.setStatus(Article.STATUS_DRAFT);
|
||||||
}
|
}
|
||||||
model.addAttribute("contentViewList", fileTempleteService.getTempleteContentDict(Article.DEFAULT_TEMPLATE));
|
model.addAttribute("contentViewList", fileTemplateService.getTemplateContentDict(Article.DEFAULT_TEMPLATE));
|
||||||
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
|
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
|
||||||
model.addAttribute("article", article);
|
model.addAttribute("article", article);
|
||||||
CmsUtils.addViewConfigAttribute(model, article.getCategory());
|
CmsUtils.addViewConfigAttribute(model, article.getCategory());
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ import com.jeesite.modules.cms.entity.Article;
|
|||||||
import com.jeesite.modules.cms.entity.Category;
|
import com.jeesite.modules.cms.entity.Category;
|
||||||
import com.jeesite.modules.cms.entity.Site;
|
import com.jeesite.modules.cms.entity.Site;
|
||||||
import com.jeesite.modules.cms.service.CategoryService;
|
import com.jeesite.modules.cms.service.CategoryService;
|
||||||
import com.jeesite.modules.cms.service.FileTempleteService;
|
import com.jeesite.modules.cms.service.FileTemplateService;
|
||||||
import com.jeesite.modules.cms.utils.CmsUtils;
|
import com.jeesite.modules.cms.utils.CmsUtils;
|
||||||
import com.jeesite.modules.sys.utils.DictUtils;
|
import com.jeesite.modules.sys.utils.DictUtils;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
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;
|
||||||
@@ -28,7 +29,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -46,7 +46,7 @@ public class CategoryController extends BaseController {
|
|||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileTempleteService fileTempleteService;
|
private FileTemplateService fileTemplateService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据
|
* 获取数据
|
||||||
@@ -157,9 +157,9 @@ public class CategoryController extends BaseController {
|
|||||||
if (category.getIsNeedAudit() == null) {
|
if (category.getIsNeedAudit() == null) {
|
||||||
category.setIsNeedAudit(Global.NO);
|
category.setIsNeedAudit(Global.NO);
|
||||||
}
|
}
|
||||||
model.addAttribute("listViewList", fileTempleteService.getTempleteContentDict(Category.DEFAULT_TEMPLATE));
|
model.addAttribute("listViewList", fileTemplateService.getTemplateContentDict(Category.DEFAULT_TEMPLATE));
|
||||||
model.addAttribute("category_DEFAULT_TEMPLATE", Category.DEFAULT_TEMPLATE);
|
model.addAttribute("category_DEFAULT_TEMPLATE", Category.DEFAULT_TEMPLATE);
|
||||||
model.addAttribute("contentViewList", fileTempleteService.getTempleteContentDict(Article.DEFAULT_TEMPLATE));
|
model.addAttribute("contentViewList", fileTemplateService.getTemplateContentDict(Article.DEFAULT_TEMPLATE));
|
||||||
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
|
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
|
||||||
model.addAttribute("category", category);
|
model.addAttribute("category", category);
|
||||||
return "modules/cms/categoryForm";
|
return "modules/cms/categoryForm";
|
||||||
|
|||||||
@@ -4,20 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.jeesite.modules.cms.web;
|
package com.jeesite.modules.cms.web;
|
||||||
|
|
||||||
import java.io.File;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
import java.io.IOException;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import java.util.List;
|
import com.jeesite.common.web.BaseController;
|
||||||
import java.util.Map;
|
import com.jeesite.modules.cms.entity.FileTemplate;
|
||||||
|
import com.jeesite.modules.cms.entity.Site;
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
import com.jeesite.modules.cms.service.FileTemplateService;
|
||||||
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;
|
||||||
@@ -25,12 +17,9 @@ import org.springframework.ui.Model;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import java.io.IOException;
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import java.util.List;
|
||||||
import com.jeesite.common.web.BaseController;
|
import java.util.Map;
|
||||||
import com.jeesite.modules.cms.entity.FileTemplete;
|
|
||||||
import com.jeesite.modules.cms.entity.Site;
|
|
||||||
import com.jeesite.modules.cms.service.FileTempleteService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板管理
|
* 模板管理
|
||||||
@@ -42,7 +31,7 @@ import com.jeesite.modules.cms.service.FileTempleteService;
|
|||||||
public class FileTemplateController extends BaseController {
|
public class FileTemplateController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileTempleteService fileTempleteService;
|
private FileTemplateService fileTemplateService;
|
||||||
|
|
||||||
@RequiresPermissions("cms:template:edit")
|
@RequiresPermissions("cms:template:edit")
|
||||||
@RequestMapping(value = { "list", "" })
|
@RequestMapping(value = { "list", "" })
|
||||||
@@ -50,19 +39,10 @@ public class FileTemplateController extends BaseController {
|
|||||||
return "modules/cms/tplIndex";
|
return "modules/cms/tplIndex";
|
||||||
}
|
}
|
||||||
|
|
||||||
// @RequiresPermissions("cms:template:edit")
|
|
||||||
// @RequestMapping(value = "tree")
|
|
||||||
// public String tree(Model model) throws IOException {
|
|
||||||
// //根据系统默认的主题获取模板地址
|
|
||||||
// model.addAttribute("templateList", fileTempleteService
|
|
||||||
// .getFileTempleteListForEdit(Site.TEMPLETE_BASE_DIRECTION + "/" + "default"));
|
|
||||||
// return "modules/cms/tplTree";
|
|
||||||
// }
|
|
||||||
|
|
||||||
@RequiresPermissions("cms:template:edit")
|
@RequiresPermissions("cms:template:edit")
|
||||||
@RequestMapping(value = "form")
|
@RequestMapping(value = "form")
|
||||||
public String form(String name, Model model) throws IOException {
|
public String form(String name, Model model) throws IOException {
|
||||||
model.addAttribute("template", fileTempleteService.getFileTemplete(name));
|
model.addAttribute("template", fileTemplateService.getFileTemplate(name));
|
||||||
return "modules/cms/tplForm";
|
return "modules/cms/tplForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +50,7 @@ public class FileTemplateController extends BaseController {
|
|||||||
@RequestMapping(value = "saveFileTemplate")
|
@RequestMapping(value = "saveFileTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String saveFileTemplate(String fileName, String fileContent) throws IOException {
|
public String saveFileTemplate(String fileName, String fileContent) throws IOException {
|
||||||
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
|
FileTemplate template = fileTemplateService.getFileTemplate(fileName);
|
||||||
String newFileName = FileUtils.path(FileUtils.getWebappPath() + "/WEB-INF/classes/" + fileName);
|
String newFileName = FileUtils.path(FileUtils.getWebappPath() + "/WEB-INF/classes/" + fileName);
|
||||||
File templateFile = template.resource().getFile();
|
File templateFile = template.resource().getFile();
|
||||||
if (templateFile.getAbsoluteFile().exists()) {
|
if (templateFile.getAbsoluteFile().exists()) {
|
||||||
@@ -86,7 +66,7 @@ public class FileTemplateController extends BaseController {
|
|||||||
@RequestMapping(value = "deleteFileTemplate")
|
@RequestMapping(value = "deleteFileTemplate")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String deleteFileTemplate(String fileName) throws IOException {
|
public String deleteFileTemplate(String fileName) throws IOException {
|
||||||
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
|
FileTemplate template = fileTemplateService.getFileTemplate(fileName);
|
||||||
File templateFile = template.resource().getFile();
|
File templateFile = template.resource().getFile();
|
||||||
if (templateFile.getAbsoluteFile().exists()) {
|
if (templateFile.getAbsoluteFile().exists()) {
|
||||||
FileUtils.deleteFile(templateFile.getAbsolutePath());
|
FileUtils.deleteFile(templateFile.getAbsolutePath());
|
||||||
@@ -109,9 +89,9 @@ public class FileTemplateController extends BaseController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Map<String, Object>> treeData() throws IOException {
|
public List<Map<String, Object>> treeData() 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<FileTemplate> listFileTemplate = fileTemplateService.getFileTemplateListForEdit(Site.TEMPLATE_BASE_DIRECTION);
|
||||||
for (int i = 0; i < listFileTemplete.size(); i++) {
|
for (int i = 0; i < listFileTemplate.size(); i++) {
|
||||||
FileTemplete e = listFileTemplete.get(i);
|
FileTemplate e = listFileTemplate.get(i);
|
||||||
Map<String, Object> map = MapUtils.newHashMap();
|
Map<String, Object> map = MapUtils.newHashMap();
|
||||||
map.put("id", e.getFilePath() + "/" + e.getFileName());
|
map.put("id", e.getFilePath() + "/" + e.getFileName());
|
||||||
map.put("isDirectory", e.isDirectory());
|
map.put("isDirectory", e.isDirectory());
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import com.jeesite.common.config.Global;
|
|||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.web.BaseController;
|
import com.jeesite.common.web.BaseController;
|
||||||
import com.jeesite.common.web.CookieUtils;
|
|
||||||
import com.jeesite.modules.cms.entity.Site;
|
import com.jeesite.modules.cms.entity.Site;
|
||||||
import com.jeesite.modules.cms.service.FileTempleteService;
|
import com.jeesite.modules.cms.service.FileTemplateService;
|
||||||
import com.jeesite.modules.cms.service.SiteService;
|
import com.jeesite.modules.cms.service.SiteService;
|
||||||
import com.jeesite.modules.sys.utils.CorpUtils;
|
|
||||||
import com.jeesite.modules.sys.utils.UserUtils;
|
import com.jeesite.modules.sys.utils.UserUtils;
|
||||||
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;
|
||||||
@@ -41,7 +39,7 @@ public class SiteController extends BaseController {
|
|||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileTempleteService fileTempleteService;
|
private FileTemplateService fileTemplateService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据
|
* 获取数据
|
||||||
@@ -81,7 +79,7 @@ public class SiteController extends BaseController {
|
|||||||
@RequiresPermissions("cms:site:view")
|
@RequiresPermissions("cms:site:view")
|
||||||
@RequestMapping(value = "form")
|
@RequestMapping(value = "form")
|
||||||
public String form(Site site, Model model) throws IOException {
|
public String form(Site site, Model model) throws IOException {
|
||||||
model.addAttribute("indexViewList", fileTempleteService.getTempleteContentDict(Site.DEFAULT_TEMPLATE));
|
model.addAttribute("indexViewList", fileTemplateService.getTemplateContentDict(Site.DEFAULT_TEMPLATE));
|
||||||
model.addAttribute("site_DEFAULT_TEMPLATE", Site.DEFAULT_TEMPLATE);
|
model.addAttribute("site_DEFAULT_TEMPLATE", Site.DEFAULT_TEMPLATE);
|
||||||
model.addAttribute("site", site);
|
model.addAttribute("site", site);
|
||||||
model.addAttribute("demos", site);
|
model.addAttribute("demos", site);
|
||||||
|
|||||||
Reference in New Issue
Block a user