| | |
| | | public class CmsTemplateServiceImpl extends ServiceImpl<CmsTemplateMapper, CmsTemplateEntity> implements ICmsTemplateService { |
| | | |
| | | @Autowired |
| | | private TemplateConfiguration cfg; |
| | | private CmsProperties properties; |
| | | |
| | | private List<String> fileSuffix = Arrays.asList(".zip", ".html"); |
| | | |
| | | @Override |
| | | public void updateTemplate(MultipartFile upload) { |
| | | String templatePath = cfg.templatePath; |
| | | String staticPath = cfg.staticPath; |
| | | String templatePath = properties.getTemplatePath(); |
| | | String staticPath = properties.getStaticPath(); |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | |
| | | String filename = upload.getOriginalFilename(); |
| | | String suffix = filename.substring(filename.lastIndexOf(".")); |
| | |
| | | |
| | | for (File templateFile : files) { |
| | | if (!templateFile.isFile()) { |
| | | FileUtil.move(templateFile, new File(FileUtils.path(staticPath, templateFile.getName())), true); |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | String name = templateFile.getName(); |
| | | if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith(".index.html")) { |
| | | if (!name.endsWith(".list.html") && !name.endsWith(".article.html") && !name.endsWith("index.html")) { |
| | | continue; |
| | | } |
| | | |
| | | Document parse = Jsoup.parse(templateFile, null); |
| | | String attr = parse.head().attr("name"); |
| | | CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); |
| | | cmsTemplate.setCompanyId(10L); |
| | | cmsTemplate.setCompanyId(companyId); |
| | | if (name.endsWith(".list.html")) { |
| | | cmsTemplate.setType(2); |
| | | } else if (name.endsWith(".article.html")) { |
| | |
| | | Document parse = Jsoup.parse(file, null); |
| | | String attr = parse.head().attr("name"); |
| | | CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); |
| | | cmsTemplate.setCompanyId(LoginUserUtil.getCompanyId()); |
| | | cmsTemplate.setCompanyId(companyId); |
| | | if (file.getName().endsWith(".list.html")) { |
| | | cmsTemplate.setType(2); |
| | | } else if (file.getName().endsWith(".article.html")) { |
| | |
| | | |
| | | @Override |
| | | public Result viewTemplateInfo(Long id) { |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectById(id); |
| | | String baseUrl = cmsProperties.getBaseUrl(); |
| | | String templatePath = cmsProperties.getTemplatePath(); |
| | | String htmlUrl = baseUrl + templatePath; |
| | | String pathName = htmlUrl + "\\" + cmsTemplateEntity.getPath(); |
| | | String pathName = FileUtils.path(templatePath, cmsTemplateEntity.getPath()); |
| | | |
| | | byte[] bytes = new byte[0]; |
| | | try { |