| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | public Result dropdownList() { |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | QueryWrapper<CmsTemplateEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("company_id",companyId); |
| | | objectQueryWrapper.eq("company_id", companyId); |
| | | List<CmsTemplateEntity> cmsTemplateEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | return Result.ok(cmsTemplateEntities); |
| | | } |
| | |
| | | Long id = adminSaveTemplateInfoDto.getId(); |
| | | |
| | | CompanyEntity company = this.companyMapper.selectById(companyId); |
| | | CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectByIdAndCompanyId(id,companyId); |
| | | CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectByIdAndCompanyId(id, companyId); |
| | | String name = cmsTemplateEntity.getName(); |
| | | Integer type = cmsTemplateEntity.getType(); |
| | | String templatePath = cmsProperties.getTemplatePath(); |
| | | String templatePath = FileUtils.path(cmsProperties.getTemplatePath(), company.getCode()); |
| | | String path = cmsTemplateEntity.getPath(); |
| | | |
| | | this.baseMapper.delete(id,companyId); |
| | | this.baseMapper.delete(id, companyId); |
| | | String pathNew = FileUtils.path(templatePath, path); |
| | | pathNew = FileUtils.path(pathNew, company.getCode()); |
| | | log.info("模板写入地址:{}", pathNew); |
| | | File file = new File(pathNew); |
| | | FileUtil.touch(file); |
| | |
| | | return Result.ok("保存成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result downloadTemplate() { |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | CompanyEntity company = this.companyMapper.selectById(companyId); |
| | | |
| | | String templatePath = FileUtils.path(cmsProperties.getTemplatePath(), company.getCode()); |
| | | String staticPath = FileUtils.path(cmsProperties.getStaticPath(), company.getCode()); |
| | | |
| | | String fileName = "template.zip"; |
| | | ZipUtil.zip(templatePath, staticPath + "/template.zip", true); |
| | | |
| | | return Result.ok("success", cmsProperties.getStaticUrl() + fileName); |
| | | } |
| | | } |