| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.io.file.FileWriter; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | private CmsTemplateMapper cmsTemplateMapper; |
| | | |
| | | @Test |
| | | public void testFileWrite(){ |
| | | Long companyId = 24L; |
| | | Long id = 38L; |
| | | CmsTemplateEntity cmsTemplateEntity = cmsTemplateMapper.selectByIdAndCompanyId(id,companyId); |
| | | String name = cmsTemplateEntity.getName(); |
| | | Integer type = cmsTemplateEntity.getType(); |
| | | String templatePath = "D:\\cmshtml"; |
| | | String path = cmsTemplateEntity.getPath(); |
| | | |
| | | cmsTemplateMapper.delete(id,companyId); |
| | | String pathNew = FileUtils.path(templatePath, path); |
| | | File file = new File(pathNew); |
| | | FileUtil.touch(file); |
| | | |
| | | //文件写入,直接覆盖 |
| | | FileWriter writer = new FileWriter(file); |
| | | writer.write("测试121634964949", false); |
| | | |
| | | CmsTemplateEntity cmsTemplate = new CmsTemplateEntity(); |
| | | cmsTemplate.setCompanyId(companyId); |
| | | cmsTemplate.setType(type); |
| | | cmsTemplate.setName(name); |
| | | cmsTemplate.setPath(path); |
| | | cmsTemplateMapper.insert(cmsTemplate); |
| | | } |
| | | @Test |
| | | public void testUserInsert() { |
| | | for(int i = 0; i < 20; i++) { |
| | | TestUserEntity testUser = new TestUserEntity(); |
| | |
| | | public void viewTemplateInfo() { |
| | | Long id = 4L; |
| | | CmsTemplateEntity cmsTemplateEntity = cmsTemplateMapper.selectById(id); |
| | | String htmlUrl = cmsProperties.getBaseUrl() + cmsProperties.getTemplatePath(); |
| | | String htmlUrl = "" + cmsProperties.getTemplatePath(); |
| | | File uploadDir = new File(htmlUrl); |
| | | if (!uploadDir.isDirectory()) { |
| | | uploadDir.mkdir(); |