【file】更新file,临时提交

pull/3/head
fengshuonan 2020-12-30 21:29:32 +08:00
parent 46e9de3ca0
commit 1e318b4faf
10 changed files with 272 additions and 53 deletions

View File

@ -39,9 +39,19 @@ public interface FileConstants {
Long DEFAULT_FILE_TIMEOUT_SECONDS = 7200L;
/**
* Guns
*
*/
String FILE_PREVIEW_URL = "/sysFileInfo/preview";
String DEFAULT_ATTACHMENT_UPLOAD_METHOD = "local_file_config";
/**
* token
*/
String FILE_PRIVATE_PREVIEW_URL = "/sysFileInfo/private/preview";
/**
* Gunstokenbanner
*/
String FILE_PUBLIC_PREVIEW_URL = "/sysFileInfo/public/preview";
/**
* object

View File

@ -0,0 +1,32 @@
package cn.stylefeng.roses.kernel.file.enums;
import lombok.Getter;
/**
*
*
* @author majianguo
* @date 2020/12/16 12:00
*/
@Getter
public enum FileStatusEnum {
/**
*
* <p>
* code
*/
NEW("1"),
/**
*
*/
OLD("0");
private final String code;
FileStatusEnum(String code) {
this.code = code;
}
}

View File

@ -14,60 +14,85 @@ import lombok.Getter;
@Getter
public enum FileExceptionEnum implements AbstractExceptionEnum {
/**
* IDS
*/
FILE_IDS_EMPTY(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "01", "附件IDS为空!"),
/**
*
*/
SECRET_FLAG_INFO_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "02", "下载的文件中包含私有文件,具体文件为:{}"),
/**
*
*/
ALIYUN_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "01", "阿里云文件操作异常,具体信息为:{}"),
ALIYUN_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "03", "阿里云文件操作异常,具体信息为:{}"),
/**
*
*/
TENCENT_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "02", "腾讯云文件操作异常,具体信息为:{}"),
TENCENT_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "04", "腾讯云文件操作异常,具体信息为:{}"),
/**
*
*/
FILE_NOT_FOUND(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "03", "本地文件不存在,具体信息为:{}"),
FILE_NOT_FOUND(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "05", "本地文件不存在,具体信息为:{}"),
/**
* MinIO
*/
MINIO_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "04", "MinIO文件操作异常具体信息为{}"),
MINIO_FILE_ERROR(RuleConstants.THIRD_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "06", "MinIO文件操作异常具体信息为{}"),
/**
*
*/
ERROR_FILE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "05", "上传文件操作异常,具体信息为:{}"),
ERROR_FILE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "07", "上传文件操作异常,具体信息为:{}"),
/**
*
*
*/
NOT_EXISTED(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "06", "该文件信息不存在文件id为{}"),
NOT_EXISTED(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "08", "该条文件信息记录不存在文件id为{}"),
/**
*
*/
FILE_STREAM_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "07", "获取文件流错误"),
FILE_STREAM_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "09", "获取文件流错误"),
/**
*
*/
DOWNLOAD_FILE_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "08", "下载文件错误,具体信息为:{}"),
DOWNLOAD_FILE_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "10", "下载文件错误,具体信息为:{}"),
/**
*
*/
PREVIEW_ERROR_NOT_SUPPORT(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "09", "预览文件异常,您预览的文件类型不支持或文件出现错误"),
PREVIEW_ERROR_NOT_SUPPORT(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "11", "预览文件异常,您预览的文件类型不支持或文件出现错误"),
/**
*
*/
PREVIEW_EMPTY_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "10", "预览文件参数存在空值,请求参数为:{}"),
PREVIEW_EMPTY_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "12", "预览文件参数存在空值,请求参数为:{}"),
/**
*
*/
WRITE_BYTES_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "10", "渲染文件流字节出错,具体信息为:{}");
WRITE_BYTES_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "13", "渲染文件流字节出错,具体信息为:{}"),
/**
* id
*/
FILE_ID_NOT_NULL(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "14", "文件ID不能为空!"),
/**
* Code
*/
FILE_CODE_NOT_NULL(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "15", "文件CODE不能为空!"),
/**
* 访
*/
FILE_DENIED_ACCESS(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + FileConstants.FILE_EXCEPTION_STEP_CODE + "16", "文件不允许被访问!");
/**
*

View File

@ -4,31 +4,56 @@ import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* <p>
*
* </p>
*
* 1fileCode,code
* 2fileIdfileId
*
* @author stylefeng
* @date 2020/6/7 22:15
* @author majianguo
* @date 2020/12/27 12:35
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysFileInfoRequest extends BaseRequest {
/**
* id
* ID
*/
@NotNull(message = "fileId不能为空", groups = {delete.class, detail.class})
@NotNull(message = "fileId不能为空", groups = {versionBack.class, detail.class})
private Long fileId;
/**
*
*
* <p>
*
* <p>
* codeid
*/
@NotNull(message = "fileCode不能为空请检查fileCode参数", groups = {edit.class, delete.class,})
private Long fileCode;
/**
* Y-N-
* <p>
* 访
*/
@NotBlank(message = "是否是机密文件不能为空请检查secretFlag参数", groups = {add.class, edit.class})
private String secretFlag;
/**
* .txt
*/
private String fileOriginName;
/**
*
*/
private String token;
/**
* 1-2-3-minio4-
*/
@ -39,11 +64,6 @@ public class SysFileInfoRequest extends BaseRequest {
*/
private String fileBucket;
/**
*
*/
private String fileOriginName;
/**
*
*/
@ -65,9 +85,9 @@ public class SysFileInfoRequest extends BaseRequest {
private String filePath;
/**
*
* 退
*/
public @interface preview {
public @interface versionBack {
}
}

View File

@ -0,0 +1,63 @@
package cn.stylefeng.roses.kernel.file.pojo.response;
import lombok.Data;
import java.io.Serializable;
/**
*
*
* @author fengshuonan
* @date 2020/12/30 21:24
*/
@Data
public class SysFileInfoListResponse implements Serializable {
private static final long serialVersionUID = -1L;
/**
* id
*/
private Long fileId;
/**
* Code
*/
private String fileAppCodeName;
/**
*
*/
private String fileOriginName;
/**
*
*/
private String fileSuffix;
/**
*
*/
private String fileSizeInfo;
/**
*
*/
private Integer fileVersion;
/**
*
*/
private Long createAccountId;
/**
* id
*/
private Long createDeptId;
/**
*
*/
private String createUserName;
}

View File

@ -17,10 +17,54 @@ public class SysFileInfoResponse {
private Long fileId;
/**
*
*
* <p>
*
* <p>
* codeid
*/
private Long fileCode;
/**
*
*/
private Integer fileVersion;
/**
* 0-,1-
*/
private String fileStatus;
/**
* .txt
*/
private String fileSuffix;
/**
* kb
*/
private Long fileSizeKb;
/**
*
*/
private String fileSizeInfo;
/**
*
*/
private String secretFlag;
/**
*
*/
private byte[] fileBytes;
/**
* bucketid+.
*/
private String fileObjectName;
/**
* 1-2-3-minio4-
*/
@ -36,29 +80,9 @@ public class SysFileInfoResponse {
*/
private String fileOriginName;
/**
* .txt
*/
private String fileSuffix;
/**
* kb
*/
private Long fileSizeKb;
/**
* bucketid+.
*/
private String fileObjectName;
/**
*
*/
private String filePath;
/**
*
*/
private byte[] fileBytes;
}

View File

@ -0,0 +1,45 @@
package cn.stylefeng.roses.kernel.file.util;
import cn.hutool.core.util.StrUtil;
import java.util.ArrayList;
import java.util.List;
/**
* pdf
*
* @author majianguo
* @date 2020/12/27 13:06
*/
public class PdfFileTypeUtil {
private static final List<String> PDF_TYPES;
static {
PDF_TYPES = new ArrayList<>();
PDF_TYPES.add("pdf");
}
/**
* PDF
*
* @param fileName
* @return boolean true-false-
* @author fengshuonan
* @date 2020/11/29 14:04
*/
public static boolean getFilePdfTypeFlag(String fileName) {
if (StrUtil.isEmpty(fileName)) {
return false;
}
for (String picType : PDF_TYPES) {
if (fileName.toLowerCase().endsWith(picType)) {
return true;
}
}
return false;
}
}

View File

@ -26,7 +26,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import static cn.stylefeng.roses.kernel.file.constants.FileConstants.DEFAULT_AVATAR_FILE_OBJ_NAME;
import static cn.stylefeng.roses.kernel.file.constants.FileConstants.FILE_PREVIEW_URL;
import static cn.stylefeng.roses.kernel.file.constants.FileConstants.FILE_PRIVATE_PREVIEW_URL;
/**
*
@ -84,7 +84,7 @@ public class SysFileInfoController {
* @author fengshuonan
* @date 2020/11/29 11:29
*/
@GetResource(name = "文件预览", path = FILE_PREVIEW_URL)
@GetResource(name = "文件预览", path = FILE_PRIVATE_PREVIEW_URL)
public void preview(SysFileInfoRequest sysFileInfoRequest) {
HttpServletResponse response = HttpServletUtil.getResponse();

View File

@ -152,7 +152,7 @@ public class LocalFileOperator implements FileOperatorApi {
String token = LoginContext.me().getToken();
// 拼接url = “host” + “预览图片的url” + “?token=xxx”
return FileConfigExpander.getServerDeployHost() + FileConstants.FILE_PREVIEW_URL + "?fileBucket=" + bucketName + "&fileObjectName=" + key + "&token=" + token;
return FileConfigExpander.getServerDeployHost() + FileConstants.FILE_PRIVATE_PREVIEW_URL + "?fileBucket=" + bucketName + "&fileObjectName=" + key + "&token=" + token;
}
@Override

View File

@ -196,7 +196,7 @@ public class MinIoFileOperator implements FileOperatorApi {
String token = LoginContext.me().getToken();
// 拼接url = “host” + “预览图片的url” + “?token=xxx”
return FileConfigExpander.getServerDeployHost() + FileConstants.FILE_PREVIEW_URL + "?fileBucket=" + bucketName + "&fileObjectName=" + key + "&token=" + token;
return FileConfigExpander.getServerDeployHost() + FileConstants.FILE_PRIVATE_PREVIEW_URL + "?fileBucket=" + bucketName + "&fileObjectName=" + key + "&token=" + token;
}