diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebDocumentController.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebDocumentController.java index b9d1316..a37c995 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebDocumentController.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/controller/HwWebDocumentController.java @@ -46,6 +46,11 @@ public class HwWebDocumentController extends BaseController { startPage(); List list = hwWebDocumentService.selectHwWebDocumentList(hwWebDocument); + for (HwWebDocument doc : list) { + if (doc.getHasSecret()) { + doc.setDocumentAddress(null); + } + } return getDataTable(list); } @@ -69,7 +74,11 @@ public class HwWebDocumentController extends BaseController @GetMapping(value = "/{documentId}") public AjaxResult getInfo(@PathVariable("documentId") String documentId) { - return success(hwWebDocumentService.selectHwWebDocumentByDocumentId(documentId)); + HwWebDocument doc = hwWebDocumentService.selectHwWebDocumentByDocumentId(documentId); + if (doc != null && doc.getHasSecret()) { + doc.setDocumentAddress(null); + } + return success(doc); } /** diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebDocument.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebDocument.java index b78cf04..fae5c1b 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebDocument.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/HwWebDocument.java @@ -4,6 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonIgnore; /** * Hw资料文件对象 hw_web_document @@ -32,6 +33,7 @@ public class HwWebDocument extends BaseEntity /** 密钥 */ @Excel(name = "密钥") + @JsonIgnore private String secretKey; /** json */ @@ -89,6 +91,10 @@ public class HwWebDocument extends BaseEntity return secretKey; } + public boolean getHasSecret() { + return secretKey != null && !secretKey.trim().isEmpty(); + } + public String getJson() { return json; } @@ -121,7 +127,7 @@ public class HwWebDocument extends BaseEntity .append("documentAddress", getDocumentAddress()) .append("createTime", getCreateTime()) .append("webCode", getWebCode()) - .append("secretKey", getSecretKey()) + .append("hasSecret", getHasSecret()) .append("json", getJson()) .append("type", getType()) .append("isDelete", getIsDelete()) diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebDocumentServiceImpl.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebDocumentServiceImpl.java index d8ec5c4..3c004e3 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebDocumentServiceImpl.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/impl/HwWebDocumentServiceImpl.java @@ -102,11 +102,16 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService throw new ServiceException("文件不存在"); } String secretKey = document.getSecretKey(); - if (providedKey != null) { - providedKey = providedKey.trim(); + String address = document.getDocumentAddress(); + if (secretKey == null || secretKey.trim().isEmpty()) { + return address; } - if (secretKey.isEmpty()|| secretKey.equals(providedKey)) { - return document.getDocumentAddress(); + String trimmedProvided = providedKey == null ? null : providedKey.trim(); + if (trimmedProvided == null || trimmedProvided.isEmpty()) { + throw new ServiceException("密钥错误"); + } + if (secretKey.trim().equals(trimmedProvided)) { + return address; } else { throw new ServiceException("密钥错误"); }