liubo 3 anni fa
parent
commit
966077b215

+ 0 - 29
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BaseErrorCode.java

@@ -1,29 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:40
- * @Version 1.0
- **/
-public interface BaseErrorCode {
-    /**
-     * 获取错误码
-     *
-     * @return
-     */
-    int getErrorCode();
-
-    /**
-     * 获取错误信息
-     *
-     * @return
-     */
-    String getErrorMsg();
-
-    /**
-     * 设置错误信息
-     *
-     * @param errorMsg
-     */
-    void setErrorMsg(String errorMsg);
-}

+ 0 - 42
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessErrorCode.java

@@ -1,42 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:49
- * @Version 1.0
- **/
-public enum BusinessErrorCode implements BaseErrorCode {
-
-    USER_NOT_LOGIN(10001, "用户未登入"),
-    INVALID_PARAMETER(10002, "参数错误");
-
-    /**
-     * 错误消息
-     */
-    private String errorMsg;
-    /**
-     * 错误码
-     */
-    private Integer errorCode;
-
-    BusinessErrorCode(Integer errorCode, String errorMsg) {
-        this.errorMsg = errorMsg;
-        this.errorCode = errorCode;
-    }
-
-    @Override
-    public int getErrorCode() {
-        return this.errorCode;
-    }
-
-    @Override
-    public String getErrorMsg() {
-        return this.errorMsg;
-    }
-
-    @Override
-    public void setErrorMsg(String errorMsg) {
-        this.errorMsg = errorMsg;
-    }
-
-}

+ 0 - 34
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/response/error/BusinessException.java

@@ -1,34 +0,0 @@
-package com.zd.base.files.bigupload.response.error;
-
-/**
- * @Author donggaosheng
- * @Date 2021/1/16 14:45
- * @Version 1.0
- **/
-public class BusinessException extends Exception {
-
-    private BaseErrorCode errorCode;
-
-    public BusinessException(BaseErrorCode errorCode) {
-        super(errorCode.getErrorMsg());
-        this.errorCode = errorCode;
-    }
-
-    public BusinessException(BaseErrorCode errorCode, String customizedErrorMsg) {
-        super(customizedErrorMsg);
-        this.errorCode = errorCode;
-        errorCode.setErrorMsg(customizedErrorMsg);
-    }
-
-    public static void main(String[] args) throws BusinessException {
-        throw new BusinessException(BusinessErrorCode.USER_NOT_LOGIN);
-    }
-
-    public BaseErrorCode getErrorCode() {
-        return errorCode;
-    }
-
-    public void setErrorCode(BaseErrorCode errorCode) {
-        this.errorCode = errorCode;
-    }
-}

+ 3 - 5
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/IUploadService.java

@@ -3,7 +3,6 @@ package com.zd.base.files.bigupload.service;
 
 import com.zd.base.files.bigupload.dto.FileChunkDTO;
 import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
-import com.zd.base.files.bigupload.response.error.BusinessException;
 
 import java.io.IOException;
 
@@ -21,7 +20,7 @@ public interface IUploadService {
      * @param chunkDTO
      * @return
      */
-    FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException;
+    FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) ;
 
 
     /**
@@ -29,7 +28,7 @@ public interface IUploadService {
      *
      * @param chunkDTO
      */
-    void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException, IOException;
+    void uploadChunk(FileChunkDTO chunkDTO) throws IOException;
 
 
     /**
@@ -39,8 +38,7 @@ public interface IUploadService {
      * @param fileName
      * @param totalChunks
      * @return
-     * @throws BusinessException
      * @throws IOException
      */
-    String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException;
+    String mergeChunk(String identifier, String fileName, Integer totalChunks) throws IOException;
 }

+ 5 - 6
zd-modules/zd-base/src/main/java/com/zd/base/files/bigupload/service/impl/UploadServiceImpl.java

@@ -3,8 +3,6 @@ package com.zd.base.files.bigupload.service.impl;
 
 import com.zd.base.files.bigupload.dto.FileChunkDTO;
 import com.zd.base.files.bigupload.dto.FileChunkResultDTO;
-import com.zd.base.files.bigupload.response.error.BusinessErrorCode;
-import com.zd.base.files.bigupload.response.error.BusinessException;
 import com.zd.base.files.bigupload.service.IUploadService;
 import com.zd.base.files.bigupload.utils.FileUtils;
 import com.zd.base.files.file.config.ResourcesConfig;
@@ -18,6 +16,7 @@ import org.springframework.util.StringUtils;
 import javax.annotation.Resource;
 import java.io.*;
 import java.net.UnknownHostException;
+import java.rmi.ServerException;
 import java.util.*;
 
 
@@ -45,7 +44,7 @@ public class UploadServiceImpl implements IUploadService {
      * @return
      */
     @Override
-    public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) throws BusinessException {
+    public FileChunkResultDTO checkChunkExist(FileChunkDTO chunkDTO) {
         //1.检查文件是否已上传过
         //1.1)检查在磁盘中是否存在
         String fileFolderPath = getFileFolderPath(chunkDTO.getIdentifier());
@@ -74,7 +73,7 @@ public class UploadServiceImpl implements IUploadService {
      * @param chunkDTO
      */
     @Override
-    public void uploadChunk(FileChunkDTO chunkDTO) throws BusinessException {
+    public void uploadChunk(FileChunkDTO chunkDTO) throws ServerException {
         //分块的目录
         String chunkFileFolderPath = getChunkFileFolderPath(chunkDTO.getIdentifier());
         logger.info("分块的目录 -> {}", chunkFileFolderPath);
@@ -93,13 +92,13 @@ public class UploadServiceImpl implements IUploadService {
             //将该分片写入redis
             long size = saveToRedis(chunkDTO);
         } catch (Exception e) {
-            throw new BusinessException(BusinessErrorCode.INVALID_PARAMETER, e.getMessage());
+            throw new ServerException("参数错误" + e.getMessage());
         }
     }
 
 
     @Override
-    public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws BusinessException, IOException {
+    public String mergeChunk(String identifier, String fileName, Integer totalChunks) throws IOException {
         String suffix = fileName.substring(fileName.lastIndexOf("."));
         if(null==suffix){
             throw new RuntimeException("文件格式有误");

+ 0 - 23
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/SpringUtil.java

@@ -1,23 +0,0 @@
-package com.zd.base.files.ueditor;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SpringUtil implements ApplicationContextAware {
-
-    private static ApplicationContext applicationContext;
-
-    @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        if (SpringUtil.applicationContext == null) {
-            SpringUtil.applicationContext = applicationContext;
-        }
-    }
-
-    public static ApplicationContext getApplicationContext() {
-        return applicationContext;
-    }
-}

+ 0 - 8
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionMap.java

@@ -5,14 +5,6 @@ import java.util.Map;
 
 public final class ActionMap {
     public static final Map<String, Integer> mapping;
-    public static final int CONFIG = 0;
-    public static final int UPLOAD_IMAGE = 1;
-    public static final int UPLOAD_SCRAWL = 2;
-    public static final int UPLOAD_VIDEO = 3;
-    public static final int UPLOAD_FILE = 4;
-    public static final int CATCH_IMAGE = 5;
-    public static final int LIST_FILE = 6;
-    public static final int LIST_IMAGE = 7;
 
     static {
         mapping = new HashMap<String, Integer>() {

+ 0 - 8
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/ActionState.java

@@ -1,8 +0,0 @@
-package com.zd.base.files.ueditor.define;
-
-public enum ActionState {
-    UNKNOW_ERROR("UNKNOW_ERROR", 0);
-
-    private ActionState(String s,int n) {
-    }
-}

+ 0 - 17
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/AppInfo.java

@@ -4,23 +4,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 public final class AppInfo {
-    public static final int SUCCESS = 0;
-    public static final int MAX_SIZE = 1;
-    public static final int PERMISSION_DENIED = 2;
-    public static final int FAILED_CREATE_FILE = 3;
-    public static final int IO_ERROR = 4;
-    public static final int NOT_MULTIPART_CONTENT = 5;
-    public static final int PARSE_REQUEST_ERROR = 6;
-    public static final int NOTFOUND_UPLOAD_DATA = 7;
-    public static final int NOT_ALLOW_FILE_TYPE = 8;
-    public static final int INVALID_ACTION = 101;
-    public static final int CONFIG_ERROR = 102;
-    public static final int PREVENT_HOST = 201;
-    public static final int CONNECTION_ERROR = 202;
-    public static final int REMOTE_FAIL = 203;
-    public static final int NOT_DIRECTORY = 301;
-    public static final int NOT_EXIST = 302;
-    public static final int ILLEGAL = 401;
     public static Map<Integer, String> info;
 
     static {

+ 0 - 1
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/define/FileType.java

@@ -4,7 +4,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 public class FileType {
-    public static final String JPG = "JPG";
     private static final Map<String, String> types;
 
     static {