Merge remote-tracking branch 'ztcloud/test' into dev
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,8 @@ import java.util.Date;
|
||||
@Accessors(chain = true)
|
||||
public class FileRespVO {
|
||||
public String getUrl() {
|
||||
// 加密附件不返回 url
|
||||
if (Boolean.TRUE.equals(this.isEncrypted)) {
|
||||
// 不可下载 或 加密附件不返回 url
|
||||
if (Boolean.FALSE.equals(this.downloadable) || Boolean.TRUE.equals(this.isEncrypted)) {
|
||||
return null;
|
||||
}
|
||||
// 如果 url 已经是临时下载地址(如预签名 URL),直接返回
|
||||
@@ -62,8 +62,8 @@ public class FileRespVO {
|
||||
private String previewUrl;
|
||||
|
||||
public String getPreviewUrl() {
|
||||
// 加密附件不返回 previewUrl
|
||||
if (Boolean.TRUE.equals(this.isEncrypted)) {
|
||||
// 不可下载不返回 previewUrl
|
||||
if (Boolean.FALSE.equals(this.downloadable) ) {
|
||||
return null;
|
||||
}
|
||||
// 仅当 url 不为空时生成
|
||||
@@ -75,7 +75,15 @@ public class FileRespVO {
|
||||
if (onlinePreview == null || onlinePreview.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String presignedUrl = this.getUrl();
|
||||
// 添加加密文件预览逻辑
|
||||
String presignedUrl = null;
|
||||
if (Boolean.TRUE.equals(this.isEncrypted)) {
|
||||
if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
|
||||
presignedUrl = url;
|
||||
}
|
||||
}else{
|
||||
presignedUrl = this.getUrl();
|
||||
}
|
||||
if (presignedUrl == null || presignedUrl.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -102,4 +110,6 @@ public class FileRespVO {
|
||||
@Schema(description = "下载次数")
|
||||
private Integer downloadCount;
|
||||
|
||||
@Schema(description = "是否可下载(true是,false否)")
|
||||
private Boolean downloadable;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,11 @@ public class FileDO extends BaseDO {
|
||||
*/
|
||||
private Integer downloadCount;
|
||||
|
||||
/**
|
||||
* 是否可下载(true是,false否)
|
||||
*/
|
||||
private Boolean downloadable;
|
||||
|
||||
/**
|
||||
* 是否加密
|
||||
* <p>
|
||||
|
||||
@@ -6,4 +6,7 @@ package com.zt.plat.module.infra.dal.redis;
|
||||
public class RedisKeyConstants {
|
||||
public static final String FILE_VERIFICATION_CODE = "infra:file:verification_code:%d:%d";
|
||||
public static final String FILE_VERIFICATION_CODE_USER_SET = "infra:file:verification_code:user:%d";
|
||||
|
||||
// 加密文件预览token
|
||||
public static final String FILE_PREVIEW_TOKEN = "infra:file:preview-token:%s";
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.zt.plat.module.infra.framework.rpc.config;
|
||||
|
||||
import com.zt.plat.module.system.api.permission.PermissionApi;
|
||||
import com.zt.plat.module.system.api.permission.RoleApi;
|
||||
import com.zt.plat.module.system.api.sms.SmsSendApi;
|
||||
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(value = "infraRpcConfiguration", proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {PermissionApi.class, RoleApi.class, AdminUserApi.class})
|
||||
@EnableFeignClients(clients = {PermissionApi.class, RoleApi.class, AdminUserApi.class, SmsSendApi.class })
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.infra.service.file;
|
||||
|
||||
import com.zt.plat.framework.common.enums.VerifyCodeSendType;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
import com.zt.plat.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
@@ -10,6 +11,8 @@ import com.zt.plat.module.infra.dal.dataobject.file.FileDO;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* 文件 Service 接口
|
||||
*
|
||||
@@ -72,6 +75,14 @@ public interface FileService {
|
||||
*/
|
||||
String generateFileVerificationCode(Long fileId, Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
* @param code 验证码
|
||||
* @param verifyCodeSendType 发送类型
|
||||
*/
|
||||
void sendVerifyCode(String code, VerifyCodeSendType verifyCodeSendType);
|
||||
|
||||
/**
|
||||
* 校验验证码并返回解密后的文件内容
|
||||
*/
|
||||
@@ -125,4 +136,25 @@ public interface FileService {
|
||||
* @param fileId
|
||||
*/
|
||||
void incDownloadCount(Long fileId);
|
||||
|
||||
/**
|
||||
* 临时生成文件预览token
|
||||
* @param fileId 文件ID
|
||||
* @param userId 用户ID
|
||||
* @return 临时token
|
||||
*/
|
||||
String generatePreviewToken(Long fileId, Long userId);
|
||||
|
||||
/**
|
||||
* 验证文件预览token
|
||||
* @param fileId 文件ID
|
||||
* @param token 用户ID
|
||||
* @return 临时token
|
||||
*/
|
||||
boolean verifyPreviewToken(Long fileId, String token);
|
||||
|
||||
/**
|
||||
* 校验预览 token 后,将文件内容解密并写入输出流(用于预览)
|
||||
*/
|
||||
void writeDecryptedToStream(Long fileId, OutputStream outputStream) throws Exception;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user