From 009b344979b439e553f0e5ddd3eb1783a2abb6b0 Mon Sep 17 00:00:00 2001 From: wzp <2040239371@qq.com> Date: 星期四, 17 七月 2025 14:23:41 +0800 Subject: [PATCH] fix: 修复订单年龄为空导致民航接口报错 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientAppServiceImpl.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientAppServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientAppServiceImpl.java index f7e1844..f36ecea 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientAppServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysClientAppServiceImpl.java @@ -8,6 +8,8 @@ import com.ruoyi.system.service.ISysClientAppService; import com.ruoyi.common.utils.SecurityUtils; +import static com.ruoyi.common.utils.SecurityUtils.md5; + /** * 瀹㈡埛搴旂敤閰嶇疆 鏈嶅姟灞傚疄鐜� */ @@ -25,6 +27,18 @@ @Override public SysClientApp selectSysClientAppByAppId(Long appId) { return sysClientAppMapper.selectSysClientAppByAppId(appId); + } + + /** + * 閫氳繃搴旂敤鏍囪瘑鏌ヨ瀹㈡埛搴旂敤閰嶇疆 + * + * @param appKey 搴旂敤鏍囪瘑 + * @return 瀹㈡埛搴旂敤閰嶇疆 + */ + @Override + public SysClientApp selectSysClientAppByAppKey(String appKey) + { + return sysClientAppMapper.selectSysClientAppByAppKey(appKey); } /** @@ -118,4 +132,42 @@ public int deleteSysClientAppByAppId(Long appId) { return sysClientAppMapper.deleteSysClientAppByAppId(appId); } + + @Override + public boolean validateSign(String appId, String sign, String timestamp) { + // 鏍规嵁appId鑾峰彇搴旂敤淇℃伅 + SysClientApp clientApp = sysClientAppMapper.selectSysClientAppByAppKey(appId); + if (clientApp == null) { + return false; + } + + // 楠岃瘉搴旂敤鏄惁鏈夋晥 + if (!"0".equals(clientApp.getStatus())) { + return false; + } + + // 楠岃瘉鏈夋晥鏈� + if (clientApp.getValidStartTime() != null && clientApp.getValidEndTime() != null) { + long currentTime = System.currentTimeMillis(); + if (currentTime < clientApp.getValidStartTime().getTime() + || currentTime > clientApp.getValidEndTime().getTime()) { + return false; + } + } + + // 鐢熸垚绛惧悕 + String serverSign = generateSign(appId, clientApp.getSecurityKey(), timestamp); + + // 姣旇緝绛惧悕 + return sign.equals(serverSign); + } + + /** + * 鐢熸垚绛惧悕 + * 绛惧悕瑙勫垯锛歁D5(appId + timestamp + securityKey) + */ + private String generateSign(String appId, String securityKey, String timestamp) { + String signStr = appId + timestamp + securityKey; + return md5(signStr); + } } \ No newline at end of file -- Gitblit v1.9.1