From ad508635f22704722d517c60c434ea7bf947aeda Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期四, 21 十月 2021 18:59:56 +0800
Subject: [PATCH] 修改引入

---
 src/main/java/com/platform/verification/VerificationTool.java |   36 ++++++++++++++++++++++++++++++++++++
 src/main/java/com/platform/resultTool/PlatformCode.java       |    2 ++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/platform/resultTool/PlatformCode.java b/src/main/java/com/platform/resultTool/PlatformCode.java
index 3d03c3b..e2a4c02 100644
--- a/src/main/java/com/platform/resultTool/PlatformCode.java
+++ b/src/main/java/com/platform/resultTool/PlatformCode.java
@@ -19,6 +19,8 @@
     public static final String ERROR_PARAMETER_NULL = "203";
     /*鍙傛暟绫诲瀷閿欒*/
     public static final String ERROR_PARAMETER_TYPE = "204";
+    /*璁块棶鏃犳晥*/
+    public static final String ERROR_INVALID_VISIT = "205";
 
     /*body鏍煎紡閿欒*/
     public static final String ERROR_BODY_DATA = "500";
diff --git a/src/main/java/com/platform/verification/VerificationTool.java b/src/main/java/com/platform/verification/VerificationTool.java
index 705f492..5056c69 100644
--- a/src/main/java/com/platform/verification/VerificationTool.java
+++ b/src/main/java/com/platform/verification/VerificationTool.java
@@ -1,10 +1,14 @@
 package com.platform.verification;
 
 
+import com.hx.util.DateUtil;
 import com.hx.util.StringUtils;
 import com.hx.util.rsa.RSAUtil;
 import com.platform.resultTool.PlatformCode;
 import com.platform.resultTool.PlatformResult;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**骞冲彴鏍¢獙鏂规硶
  * @author CJH
@@ -53,7 +57,39 @@
         if (!appId.equals(decrypts[0])) {
             return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
         }
+
+        Date date  = null;
+        try{
+
+            //鍒ゆ柇鎺ュ彛鏃堕棿
+            SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String sd = sdf.format(new Date(Long.parseLong(String.valueOf(decrypts[1]))));      // 鏃堕棿鎴宠浆鎹㈡垚鏃堕棿
+            date = DateUtil.parseString(sd,"yyyy-MM-dd HH:mm:ss");
+        }catch (Exception e){
+            return PlatformResult.failure(PlatformCode.ERROR_SIGN, "绛惧悕閿欒");
+        }
+
+        //鎺ュ彛鏈夋晥2绉掗挓
+        if(System.currentTimeMillis()-date.getTime() > 2000){
+            return PlatformResult.failure(PlatformCode.ERROR_INVALID_VISIT, "璁块棶鏃犳晥");
+        }
+
         return PlatformResult.success();
     }
 
+    public static void main(String[] args) {
+
+        Long timeStamp = System.currentTimeMillis();  //鑾峰彇褰撳墠鏃堕棿鎴�
+        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String sd = sdf.format(new Date(Long.parseLong(String.valueOf(timeStamp))));
+
+        Date date = DateUtil.parseString(sd,"yyyy-MM-dd HH:mm:ss");
+
+        System.out.println();
+
+        // 鏃堕棿鎴宠浆鎹㈡垚鏃堕棿
+        System.out.println("鏍煎紡鍖栫粨鏋滐細" + sd);
+
+    }
+
 }

--
Gitblit v1.8.0