Pārlūkot izejas kodu

判断SSO中是否存在该用户

丁治程 3 nedēļas atpakaļ
vecāks
revīzija
e4eeef04bf

+ 10 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/controller/IotedgeCollectDataController.java

@@ -250,6 +250,16 @@ public class IotedgeCollectDataController extends JeecgController<IotedgeCollect
     	return iotedgeCollectDataService.getAllGroup();
 	 }
 
+	 @AutoLog(value = "IoTEdge-SSO-判断用户是否存在")
+	 @ApiOperation(value="IoTEdge-SSO-判断用户是否存在", notes="IoTEdge-SSO-判断用户是否存在")
+	 @PostMapping(value = "/ifUserInSoo")
+	 public JSONObject ifUserNameInSSO(@RequestParam(name = "userName") String userName){
+		 return restClientService.ifUserInSSO(userName);
+	 }
+
+
+
+
 	 @AutoLog(value = "IoTEdge-测试client")
 	 @ApiOperation(value="IoTEdge-测试client", notes="IoTEdge-测试client")
 	 @PostMapping(value = "/getClient")

+ 23 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/RestClientService.java

@@ -443,6 +443,7 @@ public class RestClientService {
         jsonObject.put("clientSecret",clientSecret);
         jsonObject.put("action","append");
         jsonObject.put("scopes",scopList);
+        //jsonObject.put("password","Asdfg@123");
         HttpHeaders headers = new HttpHeaders();
         MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
         headers.setContentType(type);
@@ -522,6 +523,28 @@ public class RestClientService {
         return response.getBody();
     }
 
+
+
+    /**
+     *   author: dzc
+     *   version: 1.0
+     *   des: 调用 SSO 的接口判断当前用户是否已经存在
+     *   date: 2024/8/29
+     */
+    public JSONObject ifUserInSSO(String userName){
+        String url = configService.getConfigValue(ConfigInfo.SSO_IFUSERINSSO)+"/"+userName;
+        HttpHeaders headers = new HttpHeaders();
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+        //headers.setContentType(type);
+        //headers.add("Authorization", "Bearer " + token);
+        HttpEntity<String> httpEntity = new HttpEntity<String>(null, headers);
+        restTemplate.setErrorHandler(new MyResponseErrorHandler());
+        ResponseEntity<JSONObject> response = restTemplate.exchange(url, HttpMethod.GET,httpEntity, JSONObject.class);
+        return response.getBody();
+    }
+
+
+
     /**
     *   author: dzc
     *   version: 1.0

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeConfig/util/ConfigInfo.java

@@ -90,4 +90,7 @@ public class ConfigInfo {
 
     /** SSO-获取SSO用户角色 */
     public static String SSO_GETSSORLOE = "SSO.GetSSORole";
+
+    /** SSO-判断用户是否存在 */
+    public static String SSO_IFUSERINSSO = "SSO.IfUserInSSO";
 }