|
@@ -2,22 +2,16 @@ package com.ym.mec.auth.service.impl;
|
|
|
|
|
|
import com.dayaedu.cbs.openfeign.service.CbsQrCodeScanService;
|
|
|
import com.dayaedu.cbs.openfeign.wrapper.qrcode.CbsQrCodeScanWrapper;
|
|
|
-import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.auth.core.service.CustomTokenServices;
|
|
|
-import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
|
|
-import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
|
|
|
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|
|
-import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class CbsQrCodeScanServiceImpl implements CbsQrCodeScanService {
|
|
@@ -26,10 +20,6 @@ public class CbsQrCodeScanServiceImpl implements CbsQrCodeScanService {
|
|
|
private CustomTokenServices customTokenServices;
|
|
|
@Resource
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
- @Resource
|
|
|
- private RedisTokenStore redisTokenStore;
|
|
|
- @Resource
|
|
|
- private ObjectMapper objectMapper;
|
|
|
|
|
|
@Override
|
|
|
public CbsQrCodeScanWrapper.UserInfo userInfo(CbsQrCodeScanWrapper.QrCodeScanUserInfoReq req) {
|
|
@@ -51,25 +41,5 @@ public class CbsQrCodeScanServiceImpl implements CbsQrCodeScanService {
|
|
|
CbsQrCodeScanWrapper.QrCodeScanToken qrCodeScanToken = new CbsQrCodeScanWrapper.QrCodeScanToken();
|
|
|
qrCodeScanToken.setTokenData(accessToken.getValue());
|
|
|
return qrCodeScanToken;
|
|
|
-
|
|
|
- /*OAuth2AccessToken oAuth2AccessToken = redisTokenStore.readAccessToken(req.getPassword());
|
|
|
- if (oAuth2AccessToken != null) {
|
|
|
- OAuth2Authentication authentication = redisTokenStore.readAuthentication(req.getPassword());
|
|
|
- Map<String,Object> hashMap = objectMapper.convertValue(authentication.getUserAuthentication().getPrincipal(), HashMap.class);
|
|
|
- Object userId = hashMap.get("userId");
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserById(Integer.parseInt(userId.toString()));
|
|
|
- if (sysUser == null) {
|
|
|
- throw new BizException(HttpStatus.UNAUTHORIZED.value(), "用户不存在");
|
|
|
- }
|
|
|
- customTokenServices.loadAuthentication()
|
|
|
- HttpResponseResult<Map<String, Object>> result = sysUserFeignService.usernameLogin(sysUser.getPhone(), sysUser.getPassword(), req.getClientId(), req.getClientSecret());
|
|
|
- if (result.getCode() != 200) {
|
|
|
- throw new BizException(result.getCode(), result.getMsg());
|
|
|
- }
|
|
|
- CbsQrCodeScanWrapper.QrCodeScanToken qrCodeScanToken = new CbsQrCodeScanWrapper.QrCodeScanToken();
|
|
|
- qrCodeScanToken.setTokenData(result.getData().get("access_token"));
|
|
|
- return qrCodeScanToken;
|
|
|
- }
|
|
|
- throw new InvalidTokenException("Invalid access token: " + req.getPassword());*/
|
|
|
}
|
|
|
}
|