Pārlūkot izejas kodu

增加对接应用签名校验

xuchao 1 mēnesi atpakaļ
vecāks
revīzija
01d02d1d18

+ 4 - 2
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/core/sign/interceptor/SignAuthInterceptor.java

@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
 @Slf4j
 public class SignAuthInterceptor implements HandlerInterceptor {
 
-    private static final String NONCE_KEY_STR = "nonce-";
+    private static final String NONCE_KEY_STR = "nonce:";
 
     private static final String OpenInterfaceKey = "open-interface-";
 
@@ -129,7 +129,9 @@ public class SignAuthInterceptor implements HandlerInterceptor {
             openInterface = mapper.readValue(openInterfaceStr,BizOpenInterface.class);
         }else{
             openInterface = bizOpenInterfaceService.getOne(new QueryWrapper<BizOpenInterface>().eq("app_key",appKey));
-            commonCacheOperator.put(OpenInterfaceKey + appKey,JSON.toJSONString(openInterface));
+            if (ObjectUtil.isNotEmpty(openInterface)) {
+                commonCacheOperator.put(OpenInterfaceKey + appKey, JSON.toJSONString(openInterface));
+            }
         }
         if (openInterface == null || !openInterface.getStatus().equals("ENABLE")) {
             log.info("appKey无法查询到合作项目信息或已被封禁...........");

+ 2 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/openinterface/service/impl/BizOpenInterfaceServiceImpl.java

@@ -46,7 +46,7 @@ import java.util.List;
 @Service
 public class BizOpenInterfaceServiceImpl extends ServiceImpl<BizOpenInterfaceMapper, BizOpenInterface> implements BizOpenInterfaceService {
 
-    private static final String OpenInterfaceKey = "open-interface-";
+    private static final String OpenInterfaceKey = "open-interface-*";
     @Resource
     private CommonCacheOperator commonCacheOperator;
 
@@ -89,6 +89,7 @@ public class BizOpenInterfaceServiceImpl extends ServiceImpl<BizOpenInterfaceMap
     public void delete(List<BizOpenInterfaceIdParam> bizOpenInterfaceIdParamList) {
         // 执行删除
         this.removeByIds(CollStreamUtil.toList(bizOpenInterfaceIdParamList, BizOpenInterfaceIdParam::getId));
+        commonCacheOperator.removeBatch(OpenInterfaceKey);
     }
 
     @Override