zhijiezhao 2 jaren geleden
bovenliggende
commit
e482f0848a

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

@@ -72,4 +72,8 @@ public class FileTreeVo implements Serializable {
      * 缩略图url
      */
     private String screenshot;
+    /**
+     * 文章类型1自主2第三方
+     */
+    private Integer articleType;
 }

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

@@ -32,8 +32,8 @@ public class AsyncService {
     @Value("${spring.profiles.active}")
     private String active;
 
-    @Value("${caimei.zplmapi}")
-    private String zplmapi;
+    @Value("${caimei.zpapi}")
+    private String zpapi;
 
     @Resource
     private FileMapper fileMapper;
@@ -65,7 +65,7 @@ public class AsyncService {
             if ("dev".equals(active)) {
                 path = "http://192.168.2.92:8888" + path;
             } else {
-                path = zplmapi + path;
+                path = zpapi + path;
             }
             fileTreeVo.setOssUrl(path);
             fileMapper.insertNewFile(fileTreeVo);

+ 14 - 12
src/main/java/com/caimei/service/data/impl/DatabaseServiceImpl.java

@@ -61,9 +61,9 @@ public class DatabaseServiceImpl implements DatabaseService {
         //有package则在服务器固定路径new file.mkdir
         UUID uuid = UUID.randomUUID();
         String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid + "/";
-        filePath = filePath + packageName;
-        String zipPath = filePath;
+        String zipPath = filePath + packageName;
         String delPath = filePath;
+        filePath = zipPath;
         if ("dev".equals(active)) {
             filePath = "D:\\caimei-workSpace\\file\\" + uuid + "\\";
             zipPath = filePath + packageName;
@@ -102,7 +102,7 @@ public class DatabaseServiceImpl implements DatabaseService {
             e.printStackTrace();
         }
         FileZipUtils.deleteFile(new File(delPath));
-        return ResponseJson.success();
+        return null;
     }
 
     @Override
@@ -137,7 +137,7 @@ public class DatabaseServiceImpl implements DatabaseService {
         fileTreeVo.setAuthUserId(authUserId);
         fileTreeVo.setMime(mime);
         fileMapper.insertNewFile(fileTreeVo);
-        if(mime.contains("image")){
+        if (mime.contains("image")) {
             //图片保存缩略图
             asyncService.insertScreenshot(fileTreeVo);
         }
@@ -192,8 +192,7 @@ public class DatabaseServiceImpl implements DatabaseService {
             //文件夹
             List<FileTreeVo> fileTree = fileMapper.findFileTree(fileId, null, null);
             fileTree.forEach(f -> {
-                OSSUtils.deleteSingleFile(f.getOssName());
-                fileMapper.deleteFileTreeById(f.getId());
+                deleteFilesById(f.getId());
             });
             fileMapper.deleteFileTreeById(fileId);
         } else {
@@ -235,11 +234,11 @@ public class DatabaseServiceImpl implements DatabaseService {
             }
             //有package则在服务器固定路径new file.mkdir
             UUID uuid = UUID.randomUUID();
-            String filePath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
-            String zipPath = filePath;
+            String zipPath = "/mnt/newdatadrive/data/runtime/jar-instance/zplma/tempFile/" + uuid;
+            String filePath = zipPath;
             if ("dev".equals(active)) {
-                filePath = "D:\\caimei-workSpace\\file\\" + uuid;
-                zipPath = filePath;
+                zipPath = "D:\\caimei-workSpace\\file\\" + uuid;
+                filePath = zipPath;
             }
             boolean mkdirs = new File(filePath).mkdirs();
             Assert.isTrue(mkdirs, "文件夹创建失败");
@@ -262,6 +261,8 @@ public class DatabaseServiceImpl implements DatabaseService {
                     if ("dev".equals(active)) {
                         myPath = filePath + "\\" + fileTreeVo.getFileName();
                     }
+                    boolean dirs = new File(myPath).mkdirs();
+                    Assert.isTrue(dirs, "文件夹创建失败");
                     recursion(param, myPath);
                 }
             }
@@ -292,9 +293,10 @@ public class DatabaseServiceImpl implements DatabaseService {
             } catch (IOException e) {
                 e.printStackTrace();
             }
+            file.delete();
             FileZipUtils.deleteFile(new File(zipPath));
         }
-        return ResponseJson.error("请勾选多个文件");
+        return null;
     }
 
     @Override
@@ -350,7 +352,7 @@ public class DatabaseServiceImpl implements DatabaseService {
                 if ("dev".equals(active)) {
                     filePath = finalFilePath + "\\" + aPackage.getFileName();
                 } else {
-                    filePath = finalFilePath + aPackage.getFileName() + "/";
+                    filePath = finalFilePath + "/" + aPackage.getFileName();
                 }
                 File fil = new File(filePath.toString());
                 fil.mkdirs();

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

@@ -144,6 +144,7 @@ public class FileZipUtils {
      * @return
      */
     public static Boolean deleteFile(File file) {
+        log.info("删除文件---------------》" + file.toString());
         //判断文件不为null或文件目录存在
         if (file == null || !file.exists()) {
             log.info("文件删除失败,请检查文件是否存在以及文件路径是否正确");

+ 5 - 9
src/main/resources/mapper/ArticleMapper.xml

@@ -3,9 +3,9 @@
 <mapper namespace="com.caimei.mapper.cmMapper.ArticleMapper">
     <insert id="insertArticle" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
         insert into cm_brand_article(authUserId, title, image, content, auditStatus, status, createTime, auditBy,
-                                     auditTime, checkFlag, sort, articleType, articleLink)
+                                     auditTime, articleType, articleLink)
         values (#{authUserId}, #{title}, #{image}, #{content}, #{auditStatus}, #{status}, #{createTime}, #{auditBy},
-                #{auditTime}, #{checkFlag}, #{sort}, #{articleType}, #{articleLink})
+                #{auditTime}, #{articleType}, #{articleLink})
     </insert>
     <update id="updateArticleByArticleId">
         update cm_brand_article
@@ -25,9 +25,6 @@
             <if test="null != auditStatus">
                 auditStatus = #{auditStatus},
             </if>
-            <if test="null != sort">
-                sort = #{sort},
-            </if>
             <if test="null != articleType">
                 articleType = #{articleType},
             </if>
@@ -69,7 +66,7 @@
     <select id="getArticleList" resultType="com.caimei.model.vo.ArticleListVo">
         select a.id as articleId,a.title as articleTitle,a.image as articleImage,
         a.auditStatus,a.invalidReason,a.status,a.createTime,
-        au.name as auditBy,a.auditTime,a.sort, a.checkFlag
+        au.name as auditBy,a.auditTime, a.checkFlag
         from cm_brand_article a
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId}
@@ -87,7 +84,7 @@
                 order by a.auditStatus desc, a.createTime desc
             </when>
             <otherwise>
-                order by -a.sort desc, a.createTime desc
+                order by a.createTime desc
             </otherwise>
         </choose>
     </select>
@@ -98,7 +95,6 @@
                content as articleContent,
                createTime,
                auditStatus,
-               sort,
                articleType,
                articleLink
         from cm_brand_article
@@ -113,6 +109,6 @@
         <if test="articleTitle != null and articleTitle != ''">
             and title like concat('%',#{articleTitle},'%')
         </if>
-        order by -a.sort desc, a.createTime desc
+        order by a.createTime desc
     </select>
 </mapper>

+ 23 - 24
src/main/resources/mapper/FileMapper.xml

@@ -4,9 +4,9 @@
     <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,
-                                  createTime, auditBy, auditTime, checkFlag)
+                                  createTime, auditBy, auditTime)
         values (#{authUserId}, #{fileType}, #{title}, #{name}, #{previewUrl}, #{downloadUrl}, #{auditStatus}, #{status},
-                #{createTime}, #{auditBy}, #{auditTime}, #{checkFlag})
+                #{createTime}, #{auditBy}, #{auditTime})
     </insert>
     <insert id="insertCourseFile">
         insert into cm_brand_course_file (title, name, ossName, type, module, createTime)
@@ -70,9 +70,6 @@
             <if test="auditStatus != null">
                 auditStatus = #{auditStatus},
             </if>
-            <if test="checkFlag != null">
-                checkFlag = #{checkFlag},
-            </if>
         </set>
         where id = #{id}
     </update>
@@ -138,7 +135,7 @@
     <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,
         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
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         where a.authUserId = #{authUserId} and fileType = #{fileType}
@@ -218,28 +215,30 @@
         where id = #{fileId}
     </select>
     <select id="findFileTree" 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 parentId = #{fileId}
+        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 authUserId = #{authUserId}
+            and ctf.authUserId = #{authUserId}
         </if>
         <if test="null != packageType">
-            and packageType =#{packageType}
+            and ctf.packageType =#{packageType}
         </if>
-        order by packageType ASC,saveTime DESC
+        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