Browse Source

更改E证通token逻辑,环境拆分

frankeleyn 2 years ago
parent
commit
4cce0d87ee

+ 8 - 4
src/main/java/com/ematou/wxbase/service/impl/EidServiceImpl.java

@@ -20,6 +20,7 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
 import com.tencentcloudapi.faceid.v20180301.FaceidClient;
+import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenConfig;
 import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenRequest;
 import com.tencentcloudapi.faceid.v20180301.models.GetEidTokenResponse;
 import lombok.extern.slf4j.Slf4j;
@@ -96,14 +97,14 @@ public class EidServiceImpl implements EidService {
         if (StrUtil.isNotBlank(cacheEidToken)) {
             // 如果不为空,缓存存在
             // 将 token 组装到响应数据中
-            responseVO.setEidToken(cacheEidToken);
+            throw new ServiceException("请勿重复请求!");
         }else {
             // 如果为空,缓存不存在
             // 请求E证通 token
-            //String eidToken = reqEidToken(eidMerch, requestDTO.getUserName(), requestDTO.getIdCard());
-            String eidToken = "1a2b3c4d5e6f";
+            String eidToken = reqEidToken(eidMerch, requestDTO.getUserName(), requestDTO.getIdCard());
+            //String eidToken = "1a2b3c4d5e6f";
             // 将E证通 token 设置进 Redis,并设置过期时间
-            redisTemplate.opsForValue().set(cacheKey, eidToken, Duration.ofSeconds(eidMerch.getTokenExpired()));
+            redisTemplate.opsForValue().set(cacheKey, eidToken, Duration.ofSeconds(1L));
             // 插入操作记录
             insertOptRecord(requestDTO);
             // 插入E证通操作记录
@@ -191,6 +192,9 @@ public class EidServiceImpl implements EidService {
             req.setName(userName);
             // 设置核验人身份证
             req.setIdCard(idCard);
+            GetEidTokenConfig config = new GetEidTokenConfig();
+            config.setInputType("4");
+            req.setConfig(config);
             // 返回的resp是一个GetEidTokenResponse的实例,与请求对象对应
             GetEidTokenResponse resp = client.GetEidToken(req);
             // 输出json格式的字符串回包

+ 17 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,17 @@
+server:
+  port: 4040
+
+spring:
+  # 数据源配置
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: wx_base
+    password: goZ7ooGmxV
+    url: jdbc:mysql://out-rm-wz92efl25x02n44xego.mysql.rds.aliyuncs.com:3306/wx_base?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+  # redis 配置
+  redis:
+    database: 1
+    host: 120.78.152.8
+    port: 6379
+    password: Abc-123#*.-
+

+ 17 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,17 @@
+server:
+  port: 3030
+
+spring:
+  # 数据源配置
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    username: tuser
+    password: Qq!123
+    url: jdbc:mysql://47.112.115.196:3306/wx_base?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+  # redis 配置
+  redis:
+    database: 1
+    host: 120.78.152.8
+    port: 6379
+    password: Abc-123#*.-
+

+ 3 - 14
src/main/resources/application.yml

@@ -1,6 +1,3 @@
-server:
-  port: 3030
-
 wx:
   general:
     appId: wxf9360d70bc1406ee
@@ -9,17 +6,9 @@ wx:
     url: https://api.weixin.qq.com/cgi-bin/token?grant_type=%s&appid=%s&secret=%s
 
 spring:
-  datasource:
-    driver-class-name: com.mysql.cj.jdbc.Driver
-    username: wx_base
-    password: goZ7ooGmxV
-    url: jdbc:mysql://out-rm-wz92efl25x02n44xego.mysql.rds.aliyuncs.com:3306/wx_base?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
-  # redis 配置
-  redis:
-    database: 1
-    host: 120.78.152.8
-    port: 6379
-    password: Abc-123#*.-
+  # 环境切换
+  profiles:
+    active: prod
 
 mybatis:
   mapper-locations: classpath:mybatis/*.xml