From ea4120a80f7ef6188a745d9b27238cde1a3f7d74 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 07 Jul 2022 18:06:55 +0800
Subject: [PATCH] modify release

---
 src/test/java/com/xcong/farmer/cms/KssframeworkApplicationTests.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/src/test/java/com/xcong/farmer/cms/KssframeworkApplicationTests.java b/src/test/java/com/xcong/farmer/cms/KssframeworkApplicationTests.java
index f4bab75..542c24e 100644
--- a/src/test/java/com/xcong/farmer/cms/KssframeworkApplicationTests.java
+++ b/src/test/java/com/xcong/farmer/cms/KssframeworkApplicationTests.java
@@ -1,11 +1,27 @@
 package com.xcong.farmer.cms;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.xcong.farmer.cms.common.response.Result;
+import com.xcong.farmer.cms.common.utils.FileUtils;
+import com.xcong.farmer.cms.configurations.properties.CmsProperties;
+import com.xcong.farmer.cms.modules.system.entity.CmsTemplateEntity;
+import com.xcong.farmer.cms.modules.system.mapper.CmsTemplateMapper;
+import com.xcong.farmer.cms.modules.system.util.LoginUserUtil;
 import com.xcong.farmer.cms.modules.test.dao.TestUserDao;
 import com.xcong.farmer.cms.modules.test.entity.TestUserEntity;
+import org.jsoup.Jsoup;
 import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.Date;
 
 @SpringBootTest
@@ -13,6 +29,9 @@
 
     @Resource
     private TestUserDao testUserDao;
+
+    @Resource
+    private CmsTemplateMapper cmsTemplateMapper;
 
     @Test
     public void testUserInsert() {
@@ -35,4 +54,42 @@
         System.out.println(1);
     }
 
+
+    @Autowired
+    private CmsProperties cmsProperties;
+
+    @Test
+    public void viewTemplateInfo() {
+        Long id = 4L;
+        CmsTemplateEntity cmsTemplateEntity = cmsTemplateMapper.selectById(id);
+        String htmlUrl = cmsProperties.getBaseUrl() + cmsProperties.getTemplatePath();
+        File uploadDir = new File(htmlUrl);
+        if (!uploadDir.isDirectory()) {
+            uploadDir.mkdir();
+        }
+        htmlUrl = "D:\\cmshtml";
+        String pathName = htmlUrl+"\\"+cmsTemplateEntity.getPath();
+        System.out.println(pathName);
+        byte[] bytes = new byte[0];
+        try {
+            bytes = Files.readAllBytes(Paths.get(pathName));
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.out.println("未找到模板");
+        }
+
+        String content = new String(bytes, StandardCharsets.UTF_8);
+        System.out.println(content);
+    }
+
+    @Test
+    public void path(){
+        Long id = 6L;
+        CmsTemplateEntity cmsTemplateEntity = cmsTemplateMapper.selectById(id);
+        String templatePath = cmsProperties.getTemplatePath();
+        String pathName = FileUtils.path(templatePath, cmsTemplateEntity.getPath());
+        System.out.println(templatePath);
+        System.out.println(pathName);
+    }
+
 }

--
Gitblit v1.9.1