Browse Source

乐教通

zouxuan 1 year ago
parent
commit
8d984672ce

+ 4 - 3
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/client/SysUserFeignService.java

@@ -13,6 +13,7 @@ import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 @FeignClient(contextId = "sysUserFeignService", name = "auth-server", configuration = { FeignConfiguration.class }, fallback = SysUserFeignServiceFallback.class)
 public interface SysUserFeignService {
@@ -60,7 +61,7 @@ public interface SysUserFeignService {
 	CbsQrCodeScanWrapper.QrCodeScanToken login(@RequestBody CbsQrCodeScanWrapper.QrCodeScanReq req);
 
 	@PostMapping(value = "smsLogin")
-	HttpResponseResult<JSONObject> smsLogin(@RequestParam("phone")String phone,
-											@RequestParam("clientId")String clientId,
-											@RequestParam("clientSecret")String clientSecret);
+	HttpResponseResult<Map<String,Object>> smsLogin(@RequestParam("phone")String phone,
+													@RequestParam("clientId")String clientId,
+													@RequestParam("clientSecret")String clientSecret);
 }

+ 4 - 3
mec-auth/mec-auth-api/src/main/java/com/ym/mec/auth/api/client/fallback/SysUserFeignServiceFallback.java

@@ -9,6 +9,7 @@ import org.json.JSONObject;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
+import java.util.Map;
 
 //@Component
 public class SysUserFeignServiceFallback implements SysUserFeignService {
@@ -73,9 +74,9 @@ public class SysUserFeignServiceFallback implements SysUserFeignService {
 	}
 
 	@Override
-	public HttpResponseResult<JSONObject> smsLogin(@RequestParam("phone")String phone,
-												   @RequestParam("clientId")String clientId,
-												   @RequestParam("clientSecret")String clientSecret) {
+	public HttpResponseResult<Map<String,Object>> smsLogin(@RequestParam("phone")String phone,
+														   @RequestParam("clientId")String clientId,
+														   @RequestParam("clientSecret")String clientSecret) {
 		return null;
 	}
 

+ 5 - 3
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/CbsQrCodeScanServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.auth.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.dayaedu.cbs.openfeign.wrapper.qrcode.CbsQrCodeScanWrapper;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -7,12 +8,12 @@ import com.ym.mec.auth.core.service.CustomTokenServices;
 import com.ym.mec.auth.service.SysUserService;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
-import org.json.JSONObject;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.Map;
 
 @Service
 public class CbsQrCodeScanServiceImpl{
@@ -40,13 +41,14 @@ public class CbsQrCodeScanServiceImpl{
             throw new BizException(HttpStatus.UNAUTHORIZED.value(), "用户不存在");
         }
         //调用登陆接口
-        HttpResponseResult<JSONObject> result = sysUserFeignService.smsLogin(phone, "QR_TEACHER", "QR_TEACHER");
+        HttpResponseResult<Map<String,Object>> result = sysUserFeignService.smsLogin(phone, "QR_TEACHER", "QR_TEACHER");
         if (result != null){
             if(result.getCode() != 200){
                 throw new BizException("扫码登陆失败", result.getMsg());
             }
             CbsQrCodeScanWrapper.QrCodeScanToken qrCodeScanToken = new CbsQrCodeScanWrapper.QrCodeScanToken();
-            qrCodeScanToken.setTokenData(result.getData().getString("access_token"));
+            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(result.getData().get("authentication")));
+            qrCodeScanToken.setTokenData(jsonObject.getString("access_token"));
             return qrCodeScanToken;
         }
         throw new BizException("扫码登陆失败", "调用登陆接口失败");