| | |
| | | package com.xcong.farmer.cms.modules.system.service.Impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.xcong.farmer.cms.modules.system.mapper.CmsTemplateMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.ICmsTemplateService; |
| | | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | } |
| | | |
| | | try { |
| | | if (".zip".equals(suffix)) { |
| | | String path = FileUtils.path(templatePath, filename); |
| | | System.out.println(path); |
| | | File file = new File(path); |
| | | upload.transferTo(file); |
| | | FileUtils.zipUpload(file, templatePath, staticPath); |
| | | |
| | | if (".zip".equals(suffix)) { |
| | | ZipUtil.unzip(file, new File(templatePath)); |
| | | FileUtil.del(file); |
| | | |
| | | File template = new File(templatePath); |
| | | File[] files = template.listFiles(); |
| | | if (files == null) { |
| | | return; |
| | | } |
| | | |
| | | for (File templateFile : files) { |
| | | if (!templateFile.isFile()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!"html".equals(FileUtil.extName(templateFile))) { |
| | | continue; |
| | | } |
| | | |
| | | String name = templateFile.getName(); |
| | | 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"); |
| | | System.out.println(attr); |
| | | CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); |
| | | cmsTemplate.setCompanyId(10L); |
| | | if (name.endsWith(".list.html")) { |
| | | cmsTemplate.setType(2); |
| | | } else if (name.endsWith(".article.html")) { |
| | | cmsTemplate.setType(3); |
| | | } else { |
| | | cmsTemplate.setType(1); |
| | | } |
| | | cmsTemplate.setName(templateFile.getName()); |
| | | cmsTemplate.setPath(templateFile.getName()); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (".html".equals(suffix)) { |
| | | FileUtil.touch(file); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println(suffix); |
| | | } |
| | | |
| | | @Override |