From 57de3c5e0413742e8e15ec1349472b9fe92a98c3 Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Mon, 22 Sep 2025 17:13:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(hw-portal):=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E4=B8=BB=E9=94=AE=E7=B1=BB=E5=9E=8B=E4=B8=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 HwWebDocument 及相关类中的 documentId 类型从 Long 改为 String, 并同步更新了 Controller、Service、Mapper 和 XML 映射文件。 同时优化了密钥验证逻辑,增加去空格处理。 --- .../portal/controller/HwWebDocumentController.java | 4 ++-- .../java/com/ruoyi/portal/domain/HwWebDocument.java | 6 +++--- .../ruoyi/portal/domain/SecureDocumentRequest.java | 2 +- .../ruoyi/portal/mapper/HwWebDocumentMapper.java | 6 +++--- .../ruoyi/portal/service/IHwWebDocumentService.java | 8 ++++---- .../service/impl/HwWebDocumentServiceImpl.java | 13 ++++++++----- .../resources/mapper/portal/HwWebDocumentMapper.xml | 10 +++++++--- 7 files changed, 28 insertions(+), 21 deletions(-) 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 baad8aa..b9d1316 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 @@ -67,7 +67,7 @@ public class HwWebDocumentController extends BaseController */ // @RequiresPermissions("portal:hwWebDocument:query") @GetMapping(value = "/{documentId}") - public AjaxResult getInfo(@PathVariable("documentId") Long documentId) + public AjaxResult getInfo(@PathVariable("documentId") String documentId) { return success(hwWebDocumentService.selectHwWebDocumentByDocumentId(documentId)); } @@ -100,7 +100,7 @@ public class HwWebDocumentController extends BaseController // @RequiresPermissions("portal:hwWebDocument:remove") @Log(title = "Hw资料文件", businessType = BusinessType.DELETE) @DeleteMapping("/{documentIds}") - public AjaxResult remove(@PathVariable Long[] documentIds) + public AjaxResult remove(@PathVariable String[] documentIds) { return toAjax(hwWebDocumentService.deleteHwWebDocumentByDocumentIds(documentIds)); } 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 10acaef..39dc096 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 @@ -16,7 +16,7 @@ public class HwWebDocument extends BaseEntity private static final long serialVersionUID = 1L; /** 主键 */ - private Long documentId; + private String documentId; /** 租户id */ @Excel(name = "租户id") @@ -34,12 +34,12 @@ public class HwWebDocument extends BaseEntity @Excel(name = "密钥") private String secretKey; - public void setDocumentId(Long documentId) + public void setDocumentId(String documentId) { this.documentId = documentId; } - public Long getDocumentId() + public String getDocumentId() { return documentId; } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/SecureDocumentRequest.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/SecureDocumentRequest.java index b9a3a4c..424502b 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/SecureDocumentRequest.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/domain/SecureDocumentRequest.java @@ -4,6 +4,6 @@ import lombok.Data; @Data public class SecureDocumentRequest { - private Long documentId; + private String documentId; private String providedKey; } \ No newline at end of file diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwWebDocumentMapper.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwWebDocumentMapper.java index c1ae64d..831d642 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwWebDocumentMapper.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/mapper/HwWebDocumentMapper.java @@ -17,7 +17,7 @@ public interface HwWebDocumentMapper * @param documentId Hw资料文件主键 * @return Hw资料文件 */ - public HwWebDocument selectHwWebDocumentByDocumentId(Long documentId); + public HwWebDocument selectHwWebDocumentByDocumentId(String documentId); /** * 查询Hw资料文件列表 @@ -49,7 +49,7 @@ public interface HwWebDocumentMapper * @param documentId Hw资料文件主键 * @return 结果 */ - public int deleteHwWebDocumentByDocumentId(Long documentId); + public int deleteHwWebDocumentByDocumentId(String documentId); /** * 批量删除Hw资料文件 @@ -57,5 +57,5 @@ public interface HwWebDocumentMapper * @param documentIds 需要删除的数据主键集合 * @return 结果 */ - public int deleteHwWebDocumentByDocumentIds(Long[] documentIds); + public int deleteHwWebDocumentByDocumentIds(String[] documentIds); } diff --git a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebDocumentService.java b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebDocumentService.java index aa4b44b..14e8b66 100644 --- a/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebDocumentService.java +++ b/ruoyi-modules/hw-portal/src/main/java/com/ruoyi/portal/service/IHwWebDocumentService.java @@ -17,7 +17,7 @@ public interface IHwWebDocumentService * @param documentId Hw资料文件主键 * @return Hw资料文件 */ - public HwWebDocument selectHwWebDocumentByDocumentId(Long documentId); + public HwWebDocument selectHwWebDocumentByDocumentId(String documentId); /** * 查询Hw资料文件列表 @@ -49,7 +49,7 @@ public interface IHwWebDocumentService * @param documentIds 需要删除的Hw资料文件主键集合 * @return 结果 */ - public int deleteHwWebDocumentByDocumentIds(Long[] documentIds); + public int deleteHwWebDocumentByDocumentIds(String[] documentIds); /** * 删除Hw资料文件信息 @@ -57,7 +57,7 @@ public interface IHwWebDocumentService * @param documentId Hw资料文件主键 * @return 结果 */ - public int deleteHwWebDocumentByDocumentId(Long documentId); + public int deleteHwWebDocumentByDocumentId(String documentId); /** * 验证密钥并获取文件地址 @@ -66,6 +66,6 @@ public interface IHwWebDocumentService * @return 文件地址 * @throws Exception 如果密钥不匹配 */ - String verifyAndGetDocumentAddress(Long documentId, String providedKey) throws Exception; + String verifyAndGetDocumentAddress(String documentId, String providedKey) throws Exception; } 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 4fad635..d8ec5c4 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 @@ -29,7 +29,7 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService * @return Hw资料文件 */ @Override - public HwWebDocument selectHwWebDocumentByDocumentId(Long documentId) + public HwWebDocument selectHwWebDocumentByDocumentId(String documentId) { return hwWebDocumentMapper.selectHwWebDocumentByDocumentId(documentId); } @@ -78,7 +78,7 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService * @return 结果 */ @Override - public int deleteHwWebDocumentByDocumentIds(Long[] documentIds) + public int deleteHwWebDocumentByDocumentIds(String[] documentIds) { return hwWebDocumentMapper.deleteHwWebDocumentByDocumentIds(documentIds); } @@ -90,19 +90,22 @@ public class HwWebDocumentServiceImpl implements IHwWebDocumentService * @return 结果 */ @Override - public int deleteHwWebDocumentByDocumentId(Long documentId) + public int deleteHwWebDocumentByDocumentId(String documentId) { return hwWebDocumentMapper.deleteHwWebDocumentByDocumentId(documentId); } @Override - public String verifyAndGetDocumentAddress(Long documentId, String providedKey) throws Exception { + public String verifyAndGetDocumentAddress(String documentId, String providedKey) throws Exception { HwWebDocument document = selectHwWebDocumentByDocumentId(documentId); if (document == null) { throw new ServiceException("文件不存在"); } String secretKey = document.getSecretKey(); - if (secretKey == null || secretKey.equals(providedKey)) { + if (providedKey != null) { + providedKey = providedKey.trim(); + } + if (secretKey.isEmpty()|| secretKey.equals(providedKey)) { return document.getDocumentAddress(); } else { throw new ServiceException("密钥错误"); diff --git a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebDocumentMapper.xml b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebDocumentMapper.xml index d7a104f..8bd2fb8 100644 --- a/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebDocumentMapper.xml +++ b/ruoyi-modules/hw-portal/src/main/resources/mapper/portal/HwWebDocumentMapper.xml @@ -19,7 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - where document_id = #{documentId} @@ -35,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into hw_web_document + document_id, tenant_id, document_address, create_time, @@ -42,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" secretKey, + #{documentId}, #{tenantId}, #{documentAddress}, #{createTime}, @@ -53,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update hw_web_document + document_id = #{documentId}, tenant_id = #{tenantId}, document_address = #{documentAddress}, create_time = #{createTime}, @@ -62,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where document_id = #{documentId} - + delete from hw_web_document where document_id = #{documentId}