浏览代码

后管-成渝单点登录接口开发-获取公钥调整

LHB 3 周之前
父节点
当前提交
484cb8f8f8

+ 11 - 8
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@@ -614,20 +614,26 @@ public class UserController {
      */
     @GetMapping("/getPk")
     public ResultCYKey getPublicKey(String appKey){
+        if(StringUtil.isBlank(appKey)){
+            return ResultCYKey.fail("授权码为空");
+        }
+
+        String sql = "select count(0) from blade_param where param_key = 'appKey' and param_value = '" + appKey + "' and is_deleted = 0";
         //后管配置appKey
-        String localAppKey = jdbcTemplate.queryForObject("select * from blade_param where param_key = 'appKey' and is_deleted = 0 order by create_time DESC limit 1", String.class);
-        if(StringUtil.isBlank(localAppKey)){
-            return ResultCYKey.fail("第三方系统为配置appKey");
+        Integer localAppKey = jdbcTemplate.queryForObject(sql, Integer.class);
+        if(localAppKey == 0){
+            return ResultCYKey.fail("授权码未知");
         }
         //判断appKey是否为指定值
-        if(StringUtil.isNotBlank(localAppKey) && StringUtil.equals(localAppKey, appKey)){
+        try {
             String uuid = UUID.randomUUID().toString().trim().replaceAll("-", "");
             //生成rsa公钥私钥
             Map<String, String> keyPair = RsaUtils.createKeyPair();
             bladeRedis.setEx("cy_public_key:"+uuid, keyPair, 300L);
             return ResultCYKey.success(uuid,keyPair.get("pk"));
+        } catch (Exception e) {
+            return ResultCYKey.fail("生成公钥失败");
         }
-        return ResultCYKey.fail("appKey未知");
     }
     /**
      * 成渝 获取质检 token
@@ -641,9 +647,6 @@ public class UserController {
         if(StringUtil.isBlank(cyGetToken.getUuid())){
             return ResultCYData.fail("随机字符不能为空");
         }
-        if(StringUtil.isBlank(cyGetToken.getIdcard())){
-            return ResultCYData.fail("身份证号码(密文)不能为空");
-        }
         if(StringUtil.isBlank(cyGetToken.getMobile())){
             return ResultCYData.fail("手机号码(密文)不能为空");
         }