|  |  |  | 
|---|
|  |  |  | import com.xcong.farmer.cms.modules.system.mapper.CompanyMapper; | 
|---|
|  |  |  | import com.xcong.farmer.cms.modules.system.service.ICmsTemplateService; | 
|---|
|  |  |  | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.jsoup.Jsoup; | 
|---|
|  |  |  | import org.jsoup.nodes.Document; | 
|---|
|  |  |  | import org.jsoup.nodes.Element; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | * @date 2022-07-04 | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class CmsTemplateServiceImpl extends ServiceImpl<CmsTemplateMapper, CmsTemplateEntity> implements ICmsTemplateService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Result viewTemplateInfo(Long id) { | 
|---|
|  |  |  | Result result = new Result(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CompanyEntity companyEntity = companyMapper.selectById(LoginUserUtil.getCompanyId()); | 
|---|
|  |  |  | CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectById(id); | 
|---|
|  |  |  | String templatePath = cmsProperties.getTemplatePath(); | 
|---|
|  |  |  | String templatePath = FileUtils.path(cmsProperties.getTemplatePath(), companyEntity.getCode()); | 
|---|
|  |  |  | String pathName = FileUtils.path(templatePath, cmsTemplateEntity.getPath()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | byte[] bytes = new byte[0]; | 
|---|
|  |  |  | 
|---|
|  |  |  | public Result saveTemplateInfo(AdminSaveTemplateInfoDto adminSaveTemplateInfoDto) { | 
|---|
|  |  |  | Long companyId = LoginUserUtil.getCompanyId(); | 
|---|
|  |  |  | Long id = adminSaveTemplateInfoDto.getId(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | CompanyEntity company = this.companyMapper.selectById(companyId); | 
|---|
|  |  |  | CmsTemplateEntity cmsTemplateEntity = this.baseMapper.selectByIdAndCompanyId(id,companyId); | 
|---|
|  |  |  | String name = cmsTemplateEntity.getName(); | 
|---|
|  |  |  | Integer type = cmsTemplateEntity.getType(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|