Browse Source

1.测试版APP单点登录接口

lr 2 years ago
parent
commit
3dea2d1929

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDto.java

@@ -43,7 +43,7 @@ public class RoleDto extends BaseDTO implements Serializable {
 
     private Set<DmSystemDto> systems;
 
-    private Set<DmAppMenuDto> appMenus;
+    private Set<DmAppMenu> appMenus;
 
     private Set<DeptDto> depts;
 

+ 36 - 0
eladmin-system/src/main/java/me/zhengjie/modules/thirdparty/v1/UserApiController.java

@@ -215,6 +215,42 @@ public class UserApiController {
         throw new BadRequestException("认证失败");
     }
 
+    @Log("单点登录")
+    @ApiOperation("单点登录")
+    @AnonymousGetMapping(value = "/sso22")
+    public BaseResponse<Object> sso22(String token) throws Exception {
+        if (StringUtils.isBlank(token)) {
+            throw new BadRequestException("参数错误");
+        }
+        String res = HttpRequest.get("https://imtest1.caih.com/api-third-party/busi/comm/authLogin/api/verifyToken?token=" + token).method(Method.POST).execute().body();
+        System.out.println("res:"+res);
+        JSONObject json = JSONObject.parseObject(res);
+        if (json != null) {
+            JSONObject data = json.getJSONObject("data");
+            if (data != null) {
+                UserDto userDto = userService.findByName(data.getString("username"));
+                if (userDto != null) {
+                    Map<String,Object> newToken = SecurityUtils.getToken(key);
+                    //组装返回值
+                    JSONObject returnData = new JSONObject();
+                    returnData.put("nonce",newToken.get("nonce"));
+                    returnData.put("timestamp",newToken.get("timestamp"));
+                    returnData.put("token",newToken.get("token"));
+                    returnData.put("userId",userDto.getId());
+                    String cipher = EncryptUtils.desEncrypt(returnData.toJSONString());
+                    returnData.put("cipher", cipher);
+                    returnData.put("user", userDto);
+                    Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
+                        put("data", returnData);
+                    }};
+                    System.out.println("returnData:"+returnData.toJSONString());
+                    return new BaseResponse<>(authInfo);
+                }
+            }
+        }
+        throw new BadRequestException("认证失败");
+    }
+
     @Log("app登录")
     @ApiOperation("app登录")
     @AnonymousGetMapping(value = "/appLogin")