瀏覽代碼

Merge remote-tracking branch 'origin/developer' into developerA

# Conflicts:
#	src/main/resources/config/dev/application-dev.yml
JiangChongBo 2 年之前
父節點
當前提交
f486e3704b
共有 28 個文件被更改,包括 1590 次插入89 次删除
  1. 12 0
      pom.xml
  2. 1 0
      src/main/java/com/caimei/AdminApplication.java
  3. 11 0
      src/main/java/com/caimei/config/FastDfsClient.java
  4. 33 0
      src/main/java/com/caimei/config/TaskPoolConfig.java
  5. 2 2
      src/main/java/com/caimei/controller/admin/auth/UploadApi.java
  6. 6 2
      src/main/java/com/caimei/controller/admin/data/ArticleApi.java
  7. 221 0
      src/main/java/com/caimei/controller/admin/data/DatabaseApi.java
  8. 47 0
      src/main/java/com/caimei/controller/noToken/WxDatabaseApi.java
  9. 31 5
      src/main/java/com/caimei/controller/wechat/WxDataApi.java
  10. 1 1
      src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java
  11. 28 0
      src/main/java/com/caimei/mapper/cmMapper/FileMapper.java
  12. 8 0
      src/main/java/com/caimei/model/po/ArticlePo.java
  13. 6 0
      src/main/java/com/caimei/model/vo/ArticleFormVo.java
  14. 79 0
      src/main/java/com/caimei/model/vo/FileTreeVo.java
  15. 167 0
      src/main/java/com/caimei/service/async/AsyncService.java
  16. 37 29
      src/main/java/com/caimei/service/auth/ArticleService.java
  17. 27 5
      src/main/java/com/caimei/service/auth/impl/ArticleServiceImpl.java
  18. 8 3
      src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java
  19. 2 2
      src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java
  20. 39 0
      src/main/java/com/caimei/service/data/DatabaseService.java
  21. 376 0
      src/main/java/com/caimei/service/data/impl/DatabaseServiceImpl.java
  22. 174 0
      src/main/java/com/caimei/utils/FileZipUtils.java
  23. 49 2
      src/main/java/com/caimei/utils/OSSUtils.java
  24. 39 13
      src/main/resources/mapper/ArticleMapper.xml
  25. 4 4
      src/main/resources/mapper/AuthProductMapper.xml
  26. 175 10
      src/main/resources/mapper/FileMapper.xml
  27. 4 5
      src/main/resources/mapper/ImageMapper.xml
  28. 3 6
      src/main/resources/mapper/VideoMapper.xml

+ 12 - 0
pom.xml

@@ -41,6 +41,18 @@
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
         </dependency>
+        <!--缩略图-->
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+        </dependency>
+        <!-- oss获取token -->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-sts</artifactId>
+            <version>3.0.0</version>
+        </dependency>
         <!--<dependency>
         <!--<dependency>
             <groupId>org.springframework.boot</groupId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-security</artifactId>
             <artifactId>spring-boot-starter-security</artifactId>

+ 1 - 0
src/main/java/com/caimei/AdminApplication.java

@@ -9,6 +9,7 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.EnableMBeanExport;
 import org.springframework.context.annotation.EnableMBeanExport;
 import org.springframework.context.annotation.Import;
 import org.springframework.context.annotation.Import;
 import org.springframework.jmx.support.RegistrationPolicy;
 import org.springframework.jmx.support.RegistrationPolicy;
+import org.springframework.scheduling.annotation.EnableAsync;
 
 
 import javax.servlet.MultipartConfigElement;
 import javax.servlet.MultipartConfigElement;
 
 

+ 11 - 0
src/main/java/com/caimei/config/FastDfsClient.java

@@ -4,6 +4,7 @@ import com.github.tobato.fastdfs.domain.StorePath;
 import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
 import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.FilenameUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,6 +17,7 @@ import java.io.*;
  * @date 2021/5/14
  * @date 2021/5/14
  */
  */
 @Component
 @Component
+@Slf4j
 public class FastDfsClient {
 public class FastDfsClient {
 
 
     @Autowired
     @Autowired
@@ -47,4 +49,13 @@ public class FastDfsClient {
         outputStream.close();
         outputStream.close();
         return true;
         return true;
     }
     }
+
+    public void deleteFile(String storagePath) {
+        try {
+            String filepath = storagePath.substring(storagePath.lastIndexOf("group1/") + 7);
+            storageClient.deleteFile("group1", filepath);
+        } catch (Exception e) {
+            log.error("删除失败!-------------》" + e);
+        }
+    }
 }
 }

+ 33 - 0
src/main/java/com/caimei/config/TaskPoolConfig.java

@@ -0,0 +1,33 @@
+package com.caimei.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/11/12
+ */
+@Configuration
+@EnableAsync
+public class TaskPoolConfig {
+    @Bean("taskExecutor")
+    public Executor taskExecutor(){
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(10);
+        executor.setMaxPoolSize(20);
+        executor.setQueueCapacity(200);
+        executor.setKeepAliveSeconds(60);
+        executor.setThreadNamePrefix("asyncTask-");
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        executor.setWaitForTasksToCompleteOnShutdown(true);
+        executor.setAwaitTerminationSeconds(60);
+        return executor;
+    }
+}

+ 2 - 2
src/main/java/com/caimei/controller/admin/auth/UploadApi.java

@@ -1,6 +1,7 @@
 package com.caimei.controller.admin.auth;
 package com.caimei.controller.admin.auth;
 
 
 import com.caimei.service.auth.UploadService;
 import com.caimei.service.auth.UploadService;
+import com.caimei.service.data.DatabaseService;
 import com.caimei.utils.OSSUtils;
 import com.caimei.utils.OSSUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParam;
@@ -46,7 +47,7 @@ public class UploadApi {
     public Map<String, Object> uploadImage(MultipartFile file) throws IOException {
     public Map<String, Object> uploadImage(MultipartFile file) throws IOException {
         Map<String, Object> map = new HashMap<>(2);
         Map<String, Object> map = new HashMap<>(2);
         String saveFile;
         String saveFile;
-        if (file != null ) {
+        if (file != null) {
             // 保存文件
             // 保存文件
             saveFile = uploadService.saveFile(file);
             saveFile = uploadService.saveFile(file);
             map.put("data", saveFile);
             map.put("data", saveFile);
@@ -60,7 +61,6 @@ public class UploadApi {
     }
     }
 
 
 
 
-
     @ApiOperation("上传文件")
     @ApiOperation("上传文件")
     @ApiImplicitParam(name = "file", value = "文件", required = true)
     @ApiImplicitParam(name = "file", value = "文件", required = true)
     @PostMapping("/file")
     @PostMapping("/file")

+ 6 - 2
src/main/java/com/caimei/controller/admin/data/ArticleApi.java

@@ -60,7 +60,8 @@ public class ArticleApi {
     }
     }
 
 
     @ApiOperation("添加/编辑文章")
     @ApiOperation("添加/编辑文章")
-    @ApiImplicitParam(name = "params", value = "articleId:文章id;articleTitle:文章标题;articleImage:文章图片;articleContent:文章内容", required = true)
+    @ApiImplicitParam(name = "params", value = "articleId:文章id;articleTitle:文章标题;articleImage:文章图片;articleContent:文章内容;" +
+            "parentId:父级文件夹id;articleType:文章类型1自主2第三方;articleLink:文章链接", required = true)
     @PostMapping("/save")
     @PostMapping("/save")
     public ResponseJson saveArticle(@CurrentUser SysUser sysUser, @RequestBody String params) {
     public ResponseJson saveArticle(@CurrentUser SysUser sysUser, @RequestBody String params) {
         if (null == sysUser) {
         if (null == sysUser) {
@@ -74,8 +75,11 @@ public class ArticleApi {
         String articleTitle = paramsMap.getString("articleTitle");
         String articleTitle = paramsMap.getString("articleTitle");
         String articleImage = paramsMap.getString("articleImage");
         String articleImage = paramsMap.getString("articleImage");
         String articleContent = paramsMap.getString("articleContent");
         String articleContent = paramsMap.getString("articleContent");
+        Integer parentId = paramsMap.getInteger("parentId");
         Integer sort = paramsMap.getInteger("sort");
         Integer sort = paramsMap.getInteger("sort");
-        return articleService.saveArticle(articleId, authUserId, articleTitle, articleImage, articleContent, sort);
+        Integer articleType = paramsMap.getInteger("articleType");
+        String articleLink = paramsMap.getString("articleLink");
+        return articleService.saveArticle(articleId, authUserId, articleTitle, articleImage, articleContent, sort, parentId, articleType, articleLink);
     }
     }
 
 
     @ApiOperation("文章回显数据")
     @ApiOperation("文章回显数据")

+ 221 - 0
src/main/java/com/caimei/controller/admin/data/DatabaseApi.java

@@ -0,0 +1,221 @@
+package com.caimei.controller.admin.data;
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
+import com.caimei.model.vo.FileTreeVo;
+import com.caimei.service.data.DatabaseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author zzj
+ */
+@Api(tags = "资料库Api")
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/database")
+public class DatabaseApi {
+
+    private final DatabaseService databaseService;
+
+    @ApiOperation("获取当前路径下文件")
+    @ApiImplicitParam(name = "fileId", required = true, value = "文件Id")
+    @GetMapping("/path/file")
+    public ResponseJson<List<FileTreeVo>> getFileById(@CurrentUser SysUser sysUser, Integer fileId) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.getFileById(fileId, authUserId);
+    }
+
+    @ApiOperation("获取文件详情")
+    @ApiImplicitParam(name = "fileId", required = true, value = "文件Id")
+    @GetMapping("/file/detail")
+    public ResponseJson<FileTreeVo> getFileDetail(@CurrentUser SysUser sysUser, Integer fileId) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.getFileDetail(fileId, authUserId);
+    }
+
+    @ApiOperation("面包屑")
+    @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id")
+    @GetMapping("/path/crumbs")
+    public ResponseJson<FileTreeVo> getCrumbs(@CurrentUser SysUser sysUser, Integer fileId) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.getCrumbs(fileId, authUserId);
+    }
+
+    @ApiOperation("创建文件夹")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id"),
+            @ApiImplicitParam(name = "fileName", required = true, value = "文件夹名称")
+    })
+    @PostMapping("/path/package")
+    public ResponseJson createPackage(@CurrentUser SysUser sysUser, @RequestBody String param) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject jsonObject = JSONObject.parseObject(param);
+        Integer fileId = jsonObject.getInteger("fileId");
+        String fileName = jsonObject.getString("fileName");
+        return databaseService.createPackage(authUserId, fileId, fileName);
+    }
+
+    @ApiOperation("修改文件/文件夹名")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id"),
+            @ApiImplicitParam(name = "fileName", required = true, value = "修改的文件名称"),
+            @ApiImplicitParam(name = "packageType", required = true, value = "0是文件夹,1是文件")
+    })
+    @PostMapping("/update/fileName")
+    public ResponseJson updatePackage(@RequestBody String params) {
+        JSONObject parseObject = JSONObject.parseObject(params);
+        Integer fileId = parseObject.getInteger("fileId");
+        String fileName = parseObject.getString("fileName");
+        Integer packageType = parseObject.getInteger("packageType");
+        return databaseService.updatePackage(fileId, fileName, packageType);
+    }
+
+    @ApiOperation("移动文件")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件Id"),
+            @ApiImplicitParam(name = "parentId", required = true, value = "目标文件夹Id")
+    })
+    @PostMapping("/move/package")
+    public ResponseJson movePackage(@RequestBody String param) {
+        JSONObject jsonObject = JSONObject.parseObject(param);
+        String fileId = jsonObject.getString("fileId");
+        Integer parentId = jsonObject.getInteger("parentId");
+        return databaseService.movePackage(fileId, parentId);
+    }
+
+    @ApiOperation("文件夹目录")
+    @GetMapping("/file/tree")
+    public ResponseJson<FileTreeVo> getPackageTree(@CurrentUser SysUser sysUser) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.getPackageTree(authUserId);
+    }
+
+    @ApiOperation("下载文件夹")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id"),
+            @ApiImplicitParam(name = "fileName", required = true, value = "文件夹名称")
+    })
+    @GetMapping("/path/package/zip")
+    public ResponseJson downLoadPackageZip(@CurrentUser SysUser sysUser, Integer fileId, String fileName, HttpServletResponse response) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.downLoadZip(fileId, fileName, authUserId, response);
+    }
+
+    @ApiOperation("勾选文件下载")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "勾选文件Id,逗号分隔")
+    })
+    @GetMapping("/path/chose/zip")
+    public ResponseJson downLoadChoseZip(@CurrentUser SysUser sysUser, String fileId, HttpServletResponse response) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        return databaseService.downLoadChoseZip(fileId, authUserId, response);
+    }
+
+    @ApiOperation("删除文件")
+    @ApiImplicitParam(name = "fileId", required = true, value = "当前文件Id")
+    @PostMapping("/delete/file")
+    public ResponseJson deleteFiles(@RequestBody String fileId) {
+        JSONObject jsonObject = JSONObject.parseObject(fileId);
+        String fil = jsonObject.getString("fileId");
+        return databaseService.deleteFiles(fil);
+    }
+
+    @ApiOperation("上传结果")
+    @ApiImplicitParam(name = "params", required = true, value = "fileName:文件原名;ossName:阿里云文件名:ossUrl:阿里云文件url;fileSize:文件大小;parentId:父级文件夹id;mime:文件application")
+    @PostMapping("/oss/upload/result")
+    public ResponseJson getOssUploadResult(@CurrentUser SysUser sysUser, @RequestBody String params) {
+        if (null == sysUser) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 获取供应商用户id
+        Integer userIdentity = sysUser.getUserIdentity();
+        Integer authUserId = 2 == userIdentity ? sysUser.getId() : 3 == userIdentity ? sysUser.getParentId() : null;
+        if (null == authUserId) {
+            return ResponseJson.error("供应商用户id不能为空", null);
+        }
+        JSONObject parseObject = JSONObject.parseObject(params);
+        String fileName = parseObject.getString("fileName");
+        String ossName = parseObject.getString("ossName");
+        String ossUrl = parseObject.getString("ossUrl");
+        String fileSize = parseObject.getString("fileSize");
+        Integer parentId = parseObject.getInteger("parentId");
+        String mime = parseObject.getString("mime");
+        return databaseService.getOssUploadResult(authUserId, fileName, ossName, ossUrl, fileSize, parentId,mime);
+    }
+
+    @ApiOperation("获取阿里云token")
+    @GetMapping("/oss/token")
+    public ResponseJson<HashMap<String, String>> ossTokenGet() {
+        return databaseService.ossTokenGet();
+    }
+}

+ 47 - 0
src/main/java/com/caimei/controller/noToken/WxDatabaseApi.java

@@ -0,0 +1,47 @@
+package com.caimei.controller.noToken;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.FileTreeVo;
+import com.caimei.service.data.DatabaseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Api(tags = "前端资料库Api")
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/notoken/path")
+public class WxDatabaseApi {
+
+    private final DatabaseService databaseService;
+
+    @ApiOperation("获取当前路径下文件")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "文件Id"),
+            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    })
+    @GetMapping("/file")
+    public ResponseJson<List<FileTreeVo>> getFileById(Integer fileId, Integer authUserId) {
+        return databaseService.getFileById(fileId, authUserId);
+    }
+
+    @ApiOperation("面包屑")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id"),
+            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    })
+    @GetMapping("/crumbs")
+    public ResponseJson<FileTreeVo> getCrumbs(Integer fileId, Integer authUserId) {
+        return databaseService.getCrumbs(fileId, authUserId);
+    }
+
+}

+ 31 - 5
src/main/java/com/caimei/controller/wechat/WxDataApi.java

@@ -1,10 +1,13 @@
 package com.caimei.controller.wechat;
 package com.caimei.controller.wechat;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.annotation.CurrentUser;
 import com.caimei.aop.IpSave;
 import com.caimei.aop.IpSave;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.*;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.*;
 import com.caimei.service.auth.*;
+import com.caimei.service.data.DatabaseService;
 import com.caimei.service.data.FileService;
 import com.caimei.service.data.FileService;
 import com.caimei.service.data.ImageService;
 import com.caimei.service.data.ImageService;
 import com.caimei.service.data.VideoService;
 import com.caimei.service.data.VideoService;
@@ -17,6 +20,9 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
 /**
 /**
  * @author Aslee
  * @author Aslee
  */
  */
@@ -31,6 +37,7 @@ public class WxDataApi {
     private final VideoService videoService;
     private final VideoService videoService;
     private final FileService fileService;
     private final FileService fileService;
     private final AuthClubService authClubService;
     private final AuthClubService authClubService;
+    private final DatabaseService databaseService;
 
 
     @ApiOperation("资料库文章列表")
     @ApiOperation("资料库文章列表")
     @ApiImplicitParams({
     @ApiImplicitParams({
@@ -39,7 +46,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     })
-    @IpSave(saveName = "文章列表",saveParams = true)
+    @IpSave(saveName = "文章列表", saveParams = true)
     @GetMapping("/article/list")
     @GetMapping("/article/list")
     public ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle,
     public ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -47,9 +54,28 @@ public class WxDataApi {
         return articleService.getWxArticleList(authUserId, articleTitle, pageNum, pageSize);
         return articleService.getWxArticleList(authUserId, articleTitle, pageNum, pageSize);
     }
     }
 
 
+    @ApiOperation("获取文件详情")
+    @ApiImplicitParam(name = "fileId", required = true, value = "文件Id")
+    @GetMapping("/file/detail")
+    public ResponseJson<FileTreeVo> getFileDetail(Integer authUserId, Integer fileId) {
+        return databaseService.getFileDetail(fileId, authUserId);
+    }
+
+    @ApiOperation("下载文件夹")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileId", required = true, value = "当前文件夹Id"),
+            @ApiImplicitParam(name = "fileName", required = true, value = "文件夹名称"),
+            @ApiImplicitParam(name = "authUserId", required = true, value = "供应商用户id")
+    })
+    @GetMapping("/path/package/zip")
+    public ResponseJson downLoadPackageZip(Integer fileId, String fileName, Integer authUserId, HttpServletResponse response) {
+        return databaseService.downLoadZip(fileId, fileName, authUserId, response);
+    }
+
+
     @ApiOperation("资料库文章回显数据")
     @ApiOperation("资料库文章回显数据")
     @ApiImplicitParam(name = "articleId", value = "文章id", required = true)
     @ApiImplicitParam(name = "articleId", value = "文章id", required = true)
-    @IpSave(saveName = "文章详情",saveParams = true)
+    @IpSave(saveName = "文章详情", saveParams = true)
     @GetMapping("/article/form/data")
     @GetMapping("/article/form/data")
     public ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId) {
     public ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId) {
         return articleService.getArticleFormData(articleId);
         return articleService.getArticleFormData(articleId);
@@ -62,7 +88,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     })
-    @IpSave(saveName = "图片列表",saveParams = true)
+    @IpSave(saveName = "图片列表", saveParams = true)
     @GetMapping("/image/list")
     @GetMapping("/image/list")
     public ResponseJson<PageInfo<WxImageListVo>> getWxImageList(Integer authUserId, String imageTitle,
     public ResponseJson<PageInfo<WxImageListVo>> getWxImageList(Integer authUserId, String imageTitle,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -77,7 +103,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     })
-    @IpSave(saveName = "资料库视频列表",saveParams = true)
+    @IpSave(saveName = "资料库视频列表", saveParams = true)
     @GetMapping("/video/list")
     @GetMapping("/video/list")
     public ResponseJson<PageInfo<WxVideoListVo>> getWxVideoList(Integer authUserId, String videoTitle,
     public ResponseJson<PageInfo<WxVideoListVo>> getWxVideoList(Integer authUserId, String videoTitle,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -93,7 +119,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
     })
-    @IpSave(saveName = "文件列表",saveParams = true)
+    @IpSave(saveName = "文件列表", saveParams = true)
     @GetMapping("/file/list")
     @GetMapping("/file/list")
     public ResponseJson<PageInfo<WxFileListVo>> getWxFileList(Integer authUserId, Integer fileType, String fileTitle,
     public ResponseJson<PageInfo<WxFileListVo>> getWxFileList(Integer authUserId, Integer fileType, String fileTitle,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,

+ 1 - 1
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -93,7 +93,7 @@ public interface AuthProductMapper {
 
 
     void checkAuthProduct(Integer productId);
     void checkAuthProduct(Integer productId);
 
 
-    Integer insertProductRelation(@Param("authId") Integer authId, @Param("productId") Integer productId, @Param("authType") Integer authType);
+    void insertProductRelation(ProductRelationVo relationVo);
 
 
     ProductRelationVo getProductRelation(@Param("relationId") Integer relationId, @Param("productId") Integer productId, @Param("authId") Integer authId);
     ProductRelationVo getProductRelation(@Param("relationId") Integer relationId, @Param("productId") Integer productId, @Param("authId") Integer authId);
 
 

+ 28 - 0
src/main/java/com/caimei/mapper/cmMapper/FileMapper.java

@@ -52,4 +52,32 @@ public interface FileMapper {
     FilePo getFileForm(Integer fileId);
     FilePo getFileForm(Integer fileId);
 
 
     void checkFile(Integer fileId);
     void checkFile(Integer fileId);
+
+    List<AuthVo> getAuthImageList(Integer authUserId);
+
+    List<FileTreeVo> findFileTree(@Param("fileId") Integer fileId, @Param("authUserId") Integer authUserId,@Param("packageType")Integer packageType);
+
+    List<FileTreeVo> findFileChild(Integer fileId);
+
+    void creatPackage(@Param("authUserId") Integer authUserId,@Param("fileId") Integer fileId, @Param("packageName") String packageName);
+
+    List<FileTreeVo> findSonFiles(Integer fileId);
+
+    List<FileTreeVo> findSonPackage(@Param("fileId") Integer fileId, @Param("authUserId") Integer authUserId, @Param("selectFor") Integer selectFor);
+
+    void insertNewFile(FileTreeVo fileTreeVo);
+
+    void updateFile(FileTreeVo fileTreeVo);
+
+    FileTreeVo findFile(@Param("fileId")Integer fileId,@Param("authUserId") Integer authUserId,@Param("packageType")Integer packageType);
+
+    void deleteFileTreeById(Integer fileId);
+
+    String findShopPrefix(Integer authUserId);
+
+    void insertImgUrl(FileTreeVo fileTreeVo);
+
+    void updateFileByArticleId(FileTreeVo fileTreeVo);
+
+    FileTreeVo findFileByArticleId(Integer id);
 }
 }

+ 8 - 0
src/main/java/com/caimei/model/po/ArticlePo.java

@@ -74,4 +74,12 @@ public class ArticlePo {
      * 排序值
      * 排序值
      */
      */
     private Integer sort;
     private Integer sort;
+    /**
+     * 文章类型1自主2第三方
+     */
+    private Integer articleType;
+    /**
+     * 第三方文章链接
+     */
+    private String articleLink;
 }
 }

+ 6 - 0
src/main/java/com/caimei/model/vo/ArticleFormVo.java

@@ -32,4 +32,10 @@ public class ArticleFormVo {
 
 
     @ApiModelProperty("排序值")
     @ApiModelProperty("排序值")
     private Integer sort;
     private Integer sort;
+
+    @ApiModelProperty("文章类型")
+    private Integer articleType;
+
+    @ApiModelProperty("文章链接")
+    private String articleLink;
 }
 }

+ 79 - 0
src/main/java/com/caimei/model/vo/FileTreeVo.java

@@ -0,0 +1,79 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author zzj
+ */
+@Data
+public class FileTreeVo implements Serializable {
+    private Integer authUserId;
+    /**
+     * 父级文件id
+     */
+    private Integer parentId;
+    /**
+     * 自身文件id
+     */
+    private Integer id;
+    /**
+     * 文件类型
+     */
+    private String fileType;
+    /**
+     * 文件名
+     */
+    private String fileName;
+    /**
+     * 阿里云文件名
+     */
+    private String ossName;
+    /**
+     * 阿里云链接
+     */
+    private String ossUrl;
+    /**
+     * 父级节点
+     */
+    protected FileTreeVo parentNode;
+    /**
+     * 子级节点
+     */
+    protected FileTreeVo childNode;
+    /**
+     * 子级节点列表
+     */
+    protected List<FileTreeVo> childList;
+    /**
+     * 文件保存时间
+     */
+    private Date saveTime;
+    /**
+     * 文件大小
+     */
+    private String fileSize;
+    /**
+     * 0是文件夹,1不是
+     */
+    private Integer packageType;
+    /**
+     * 文件扩展类型
+     */
+    private String mime;
+    /**
+     * 文章Id
+     */
+    private Integer articleId;
+    /**
+     * 缩略图url
+     */
+    private String screenshot;
+    /**
+     * 文章类型1自主2第三方
+     */
+    private Integer articleType;
+}

+ 167 - 0
src/main/java/com/caimei/service/async/AsyncService.java

@@ -0,0 +1,167 @@
+package com.caimei.service.async;
+
+import com.caimei.config.FastDfsClient;
+import com.caimei.mapper.cmMapper.ArticleMapper;
+import com.caimei.mapper.cmMapper.FileMapper;
+import com.caimei.model.po.ArticlePo;
+import com.caimei.model.vo.ArticleFormVo;
+import com.caimei.model.vo.FileTreeVo;
+import com.caimei.utils.FileZipUtils;
+import com.caimei.utils.OSSUtils;
+import lombok.extern.slf4j.Slf4j;
+import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+
+import javax.annotation.Resource;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.UUID;
+
+/**
+ * @author zzj
+ */
+@Slf4j
+@Component
+public class AsyncService {
+
+
+    @Value("${spring.profiles.active}")
+    private String active;
+
+    @Value("${caimei.zpapi}")
+    private String zpapi;
+
+    @Resource
+    private FileMapper fileMapper;
+
+    @Value("${caimei.imageDomain}")
+    private String imageDomain;
+
+    @Resource
+    private FastDfsClient client;
+
+    @Resource
+    private ArticleMapper articleMapper;
+
+    @Async("taskExecutor")
+    public void saveArticleImage(boolean insertFlag, ArticlePo article, Integer parentId) {
+        //保存文章相关属性
+        FileTreeVo fileTreeVo = new FileTreeVo();
+        fileTreeVo.setPackageType(1);
+        fileTreeVo.setMime("text/plain");
+        fileTreeVo.setFileName(article.getTitle() + ".txt");
+        fileTreeVo.setFileType("article");
+        fileTreeVo.setParentId(parentId);
+        fileTreeVo.setAuthUserId(article.getAuthUserId());
+        fileTreeVo.setArticleId(article.getId());
+        UUID uuid = UUID.randomUUID();
+        fileTreeVo.setOssName(uuid + ".txt");
+        //http://192.168.2.92:8888/:authUserId/:prefix/docs/article-detail?fileId=fileId
+        String prefix = fileMapper.findShopPrefix(article.getAuthUserId());
+        prefix = null == prefix ? "app" : prefix;
+        String path = "";
+        path = "/" + article.getAuthUserId() + "/" + prefix + "/docs/article-detail?articleId=" + article.getId();
+        if ("dev".equals(active)) {
+            path = "http://192.168.2.92:8888" + path;
+        } else {
+            path = zpapi + path;
+        }
+        if (2 == article.getArticleType()) {
+            path = article.getArticleLink();
+        }
+        fileTreeVo.setOssUrl(path);
+        //创建txt文件保存链接上传到阿里云
+        String delPath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
+        String filePath = delPath + "/";
+        if ("dev".equals(active)) {
+            delPath = "D:\\caimei-workSpace\\file\\" + uuid;
+            filePath = delPath + "\\";
+        }
+        File file = writeTxt(filePath, path);
+        OSSUtils.ossUpload(fileTreeVo.getOssName(), file, "text/plain", null);
+        try {
+            client.downloadFile(article.getImage(), filePath + "myShotImage.jpg");
+            log.info("下载成功???");
+            Thumbnails.of(filePath + "myShotImage.jpg").size(64, 64).toFile(filePath + "NewMyShotImage.jpg");
+            String imgUrl = imageDomain + "/" + client.uploadFile(filePath + "NewMyShotImage.jpg");
+            fileTreeVo.setScreenshot(imgUrl);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        if (insertFlag) {
+            fileMapper.insertNewFile(fileTreeVo);
+        } else {
+            FileTreeVo fil = fileMapper.findFileByArticleId(article.getId());
+            if (StringUtils.isNotBlank(fil.getScreenshot())) {
+                client.deleteFile(fil.getScreenshot());
+            }
+            if (StringUtils.isNotBlank(fil.getOssName())) {
+                OSSUtils.deleteSingleFile(fil.getOssName());
+            }
+            fileMapper.updateFileByArticleId(fileTreeVo);
+        }
+        File fileDir = new File(delPath);
+        Boolean aBoolean = FileZipUtils.deleteFile(fileDir);
+        log.info("临时txt删除------------>" + aBoolean);
+    }
+
+    private File writeTxt(String filePath, String content) {
+        File fileDir = new File(filePath);
+        boolean mkdirs = fileDir.mkdirs();
+        Assert.isTrue(mkdirs, "文件夹创建失败");
+        FileWriter fw = null;
+        File file = new File(filePath + "1.txt");
+        try {
+            if (!file.exists()) {
+                file.createNewFile();
+            }
+            fw = new FileWriter(filePath + "1.txt");
+            BufferedWriter bw = new BufferedWriter(fw);
+            bw.write(content);
+            bw.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                fw.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return file;
+    }
+
+    public void insertScreenshot(FileTreeVo fileTreeVo) {
+        UUID uuid = UUID.randomUUID();
+        String delPath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
+        String filePath = delPath + "/" + fileTreeVo.getFileName();
+        String newImage = delPath + "/";
+        String imgUrl = "";
+        if ("dev".equals(active)) {
+            delPath = "D:\\caimei-workSpace\\file\\" + uuid;
+            filePath = delPath + "\\" + fileTreeVo.getFileName();
+            newImage = delPath + "\\";
+        }
+        File fileDir = new File(delPath);
+        boolean mkdirs = fileDir.mkdirs();
+        Assert.isTrue(mkdirs, "文件夹创建失败");
+
+        OSSUtils.downFileByFilePath("authFile/", fileTreeVo.getOssName(), filePath);
+        try {
+            Thumbnails.of(filePath).size(64, 64).toFile(newImage + "newImages." + fileTreeVo.getFileType());
+            imgUrl = imageDomain + "/" + client.uploadFile(newImage + "newImages." + fileTreeVo.getFileType());
+        } catch (IOException e) {
+            log.error("压缩图失败:" + e);
+        }
+        fileTreeVo.setScreenshot(imgUrl);
+        fileMapper.insertImgUrl(fileTreeVo);
+        FileZipUtils.deleteFile(fileDir);
+    }
+}

+ 37 - 29
src/main/java/com/caimei/service/auth/ArticleService.java

@@ -17,73 +17,81 @@ public interface ArticleService {
     /**
     /**
      * 获取文章列表
      * 获取文章列表
      *
      *
-     * @param listType      列表类型:1文章列表,2文章审核列表
-     * @param authUserId    供应商用户id
-     * @param articleTitle  文章标题
-     * @param auditStatus   审核状态
-     * @param status        上线状态
-     * @param pageNum       第几页
-     * @param pageSize      一页多少条
-     * @return  ArticleVo
+     * @param listType     列表类型:1文章列表,2文章审核列表
+     * @param authUserId   供应商用户id
+     * @param articleTitle 文章标题
+     * @param auditStatus  审核状态
+     * @param status       上线状态
+     * @param pageNum      第几页
+     * @param pageSize     一页多少条
+     * @return ArticleVo
      */
      */
     ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status, Integer pageNum, Integer pageSize);
     ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status, Integer pageNum, Integer pageSize);
 
 
     /**
     /**
      * 添加/编辑文章
      * 添加/编辑文章
-     * @param articleId         文章id
-     * @param authUserId        供应商用户id
-     * @param articleTitle      文章标题
-     * @param articleImage      文章图片
-     * @param articleContent    文章内容
+     *
+     * @param articleId      文章id
+     * @param authUserId     供应商用户id
+     * @param articleTitle   文章标题
+     * @param articleImage   文章图片
+     * @param articleContent 文章内容
      * @param sort
      * @param sort
-     * @return  ResponseJson
+     * @param parentId       父级文件夹id
+     * @return ResponseJson
      */
      */
-    ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort);
+    ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort, Integer parentId,Integer articleType,String articleLink);
 
 
     /**
     /**
      * 更新文章状态
      * 更新文章状态
-     * @param articleId     文章id
-     * @param status        文章状态:0停用 1启用
-     * @return  ResponseJson
+     *
+     * @param articleId 文章id
+     * @param status    文章状态:0停用 1启用
+     * @return ResponseJson
      */
      */
     ResponseJson updateArticleStatus(Integer articleId, Integer status);
     ResponseJson updateArticleStatus(Integer articleId, Integer status);
 
 
     /**
     /**
      * 删除文章
      * 删除文章
-     * @param articleId     文章id
-     * @return  ResponseJson
+     *
+     * @param articleId 文章id
+     * @return ResponseJson
      */
      */
     ResponseJson deleteArticle(Integer articleId);
     ResponseJson deleteArticle(Integer articleId);
 
 
     /**
     /**
      * 审核文章
      * 审核文章
-     * @param articleId         文章id
-     * @param auditStatus       审核状态:0审核未通过,1审核通过,2待审核
-     * @param invalidReason     审核不通过原因
-     * @param auditBy           审核人用户id
+     *
+     * @param articleId     文章id
+     * @param auditStatus   审核状态:0审核未通过,1审核通过,2待审核
+     * @param invalidReason 审核不通过原因
+     * @param auditBy       审核人用户id
      * @return
      * @return
      */
      */
     ResponseJson auditArticle(Integer articleId, Integer auditStatus, String invalidReason, Integer auditBy);
     ResponseJson auditArticle(Integer articleId, Integer auditStatus, String invalidReason, Integer auditBy);
 
 
     /**
     /**
      * 文章回显数据
      * 文章回显数据
-     * @param articleId     文章id
+     *
+     * @param articleId 文章id
      * @return
      * @return
      */
      */
     ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId);
     ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId);
 
 
     /**
     /**
      * 微信公众号文章列表
      * 微信公众号文章列表
-     * @param authUserId    供应商用户id
-     * @param articleTitle   文章名称
-     * @param pageNum       第几页
-     * @param pageSize      一页多少条
+     *
+     * @param authUserId   供应商用户id
+     * @param articleTitle 文章名称
+     * @param pageNum      第几页
+     * @param pageSize     一页多少条
      * @return
      * @return
      */
      */
     ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle, Integer pageNum, Integer pageSize);
     ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle, Integer pageNum, Integer pageSize);
 
 
     /**
     /**
      * 更改查看标记
      * 更改查看标记
+     *
      * @param articleId
      * @param articleId
      * @return
      * @return
      */
      */

+ 27 - 5
src/main/java/com/caimei/service/auth/impl/ArticleServiceImpl.java

@@ -1,17 +1,24 @@
 package com.caimei.service.auth.impl;
 package com.caimei.service.auth.impl;
 
 
+import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.cmMapper.ArticleMapper;
 import com.caimei.mapper.cmMapper.ArticleMapper;
 import com.caimei.mapper.cmMapper.AuthMapper;
 import com.caimei.mapper.cmMapper.AuthMapper;
+import com.caimei.mapper.cmMapper.FileMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.ArticlePo;
 import com.caimei.model.po.ArticlePo;
+import com.caimei.model.po.SysUser;
 import com.caimei.model.vo.ArticleFormVo;
 import com.caimei.model.vo.ArticleFormVo;
 import com.caimei.model.vo.ArticleListVo;
 import com.caimei.model.vo.ArticleListVo;
+import com.caimei.model.vo.FileTreeVo;
 import com.caimei.model.vo.WxArticleListVo;
 import com.caimei.model.vo.WxArticleListVo;
+import com.caimei.service.async.AsyncService;
 import com.caimei.service.auth.ArticleService;
 import com.caimei.service.auth.ArticleService;
+import com.caimei.utils.OSSUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -34,6 +41,12 @@ public class ArticleServiceImpl implements ArticleService {
     @Resource
     @Resource
     private AuthMapper authMapper;
     private AuthMapper authMapper;
 
 
+    @Resource
+    private AsyncService asyncService;
+
+    @Resource
+    private FastDfsClient fastDfsClient;
+
     @Override
     @Override
     public ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status, Integer pageNum, Integer pageSize) {
     public ResponseJson<PageInfo<ArticleListVo>> getArticleList(Integer listType, Integer authUserId, String articleTitle, Integer auditStatus, Integer status, Integer pageNum, Integer pageSize) {
         listType = null == listType ? 1 : listType;
         listType = null == listType ? 1 : listType;
@@ -44,7 +57,7 @@ public class ArticleServiceImpl implements ArticleService {
     }
     }
 
 
     @Override
     @Override
-    public ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort) {
+    public ResponseJson saveArticle(Integer articleId, Integer authUserId, String articleTitle, String articleImage, String articleContent, Integer sort, Integer parentId, Integer articleType, String articleLink) {
         if (null == articleId && null == authUserId) {
         if (null == articleId && null == authUserId) {
             return ResponseJson.error("参数异常,请输入供应商用户id");
             return ResponseJson.error("参数异常,请输入供应商用户id");
         }
         }
@@ -54,11 +67,14 @@ public class ArticleServiceImpl implements ArticleService {
         if (StringUtils.isEmpty(articleImage)) {
         if (StringUtils.isEmpty(articleImage)) {
             return ResponseJson.error("参数异常,请输入文章图片");
             return ResponseJson.error("参数异常,请输入文章图片");
         }
         }
-        if (StringUtils.isEmpty(articleContent)) {
+        if (null == articleType) {
+            return ResponseJson.error("参数异常,请选择文章类型");
+        }
+        if (1 == articleType && StringUtils.isEmpty(articleContent)) {
             return ResponseJson.error("参数异常,请输入文章内容");
             return ResponseJson.error("参数异常,请输入文章内容");
         }
         }
-        if (null == sort) {
-            return ResponseJson.error("排序值不能为空");
+        if (2 == articleType && StringUtils.isBlank(articleLink)) {
+            return ResponseJson.error("参数异常,请输入文章链接");
         }
         }
         boolean insertFlag = null == articleId;
         boolean insertFlag = null == articleId;
         ArticleFormVo dbArticle = null;
         ArticleFormVo dbArticle = null;
@@ -72,7 +88,8 @@ public class ArticleServiceImpl implements ArticleService {
         article.setTitle(articleTitle);
         article.setTitle(articleTitle);
         article.setImage(articleImage);
         article.setImage(articleImage);
         article.setContent(articleContent);
         article.setContent(articleContent);
-        article.setSort(sort);
+        article.setArticleLink(articleLink);
+        article.setArticleType(articleType);
         // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
         // 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
         if (null != dbArticle && 1 != dbArticle.getAuditStatus()) {
         if (null != dbArticle && 1 != dbArticle.getAuditStatus()) {
             // 被驳回的数据,编辑后变为待审核状态
             // 被驳回的数据,编辑后变为待审核状态
@@ -94,8 +111,13 @@ public class ArticleServiceImpl implements ArticleService {
         } else {
         } else {
             article.setId(articleId);
             article.setId(articleId);
             // 更新文章
             // 更新文章
+            ArticleFormVo articleForm = articleMapper.getArticleForm(article.getId());
+            if (StringUtils.isNotBlank(articleForm.getArticleImage())) {
+                fastDfsClient.deleteFile(articleForm.getArticleImage());
+            }
             articleMapper.updateArticleByArticleId(article);
             articleMapper.updateArticleByArticleId(article);
         }
         }
+        asyncService.saveArticleImage(insertFlag, article, parentId);
         return ResponseJson.success("保存文章成功");
         return ResponseJson.success("保存文章成功");
     }
     }
 
 

+ 8 - 3
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -310,8 +310,13 @@ public class AuthProductServiceImpl implements AuthProductService {
                 // 关联设备,更新设备
                 // 关联设备,更新设备
                 authProductMapper.updateProductByProductId(product);
                 authProductMapper.updateProductByProductId(product);
             }
             }
+            ProductRelationVo relationVo = new ProductRelationVo();
+            relationVo.setAuthId(authId);
+            relationVo.setProductId(product.getProductId());
+            relationVo.setAuthType(authType);
             // 插入机构设备关联关系
             // 插入机构设备关联关系
-            relationId = authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
+            authProductMapper.insertProductRelation(relationVo);
+            relationId = relationVo.getRelationId();
         } else {
         } else {
             if (1 == dbRelation.getAuthType()) {
             if (1 == dbRelation.getAuthType()) {
                 // 更新设备
                 // 更新设备
@@ -465,7 +470,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 map.put("addWord2_style", Font.BOLD);
                 map.put("addWord2_style", Font.BOLD);
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_x", (int) Math.round(2168 * rate));
                 map.put("addWord2_x", (int) Math.round(2168 * rate));
-                map.put("addWord2_y", (int) Math.round(3160 * rate));
+                map.put("addWord2_y", (int) Math.round(3157 * rate));
             }
             }
             // 添加认证日期信息
             // 添加认证日期信息
             if (null != product.getCreateTime()) {
             if (null != product.getCreateTime()) {
@@ -476,7 +481,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 map.put("addWord3_style", Font.PLAIN);
                 map.put("addWord3_style", Font.PLAIN);
                 map.put("addWord3_size", (int) Math.round(90 * rate));
                 map.put("addWord3_size", (int) Math.round(90 * rate));
                 map.put("addWord3_x", (int) Math.round(2085 * rate));
                 map.put("addWord3_x", (int) Math.round(2085 * rate));
-                map.put("addWord3_y", (int) Math.round(3292 * rate));
+                map.put("addWord3_y", (int) Math.round(3289 * rate));
             }
             }
             // 添加二维码信息
             // 添加二维码信息
             if (StringUtils.isNotEmpty(template.getQrPosition())) {
             if (StringUtils.isNotEmpty(template.getQrPosition())) {

+ 2 - 2
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -414,7 +414,7 @@ public class AuthServiceImpl implements AuthService {
                 map.put("addWord1_style", Font.BOLD);
                 map.put("addWord1_style", Font.BOLD);
                 map.put("addWord1_size", (int) Math.round(90 * rate));
                 map.put("addWord1_size", (int) Math.round(90 * rate));
                 map.put("addWord1_x", (int) Math.round(2168 * rate));
                 map.put("addWord1_x", (int) Math.round(2168 * rate));
-                map.put("addWord1_y", (int) Math.round(3160 * rate));
+                map.put("addWord1_y", (int) Math.round(3157 * rate));
             }
             }
             // 添加认证日期信息
             // 添加认证日期信息
             if (null != auth.getAuthDate()) {
             if (null != auth.getAuthDate()) {
@@ -425,7 +425,7 @@ public class AuthServiceImpl implements AuthService {
                 map.put("addWord2_style", Font.PLAIN);
                 map.put("addWord2_style", Font.PLAIN);
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_x", (int) Math.round(2085 * rate));
                 map.put("addWord2_x", (int) Math.round(2085 * rate));
-                map.put("addWord2_y", (int) Math.round(3292 * rate));
+                map.put("addWord2_y", (int) Math.round(3289 * rate));
             }
             }
             // 添加二维码信息
             // 添加二维码信息
             if (StringUtils.isNotEmpty(template.getQrPosition())) {
             if (StringUtils.isNotEmpty(template.getQrPosition())) {

+ 39 - 0
src/main/java/com/caimei/service/data/DatabaseService.java

@@ -0,0 +1,39 @@
+package com.caimei.service.data;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.FileTreeVo;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author zzj
+ */
+public interface DatabaseService {
+    ResponseJson<List<FileTreeVo>> getFileById(Integer fileId,Integer authUserId);
+
+    ResponseJson createPackage(Integer authUserId,Integer fileId, String packageName);
+
+    ResponseJson downLoadZip(Integer fileId, String packageName, Integer authUserId,HttpServletResponse response);
+
+    ResponseJson insertNewFile(String fileName, String filePath, String previewUrl, Integer parentId,String fileType);
+
+    ResponseJson<HashMap<String, String>> ossTokenGet();
+
+    ResponseJson getOssUploadResult(Integer authUserId,String fileName, String ossName, String ossUrl, String fileSize,Integer parentId,String mime);
+
+    ResponseJson updatePackage(Integer fileId, String packageName, Integer packageType);
+
+    ResponseJson movePackage(String fileId, Integer parentId);
+
+    ResponseJson deleteFiles(String fileId);
+
+    ResponseJson<FileTreeVo> getCrumbs(Integer fileId, Integer authUserId);
+
+    ResponseJson<FileTreeVo> getPackageTree(Integer authUserId);
+
+    ResponseJson downLoadChoseZip(String fileId, Integer authUserId, HttpServletResponse response);
+
+    ResponseJson<FileTreeVo> getFileDetail(Integer fileId, Integer authUserId);
+}

+ 376 - 0
src/main/java/com/caimei/service/data/impl/DatabaseServiceImpl.java

@@ -0,0 +1,376 @@
+package com.caimei.service.data.impl;
+
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.profile.DefaultProfile;
+import com.caimei.mapper.cmMapper.FileMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.FileTreeVo;
+import com.caimei.service.async.AsyncService;
+import com.caimei.service.data.DatabaseService;
+import com.caimei.utils.FileZipUtils;
+import com.caimei.utils.OSSUtils;
+import com.sun.org.apache.regexp.internal.RE;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author zzj
+ */
+@Slf4j
+@Service
+public class DatabaseServiceImpl implements DatabaseService {
+
+    @Resource
+    private FileMapper fileMapper;
+
+    @Value("${spring.profiles.active}")
+    private String active;
+
+    @Resource
+    private AsyncService asyncService;
+
+    @Override
+    public ResponseJson<List<FileTreeVo>> getFileById(Integer fileId, Integer authUserId) {
+        List<FileTreeVo> fileTree = fileMapper.findFileTree(fileId, authUserId, null);
+        return ResponseJson.success(fileTree);
+    }
+
+    @Override
+    public ResponseJson createPackage(Integer authUserId, Integer fileId, String packageName) {
+        fileMapper.creatPackage(authUserId, fileId, packageName);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson downLoadZip(Integer fileId, String packageName, Integer authUserId, HttpServletResponse response) {
+        //有package则在服务器固定路径new file.mkdir
+        UUID uuid = UUID.randomUUID();
+        String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid + "/";
+        String zipPath = filePath + packageName;
+        String delPath = filePath;
+        filePath = zipPath;
+        if ("dev".equals(active)) {
+            filePath = "D:\\caimei-workSpace\\file\\" + uuid + "\\";
+            zipPath = filePath + packageName;
+            delPath = filePath;
+            filePath = filePath + packageName + "\\";
+        }
+        boolean mkdirs = new File(filePath).mkdirs();
+        Assert.isTrue(mkdirs, "文件夹创建失败");
+
+        String param = fileId + "," + authUserId;
+        recursion(param, filePath);
+        //压缩
+        FileZipUtils.compress(zipPath, "", true);
+        String s = zipPath + ".zip";
+        String fileName = packageName + ".zip";
+        File file = new File(s);
+        try {
+            if (file.exists()) {
+                FileInputStream fileInputStream = new FileInputStream(file);
+                ServletOutputStream outputStream = response.getOutputStream();
+                // 设置下载文件的mineType,告诉浏览器下载文件类型
+                //            int i = fileName.lastIndexOf(".");
+                //            String substring = fileName.substring(i + 1, filePath.length());
+                response.setContentType("application/zip");
+                // 设置一个响应头,无论是否被浏览器解析,都下载
+                response.setHeader("Content-disposition", "attachment; filename=" + fileName);
+                byte[] bytes = new byte[1024];
+                int len;
+                while ((len = fileInputStream.read(bytes)) != -1) {
+                    outputStream.write(bytes, 0, len);
+                }
+                fileInputStream.close();
+                outputStream.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        FileZipUtils.deleteFile(new File(delPath));
+        return null;
+    }
+
+    @Override
+    public ResponseJson insertNewFile(String fileName, String filePath, String previewUrl, Integer parentId, String fileType) {
+        FileTreeVo fileTreeVo = new FileTreeVo();
+        fileTreeVo.setFileName(fileName);
+        fileTreeVo.setOssName(filePath);
+        fileTreeVo.setOssUrl(previewUrl);
+        fileTreeVo.setParentId(parentId);
+        fileTreeVo.setFileType(fileType);
+        fileMapper.insertNewFile(fileTreeVo);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson<HashMap<String, String>> ossTokenGet() {
+        return ResponseJson.success(OSSUtils.getToken());
+    }
+
+    @Override
+    public ResponseJson getOssUploadResult(Integer authUserId, String fileName, String ossName, String ossUrl, String fileSize, Integer parentId, String mime) {
+        FileTreeVo fileTreeVo = new FileTreeVo();
+        fileTreeVo.setFileName(fileName);
+        fileTreeVo.setOssName(ossName);
+        fileTreeVo.setOssUrl(ossUrl);
+        fileTreeVo.setParentId(parentId);
+        if (fileName.contains(".")) {
+            fileTreeVo.setFileType(fileName.substring(fileName.lastIndexOf(".") + 1));
+        }
+        fileTreeVo.setFileSize(fileSize);
+        fileTreeVo.setPackageType(1);
+        fileTreeVo.setAuthUserId(authUserId);
+        fileTreeVo.setMime(mime);
+        fileMapper.insertNewFile(fileTreeVo);
+        if (mime.contains("image")) {
+            //图片保存缩略图
+            asyncService.insertScreenshot(fileTreeVo);
+        }
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson updatePackage(Integer fileId, String packageName, Integer packageType) {
+        FileTreeVo fileTreeVo = new FileTreeVo();
+        fileTreeVo.setId(fileId);
+        fileTreeVo.setPackageType(packageType);
+        fileTreeVo.setFileName(packageName);
+        fileMapper.updateFile(fileTreeVo);
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson movePackage(String fileId, Integer parentId) {
+        if (fileId.contains(",")) {
+            String[] split = fileId.split(",");
+            for (String s : split) {
+                FileTreeVo fileTreeVo = new FileTreeVo();
+                fileTreeVo.setId(Integer.valueOf(s));
+                fileTreeVo.setParentId(parentId);
+                fileMapper.updateFile(fileTreeVo);
+            }
+        } else {
+            FileTreeVo fileTreeVo = new FileTreeVo();
+            fileTreeVo.setId(Integer.valueOf(fileId));
+            fileTreeVo.setParentId(parentId);
+            fileMapper.updateFile(fileTreeVo);
+        }
+        return ResponseJson.success();
+    }
+
+    @Override
+    public ResponseJson deleteFiles(String fileId) {
+        if (fileId.contains(",")) {
+            String[] split = fileId.split(",");
+            for (String s : split) {
+                deleteFilesById(Integer.valueOf(s));
+            }
+        } else {
+            deleteFilesById(Integer.valueOf(fileId));
+        }
+        return ResponseJson.success();
+    }
+
+    private void deleteFilesById(Integer fileId) {
+        FileTreeVo file = fileMapper.findFile(fileId, null, null);
+        if (0 == file.getPackageType()) {
+            //文件夹
+            List<FileTreeVo> fileTree = fileMapper.findFileTree(fileId, null, null);
+            fileTree.forEach(f -> {
+                deleteFilesById(f.getId());
+            });
+            fileMapper.deleteFileTreeById(fileId);
+        } else {
+            //单文件
+            OSSUtils.deleteSingleFile(file.getOssName());
+            fileMapper.deleteFileTreeById(fileId);
+        }
+    }
+
+    @Override
+    public ResponseJson<FileTreeVo> getCrumbs(Integer fileId, Integer authUserId) {
+        if (fileId > 0) {
+            FileTreeVo file = fileMapper.findFile(fileId, authUserId, null);
+            FileTreeVo crumbsParent = getCrumbsParent(file, authUserId);
+            return ResponseJson.success(crumbsParent);
+        } else {
+            return ResponseJson.success();
+        }
+    }
+
+    @Override
+    public ResponseJson<FileTreeVo> getPackageTree(Integer authUserId) {
+        FileTreeVo fileTreeVo = new FileTreeVo();
+        fileTreeVo.setId(0);
+        fileTreeVo.setAuthUserId(authUserId);
+        fileTreeVo.setPackageType(0);
+        PackageTree(fileTreeVo);
+        return ResponseJson.success(fileTreeVo);
+    }
+
+    @Override
+    public ResponseJson downLoadChoseZip(String fileId, Integer authUserId, HttpServletResponse response) {
+        if (fileId.contains(",")) {
+            String[] split = fileId.split(",");
+            ArrayList<FileTreeVo> fileTreeVos = new ArrayList<>();
+            for (String s : split) {
+                FileTreeVo file = fileMapper.findFile(Integer.valueOf(s), authUserId, null);
+                fileTreeVos.add(file);
+            }
+            //有package则在服务器固定路径new file.mkdir
+            UUID uuid = UUID.randomUUID();
+            String zipPath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
+            String filePath = zipPath;
+            if ("dev".equals(active)) {
+                zipPath = "D:\\caimei-workSpace\\file\\" + uuid;
+                filePath = zipPath;
+            }
+            boolean mkdirs = new File(filePath).mkdirs();
+            Assert.isTrue(mkdirs, "文件夹创建失败");
+
+            for (FileTreeVo fileTreeVo : fileTreeVos) {
+                if (1 == fileTreeVo.getPackageType()) {
+                    //普通文件直接下载到临时文件夹uuid下
+                    String fileName = "";
+                    if ("dev".equals(active)) {
+                        fileName = zipPath + "\\" + fileTreeVo.getFileName();
+                    } else {
+                        fileName = zipPath + "/" + fileTreeVo.getFileName();
+                    }
+                    OSSUtils.downFileByFilePath("authFile/", fileTreeVo.getOssName(), fileName);
+                } else {
+                    //文件夹在uuid文件夹下创建自己包名的文件夹
+                    String param = fileTreeVo.getId() + "," + authUserId;
+                    String myPath = "";
+                    myPath = filePath + "/" + fileTreeVo.getFileName();
+                    if ("dev".equals(active)) {
+                        myPath = filePath + "\\" + fileTreeVo.getFileName();
+                    }
+                    boolean dirs = new File(myPath).mkdirs();
+                    Assert.isTrue(dirs, "文件夹创建失败");
+                    recursion(param, myPath);
+                }
+            }
+
+            //压缩
+            FileZipUtils.compress(zipPath, "", true);
+            String s = zipPath + ".zip";
+            String fileName = uuid + ".zip";
+            File file = new File(s);
+            try {
+                if (file.exists()) {
+                    FileInputStream fileInputStream = new FileInputStream(file);
+                    ServletOutputStream outputStream = response.getOutputStream();
+                    // 设置下载文件的mineType,告诉浏览器下载文件类型
+//                                int i = fileName.lastIndexOf(".");
+//                                String substring = fileName.substring(i + 1, filePath.length());
+                    response.setContentType("application/zip");
+                    // 设置一个响应头,无论是否被浏览器解析,都下载
+                    response.setHeader("Content-disposition", "attachment; filename=" + fileName);
+                    byte[] bytes = new byte[1024];
+                    int len;
+                    while ((len = fileInputStream.read(bytes)) != -1) {
+                        outputStream.write(bytes, 0, len);
+                    }
+                    fileInputStream.close();
+                    outputStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            file.delete();
+            FileZipUtils.deleteFile(new File(zipPath));
+        }
+        return null;
+    }
+
+    @Override
+    public ResponseJson<FileTreeVo> getFileDetail(Integer fileId, Integer authUserId) {
+        FileTreeVo file = fileMapper.findFile(fileId, authUserId, null);
+        return ResponseJson.success(file);
+    }
+
+    private void PackageTree(FileTreeVo fileTreeVo) {
+        if (null == fileTreeVo) {
+            return;
+        }
+        List<FileTreeVo> fileList = fileMapper.findFileTree(fileTreeVo.getId(), fileTreeVo.getAuthUserId(), fileTreeVo.getPackageType());
+        if (null != fileList && fileList.size() > 0) {
+            fileTreeVo.setChildList(fileList);
+        }
+        fileList.forEach(this::PackageTree);
+    }
+
+
+    private FileTreeVo getCrumbsParent(FileTreeVo file, Integer authUserId) {
+        if (null == file || 0 == file.getParentId()) {
+            return file;
+        }
+        FileTreeVo fil = fileMapper.findFile(file.getParentId(), authUserId, null);
+        fil.setChildNode(file);
+        return getCrumbsParent(fil, authUserId);
+    }
+
+    private void recursion(String param, String filePath) {
+        String[] split = param.split(",");
+        Integer fileId = Integer.valueOf(split[0]);
+        Integer authUserId = Integer.valueOf(split[1]);
+        //1.如果当前目录存在普通文件,下载当前目录下的文件到文件夹中
+        String finalFilePath = filePath;
+        List<FileTreeVo> commonFile = existsPackageOrCommonFile(fileId, authUserId, 2);
+        if (null != commonFile && commonFile.size() > 0) {
+            commonFile.forEach(c -> {
+                String fileName = "";
+                if ("dev".equals(active)) {
+                    fileName = finalFilePath + "\\" + c.getFileName();
+                } else {
+                    fileName = finalFilePath + "/" + c.getFileName();
+                }
+                OSSUtils.downFileByFilePath("authFile/", c.getOssName(), fileName);
+            });
+        }
+        //2.如果存在文件夹循环文件夹,递归本方法
+        List<FileTreeVo> packages = existsPackageOrCommonFile(fileId, authUserId, 1);
+        HashMap<String, String> sonPackage = new HashMap<String, String>();
+        if (null != packages && packages.size() > 0) {
+            for (FileTreeVo aPackage : packages) {
+                if ("dev".equals(active)) {
+                    filePath = finalFilePath + "\\" + aPackage.getFileName();
+                } else {
+                    filePath = finalFilePath + "/" + aPackage.getFileName();
+                }
+                File fil = new File(filePath.toString());
+                fil.mkdirs();
+                String params = aPackage.getId() + "," + authUserId;
+                sonPackage.put(params, filePath);
+            }
+        }
+        sonPackage.forEach(this::recursion);
+    }
+
+    /**
+     * selectFor 1文件夹package,2普通文件
+     *
+     * @param fileId
+     * @param selectFor
+     * @return
+     */
+    private List<FileTreeVo> existsPackageOrCommonFile(Integer fileId, Integer authUserId, Integer selectFor) {
+        return fileMapper.findSonPackage(fileId, authUserId, selectFor);
+    }
+}

+ 174 - 0
src/main/java/com/caimei/utils/FileZipUtils.java

@@ -0,0 +1,174 @@
+package com.caimei.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+@Slf4j
+public class FileZipUtils {
+
+    /**
+     * 压缩文件
+     *
+     * @param f                原文件
+     * @param baseDir          打包根目录
+     * @param zos              压缩文件
+     * @param deleteSourceFile 是否需要删除原文件,例如:true=删除原文件、false=不删除原文件
+     */
+    public static void compress(File f, String baseDir, ZipOutputStream zos, boolean deleteSourceFile) {
+        if (!f.exists()) {
+            log.info("待压缩的文件目录或文件" + f.getName() + "不存在");
+            return;
+        }
+        File[] fs = f.listFiles();
+        BufferedInputStream bis = null;
+        //ZipOutputStream zos = null;
+        byte[] bufs = new byte[1024 * 10];
+        FileInputStream fis = null;
+        try {
+            //zos = new ZipOutputStream(new FileOutputStream(zipFile));
+            for (int i = 0; i < fs.length; i++) {
+                String fName = fs[i].getName();
+                log.info("压缩:" + baseDir + fName);
+                if (fs[i].isFile()) {
+                    ZipEntry zipEntry = new ZipEntry(baseDir + fName);//
+                    zos.putNextEntry(zipEntry);
+                    //读取待压缩的文件并写进压缩包里
+                    fis = new FileInputStream(fs[i]);
+                    bis = new BufferedInputStream(fis, 1024 * 10);
+                    int read = 0;
+                    while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) {
+                        zos.write(bufs, 0, read);
+                    }
+                    //如果需要删除源文件,则需要执行下面2句
+                    if (deleteSourceFile) {
+                        fis.close();
+                        fs[i].delete();
+                    }
+
+                } else if (fs[i].isDirectory()) {
+                    compress(fs[i], baseDir + fName + "/", zos, false);
+                }
+            }//end for
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            //关闭流
+            try {
+                if (null != bis) {
+                    bis.close();
+                }
+//                if (null != zos) {
+//                    zos.close();
+//                }
+                if (null != fis) {
+                    fis.close();
+                }
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+
+    }
+
+    /**
+     * 打包指定路径的文件夹
+     *
+     * @param sourceFilePath   源文件加地址,例如:C:\\test 必填
+     * @param baseDir          打包的根目录名,例如:download/ 非必填
+     * @param deleteSourceFile 是否需要删除原文件,例如:true=删除原文件、false=不删除原文件 必填
+     */
+    public static void compress(String sourceFilePath, String baseDir, boolean deleteSourceFile) {
+        File sourceDir = new File(sourceFilePath);
+        File zipFile = new File(sourceFilePath + ".zip");
+        ZipOutputStream zos = null;
+        try {
+            zos = new ZipOutputStream(new FileOutputStream(zipFile));
+            compress(sourceDir, baseDir, zos, deleteSourceFile);
+        } catch (FileNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            if (zos != null) {
+                try {
+                    zos.flush();
+                    zos.closeEntry();
+                    zos.close();
+                } catch (IOException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 递归查询当前目录下所有文件
+     *
+     * @return
+     */
+    public static File[] getFileName(String path) {
+        File f = new File(path);//获取路径
+        long time = f.lastModified();
+        Date date = new Date(time);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd E HH:mm");
+        String newtime = sdf.format(date);
+        log.info("最后一次修改时间-----》" + newtime);
+        log.info("文件长度----------------->" + f.length());
+        if (!f.exists()) {
+            log.info(path + " not exists");//不存在就输出
+            return null;
+        }
+        File fa[] = f.listFiles();//用数组接收  F:笔记总结C#, F:笔记总结if语句.txt
+        for (int i = 0; i < fa.length; i++) {//循环遍历
+            File fs = fa[i];//获取数组中的第i个
+            if (fs.isDirectory()) {
+                log.info(fs.getName() + " [目录]");//如果是目录就输出
+            } else {
+                log.info(fs.getName());//否则直接输出
+            }
+        }
+        return fa;
+    }
+
+    /**
+     * 文件夹删除
+     *
+     * @param file
+     * @return
+     */
+    public static Boolean deleteFile(File file) {
+        log.info("删除文件---------------》" + file.toString());
+        //判断文件不为null或文件目录存在
+        if (file == null || !file.exists()) {
+            log.info("文件删除失败,请检查文件是否存在以及文件路径是否正确");
+            return false;
+        }
+        //获取目录下子文件
+        File[] files = file.listFiles();
+        //遍历该目录下的文件对象
+        for (File f : files) {
+            //判断子目录是否存在子目录,如果是文件则删除
+            if (f.isDirectory()) {
+                //递归删除目录下的文件
+                deleteFile(f);
+            } else {
+                //文件删除
+                f.delete();
+                //打印文件名
+                log.info("文件名:" + f.getName());
+            }
+        }
+        //文件夹删除
+        boolean delete = file.delete();
+        System.out.println("目录名:" + file.getName());
+        return delete;
+    }
+
+}

+ 49 - 2
src/main/java/com/caimei/utils/OSSUtils.java

@@ -4,6 +4,12 @@ import com.aliyun.oss.HttpMethod;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.OSSClientBuilder;
 import com.aliyun.oss.model.*;
 import com.aliyun.oss.model.*;
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.auth.sts.AssumeRoleRequest;
+import com.aliyuncs.auth.sts.AssumeRoleResponse;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.profile.DefaultProfile;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -13,6 +19,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URL;
 import java.util.Date;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.UUID;
 import java.util.UUID;
 
 
 @Component
 @Component
@@ -52,6 +59,36 @@ public class OSSUtils {
         active = actives;
         active = actives;
     }
     }
 
 
+    public static HashMap<String, String> getToken() {
+        //构建一个阿里云客户端,用于发起请求。
+        //设置调用者(RAM用户或RAM角色)的AccessKey ID和AccessKey Secret。
+        DefaultProfile profile = DefaultProfile.getProfile("oss-cn-shenzhen", accessKeyId, accessKeySecret);
+        IAcsClient client = new DefaultAcsClient(profile);
+
+        //构造请求,设置参数。
+        AssumeRoleRequest request = new AssumeRoleRequest();
+        request.setRegionId(endpoint);
+        request.setRoleArn("acs:ram::1565565840178476:role/caimeitst");
+        request.setRoleSessionName("TSTtest");
+        AssumeRoleResponse response = null;
+        try {
+            response = client.getAcsResponse(request);
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        String requestId = response.getRequestId();
+        String securityToken = response.getCredentials().getSecurityToken();
+        String accessKeySecret = response.getCredentials().getAccessKeySecret();
+        String accessKeyId = response.getCredentials().getAccessKeyId();
+        HashMap<String, String> tokenMap = new HashMap<>(5);
+        tokenMap.put("requestId", requestId);
+        tokenMap.put("accessKeyId", accessKeyId);
+        tokenMap.put("accessKeySecret", accessKeySecret);
+        tokenMap.put("securityToken", securityToken);
+        tokenMap.put("bucket", privateBucket);
+        return tokenMap;
+    }
+
     public static String ossUpload(String fileName, File file, String contentType, String contentDisposition) {
     public static String ossUpload(String fileName, File file, String contentType, String contentDisposition) {
         String url = null;
         String url = null;
         try {
         try {
@@ -126,13 +163,13 @@ public class OSSUtils {
         if (".vsd".equalsIgnoreCase(fileExtension)) {
         if (".vsd".equalsIgnoreCase(fileExtension)) {
             return "application/vnd.visio";
             return "application/vnd.visio";
         }
         }
-        if (".ppt".equalsIgnoreCase(fileExtension)  ) {
+        if (".ppt".equalsIgnoreCase(fileExtension)) {
             return "application/vnd.ms-powerpoint";
             return "application/vnd.ms-powerpoint";
         }
         }
         if (".pptx".equalsIgnoreCase(fileExtension)) {
         if (".pptx".equalsIgnoreCase(fileExtension)) {
             return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
             return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
         }
         }
-        if (".doc".equalsIgnoreCase(fileExtension) ) {
+        if (".doc".equalsIgnoreCase(fileExtension)) {
             return "application/msword";
             return "application/msword";
         }
         }
         if (".docx".equalsIgnoreCase(fileExtension)) {
         if (".docx".equalsIgnoreCase(fileExtension)) {
@@ -220,4 +257,14 @@ public class OSSUtils {
         // 关闭OSSClient。
         // 关闭OSSClient。
         ossClient.shutdown();
         ossClient.shutdown();
     }
     }
+
+    public static void downFileByFilePath(String path, String ossName, String fileName) {
+        // 创建OSSClient实例。
+        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
+        // 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
+        String filePath = active + "/" + path + ossName;
+        ossClient.getObject(new GetObjectRequest(privateBucket, filePath), new File(fileName));
+        // 关闭OSSClient。
+        ossClient.shutdown();
+    }
 }
 }

+ 39 - 13
src/main/resources/mapper/ArticleMapper.xml

@@ -1,18 +1,37 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.cmMapper.ArticleMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.ArticleMapper">
-    <insert id="insertArticle">
-        insert into cm_brand_article(authUserId, title, image, content, auditStatus, status, createTime, auditBy, auditTime, checkFlag, sort)
-        values (#{authUserId}, #{title}, #{image}, #{content}, #{auditStatus}, #{status}, #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag}, #{sort})
+    <insert id="insertArticle" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
+        insert into cm_brand_article(authUserId, title, image, content, auditStatus, status, createTime, auditBy,
+                                     auditTime, articleType, articleLink)
+        values (#{authUserId}, #{title}, #{image}, #{content}, #{auditStatus}, #{status}, #{createTime}, #{auditBy},
+                #{auditTime}, #{articleType}, #{articleLink})
     </insert>
     </insert>
     <update id="updateArticleByArticleId">
     <update id="updateArticleByArticleId">
         update cm_brand_article
         update cm_brand_article
-        set title       = #{title},
-            image       = #{image},
-            content     = #{content},
-            status      = #{status},
-            auditStatus = #{auditStatus},
-            sort        = #{sort}
+        <set>
+            <if test="null != title and ''!=title">
+                title = #{title},
+            </if>
+            <if test="null != image and ''!=image">
+                image = #{image},
+            </if>
+            <if test="null != content and ''!=content">
+                content = #{content},
+            </if>
+            <if test="null != status">
+                status = #{status},
+            </if>
+            <if test="null != auditStatus">
+                auditStatus = #{auditStatus},
+            </if>
+            <if test="null != articleType">
+                articleType = #{articleType},
+            </if>
+            <if test="null != articleLink and ''!=articleLink">
+                articleLink = #{articleLink},
+            </if>
+        </set>
         where id = #{id}
         where id = #{id}
     </update>
     </update>
     <update id="updateArticleStatusByArticleId">
     <update id="updateArticleStatusByArticleId">
@@ -45,7 +64,7 @@
     <select id="getArticleList" resultType="com.caimei.model.vo.ArticleListVo">
     <select id="getArticleList" resultType="com.caimei.model.vo.ArticleListVo">
         select a.id as articleId,a.title as articleTitle,a.image as articleImage,
         select a.id as articleId,a.title as articleTitle,a.image as articleImage,
         a.auditStatus,a.invalidReason,a.status,a.createTime,
         a.auditStatus,a.invalidReason,a.status,a.createTime,
-        au.name as auditBy,a.auditTime,a.sort, a.checkFlag
+        au.name as auditBy,a.auditTime
         from cm_brand_article a
         from cm_brand_article a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId}
         where a.authUserId = #{authUserId}
@@ -63,12 +82,19 @@
                 order by a.auditStatus desc, a.createTime desc
                 order by a.auditStatus desc, a.createTime desc
             </when>
             </when>
             <otherwise>
             <otherwise>
-                order by -a.sort desc, a.createTime desc
+                order by a.createTime desc
             </otherwise>
             </otherwise>
         </choose>
         </choose>
     </select>
     </select>
     <select id="getArticleForm" resultType="com.caimei.model.vo.ArticleFormVo">
     <select id="getArticleForm" resultType="com.caimei.model.vo.ArticleFormVo">
-        select id as articleId, title as articleTitle, image as articleImage, content as articleContent, createTime, auditStatus, sort
+        select id      as articleId,
+               title   as articleTitle,
+               image   as articleImage,
+               content as articleContent,
+               createTime,
+               auditStatus,
+               articleType,
+               articleLink
         from cm_brand_article
         from cm_brand_article
         where id = #{articleId}
         where id = #{articleId}
     </select>
     </select>
@@ -81,6 +107,6 @@
         <if test="articleTitle != null and articleTitle != ''">
         <if test="articleTitle != null and articleTitle != ''">
             and title like concat('%',#{articleTitle},'%')
             and title like concat('%',#{articleTitle},'%')
         </if>
         </if>
-        order by -a.sort desc, a.createTime desc
+        order by a.createTime desc
     </select>
     </select>
 </mapper>
 </mapper>

+ 4 - 4
src/main/resources/mapper/AuthProductMapper.xml

@@ -26,15 +26,15 @@
         insert into cm_brand_product_type_param (productTypeId, name, content)
         insert into cm_brand_product_type_param (productTypeId, name, content)
         values (#{productTypeId}, #{paramName}, #{paramContent})
         values (#{productTypeId}, #{paramName}, #{paramContent})
     </insert>
     </insert>
-    <insert id="insertProductRelation" useGeneratedKeys="true" keyColumn="id">
-        insert into cm_brand_product_relation (authId, productId, authType)
-        values (#{authId}, #{productId}, #{authType})
-    </insert>
     <insert id="addScanCount">
     <insert id="addScanCount">
         update cm_brand_auth_product
         update cm_brand_auth_product
         set scanCount = scanCount + 1
         set scanCount = scanCount + 1
         where id = #{productId}
         where id = #{productId}
     </insert>
     </insert>
+    <insert id="insertProductRelation" useGeneratedKeys="true" parameterType="com.caimei.model.vo.ProductRelationVo" keyProperty="relationId" keyColumn="id">
+        insert into cm_brand_product_relation (authId, productId, authType)
+        values (#{authId}, #{productId}, #{authType})
+    </insert>
 
 
     <update id="updateProductStatusByProductId">
     <update id="updateProductStatusByProductId">
         update cm_brand_auth_product
         update cm_brand_auth_product

+ 175 - 10
src/main/resources/mapper/FileMapper.xml

@@ -1,16 +1,33 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.cmMapper.FileMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.FileMapper">
-    <insert id="insertFile" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.FilePo" useGeneratedKeys="true">
+    <insert id="insertFile" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.FilePo"
+            useGeneratedKeys="true">
         insert into cm_brand_file(authUserId, fileType, title, name, previewUrl, downloadUrl, auditStatus, status,
         insert into cm_brand_file(authUserId, fileType, title, name, previewUrl, downloadUrl, auditStatus, status,
-                                  createTime, auditBy, auditTime, checkFlag)
+                                  createTime, auditBy, auditTime)
         values (#{authUserId}, #{fileType}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
         values (#{authUserId}, #{fileType}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
-                #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag})
+                #{createTime}, #{auditBy}, #{auditTime})
     </insert>
     </insert>
     <insert id="insertCourseFile">
     <insert id="insertCourseFile">
         insert into cm_brand_course_file (title, name, ossName, type, module, createTime)
         insert into cm_brand_course_file (title, name, ossName, type, module, createTime)
         values (#{title}, #{name}, #{ossName}, #{fileType}, #{fileModule}, NOW());
         values (#{title}, #{name}, #{ossName}, #{fileType}, #{fileModule}, NOW());
     </insert>
     </insert>
+    <insert id="creatPackage">
+        insert into cm_tree_file(parentId, fileType, fileName, saveTime, packageType, authUserId)
+        values (#{fileId}, 'package', #{packageName}, now(), 0, #{authUserId})
+    </insert>
+    <insert id="insertNewFile" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.vo.FileTreeVo"
+            useGeneratedKeys="true">
+        insert into cm_tree_file(parentId, fileType, saveTime, ossUrl, fileName, ossName, fileSize, packageType,
+                                 authUserId, mime, articleId, screenshot)
+        values (#{parentId}, #{fileType}, now(), #{ossUrl}, #{fileName}, #{ossName}, #{fileSize}, #{packageType},
+                #{authUserId}, #{mime}, #{articleId}, #{screenshot})
+    </insert>
+    <insert id="insertImgUrl">
+        update cm_tree_file
+        set screenshot = #{screenshot}
+        where id = #{id}
+    </insert>
     <update id="updateFileByFileId">
     <update id="updateFileByFileId">
         update cm_brand_file
         update cm_brand_file
         set title       = #{title},
         set title       = #{title},
@@ -53,9 +70,6 @@
             <if test="auditStatus != null">
             <if test="auditStatus != null">
                 auditStatus = #{auditStatus},
                 auditStatus = #{auditStatus},
             </if>
             </if>
-            <if test="checkFlag != null">
-                checkFlag = #{checkFlag},
-            </if>
         </set>
         </set>
         where id = #{id}
         where id = #{id}
     </update>
     </update>
@@ -73,16 +87,73 @@
         set checkFlag = 1
         set checkFlag = 1
         where id = #{fileId}
         where id = #{fileId}
     </update>
     </update>
+    <update id="updateFile">
+        update cm_tree_file
+        <set>
+            <if test="null != parentId">
+                parentId=#{parentId},
+            </if>
+            <if test="null != fileType and fileType != ''">
+                fileType= #{fileType},
+            </if>
+            <if test="null != ossName and ossName != ''">
+                ossName=#{ossName},
+            </if>
+            <if test="null != fileName and fileName != ''">
+                fileName=#{fileName},
+            </if>
+            <if test="null != ossUrl and ossUrl != ''">
+                ossUrl=#{ossUrl},
+            </if>
+            <if test="null != saveTime">
+                saveTime=#{saveTime},
+            </if>
+            <if test="null != fileSize and fileSize != ''">
+                fileSize=#{fileSize},
+            </if>
+            <if test="null != packageType and packageType != ''">
+                packageType=#{packageType},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+    <update id="updateFileByArticleId">
+        update cm_tree_file
+        <set>
+            <if test="null != ossName and ossName != ''">
+                ossName=#{ossName},
+            </if>
+            <if test="null != fileName and fileName != ''">
+                fileName=#{fileName},
+            </if>
+            <if test="null != ossUrl and ossUrl != ''">
+                ossUrl=#{ossUrl},
+            </if>
+            <if test="null != screenshot and screenshot != ''">
+                screenshot=#{screenshot}
+            </if>
+        </set>
+        where articleId = #{articleId}
+    </update>
     <delete id="deleteFileByFileId">
     <delete id="deleteFileByFileId">
-        delete from cm_brand_file where id = #{fileId}
+        delete
+        from cm_brand_file
+        where id = #{fileId}
     </delete>
     </delete>
     <delete id="deleteCourseFileByFileId">
     <delete id="deleteCourseFileByFileId">
-        delete from cm_brand_course_file where id = #{fileId}
+        delete
+        from cm_brand_course_file
+        where id = #{fileId}
+    </delete>
+    <delete id="deleteFileTreeById">
+        delete
+        from cm_tree_file
+        where id = #{fileId}
     </delete>
     </delete>
     <select id="getFileList" resultType="com.caimei.model.vo.FileListVo">
     <select id="getFileList" resultType="com.caimei.model.vo.FileListVo">
         select a.id as fileId,a.title as fileTitle,a.name as fileName,a.previewUrl as filePreviewUrl,
         select a.id as fileId,a.title as fileTitle,a.name as fileName,a.previewUrl as filePreviewUrl,
         a.downloadUrl as fileDownloadUrl, a.auditStatus,a.invalidReason,a.status,a.createTime,
         a.downloadUrl as fileDownloadUrl, a.auditStatus,a.invalidReason,a.status,a.createTime,
-        au.name as auditBy,a.auditTime,a.checkFlag
+        au.name as auditBy,a.auditTime
         from cm_brand_file a
         from cm_brand_file a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId} and fileType = #{fileType}
         where a.authUserId = #{authUserId} and fileType = #{fileType}
@@ -157,6 +228,100 @@
           and find_in_set(a.id, #{authIds})
           and find_in_set(a.id, #{authIds})
     </select>
     </select>
     <select id="getFileForm" resultType="com.caimei.model.po.FilePo">
     <select id="getFileForm" resultType="com.caimei.model.po.FilePo">
-        select id,auditStatus from cm_brand_file where id = #{fileId}
+        select id, auditStatus
+        from cm_brand_file
+        where id = #{fileId}
+    </select>
+    <select id="findFileTree" resultType="com.caimei.model.vo.FileTreeVo">
+        select ctf.id,
+        ctf.parentId,
+        ctf.fileType,
+        ctf.fileName,
+        ctf.ossUrl,
+        ctf.ossName,
+        ctf.fileSize,
+        ctf.saveTime,
+        ctf.packageType,
+        ctf.authUserId,
+        ctf.mime,
+        ctf.articleId,
+        ctf.screenshot,
+        cba.articleType
+        from cm_tree_file ctf
+        LEFT JOIN cm_brand_article cba ON cba.id = ctf.articleId
+        where ctf.parentId = #{fileId}
+        <if test="null != authUserId">
+            and ctf.authUserId = #{authUserId}
+        </if>
+        <if test="null != packageType">
+            and ctf.packageType =#{packageType}
+        </if>
+        order by ctf.packageType ASC,ctf.saveTime DESC
+    </select>
+    <select id="findFileChild" resultType="com.caimei.model.vo.FileTreeVo">
+        select id, parentId, fileType, fileName, ossUrl, saveTime
+        from cm_tree_file
+        where parentId = #{fileId}
+    </select>
+    <select id="findSonFiles" resultType="com.caimei.model.vo.FileTreeVo">
+        select id, parentId, fileType, fileName, ossUrl, saveTime
+        from cm_tree_file
+        where parentId = #{fileId}
+    </select>
+    <select id="findSonPackage" resultType="com.caimei.model.vo.FileTreeVo">
+        select id,parentId,fileType,fileName,ossName from cm_tree_file
+        where parentId =#{fileId}
+        and authUserId = #{authUserId}
+        <if test="selectFor == 1">
+            and fileType = 'package'
+        </if>
+        <if test="selectFor == 2">
+            and fileType != 'package'
+        </if>
+    </select>
+    <select id="findFile" resultType="com.caimei.model.vo.FileTreeVo">
+        select id,
+        parentId,
+        fileType,
+        fileName,
+        ossUrl,
+        ossName,
+        fileSize,
+        saveTime,
+        packageType,
+        authUserId,
+        mime,
+        articleId,
+        screenshot
+        from cm_tree_file
+        where id = #{fileId}
+        <if test="null != authUserId">
+            and authUserId = #{authUserId}
+        </if>
+        <if test="null != packageType">
+            and packageType =#{packageType}
+        </if>
+    </select>
+    <select id="findShopPrefix" resultType="java.lang.String">
+        select prefix
+        from cm_brand_auth_user
+        where authUserId = #{authUserId}
+    </select>
+    <select id="findFileByArticleId" resultType="com.caimei.model.vo.FileTreeVo">
+        select id,
+               parentId,
+               fileType,
+               fileName,
+               ossUrl,
+               ossName,
+               fileSize,
+               saveTime,
+               packageType,
+               authUserId,
+               mime,
+               articleId,
+               screenshot
+        from cm_tree_file
+        where articleId = #{id}
     </select>
     </select>
 </mapper>
 </mapper>

+ 4 - 5
src/main/resources/mapper/ImageMapper.xml

@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.cmMapper.ImageMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.ImageMapper">
     <insert id="insertImage" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.ImagePo" useGeneratedKeys="true">
     <insert id="insertImage" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.ImagePo" useGeneratedKeys="true">
-        insert into cm_brand_image(authUserId, title, zipUrl, auditStatus, status, createTime, auditBy, auditTime, checkFlag)
-        values (#{authUserId}, #{title}, #{zipUrl}, #{auditStatus}, #{status}, #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag})
+        insert into cm_brand_image(authUserId, title, zipUrl, auditStatus, status, createTime, auditBy, auditTime)
+        values (#{authUserId}, #{title}, #{zipUrl}, #{auditStatus}, #{status}, #{createTime}, #{auditBy}, #{auditTime})
     </insert>
     </insert>
     <insert id="insertImageDetail">
     <insert id="insertImageDetail">
         insert into cm_brand_image_detail(imageId, image)
         insert into cm_brand_image_detail(imageId, image)
@@ -14,8 +14,7 @@
         set title       = #{title},
         set title       = #{title},
             zipUrl      = #{zipUrl},
             zipUrl      = #{zipUrl},
             status      = #{status},
             status      = #{status},
-            auditStatus = #{auditStatus},
-            checkFlag   = #{checkFlag}
+            auditStatus = #{auditStatus}
         where id = #{id}
         where id = #{id}
     </update>
     </update>
     <update id="updateImageStatusByImageId">
     <update id="updateImageStatusByImageId">
@@ -46,7 +45,7 @@
     <select id="getImageList" resultType="com.caimei.model.vo.ImageListVo">
     <select id="getImageList" resultType="com.caimei.model.vo.ImageListVo">
         select a.id as imageId,a.title as imageTitle,
         select a.id as imageId,a.title as imageTitle,
         a.auditStatus,a.invalidReason,a.status,a.createTime,
         a.auditStatus,a.invalidReason,a.status,a.createTime,
-        au.name as auditBy,a.auditTime,a.checkFlag
+        au.name as auditBy,a.auditTime
         from cm_brand_image a
         from cm_brand_image a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId}
         where a.authUserId = #{authUserId}

+ 3 - 6
src/main/resources/mapper/VideoMapper.xml

@@ -3,9 +3,9 @@
 <mapper namespace="com.caimei.mapper.cmMapper.VideoMapper">
 <mapper namespace="com.caimei.mapper.cmMapper.VideoMapper">
     <insert id="insertVideo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.VideoPo" useGeneratedKeys="true">
     <insert id="insertVideo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.VideoPo" useGeneratedKeys="true">
         insert into cm_brand_video(authUserId, title, image, name, previewUrl, downloadUrl, auditStatus, status, createTime,
         insert into cm_brand_video(authUserId, title, image, name, previewUrl, downloadUrl, auditStatus, status, createTime,
-                                   auditBy, auditTime, checkFlag)
+                                   auditBy, auditTime)
         values (#{authUserId}, #{title}, #{image}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
         values (#{authUserId}, #{title}, #{image}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
-                #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag})
+                #{createTime}, #{auditBy}, #{auditTime})
     </insert>
     </insert>
     <update id="updateVideoByVideoId">
     <update id="updateVideoByVideoId">
         update cm_brand_video
         update cm_brand_video
@@ -52,9 +52,6 @@
             <if test="auditStatus != null">
             <if test="auditStatus != null">
                 auditStatus = #{auditStatus},
                 auditStatus = #{auditStatus},
             </if>
             </if>
-            <if test="checkFlag != null">
-                checkFlag = #{checkFlag},
-            </if>
         </set>
         </set>
         where id = #{id}
         where id = #{id}
     </update>
     </update>
@@ -67,7 +64,7 @@
     <select id="getVideoList" resultType="com.caimei.model.vo.VideoListVo">
     <select id="getVideoList" resultType="com.caimei.model.vo.VideoListVo">
         select a.id as videoId,a.title as videoTitle,a.image as videoImage, a.name as videoName, a.previewUrl as videoPreviewUrl, a.downloadUrl
         select a.id as videoId,a.title as videoTitle,a.image as videoImage, a.name as videoName, a.previewUrl as videoPreviewUrl, a.downloadUrl
         as videoDownloadUrl,a.auditStatus,a.invalidReason,a.status,a.createTime,
         as videoDownloadUrl,a.auditStatus,a.invalidReason,a.status,a.createTime,
-        au.name as auditBy,a.auditTime,a.checkFlag
+        au.name as auditBy,a.auditTime
         from cm_brand_video a
         from cm_brand_video a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId}
         where a.authUserId = #{authUserId}