|
@@ -167,110 +167,7 @@ public class SysLoginController
|
|
|
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// *
|
|
|
-// */
|
|
|
-// @PostMapping("/login/ttcode")
|
|
|
-// @ApiOperation("字节小程序授权码模式登录")
|
|
|
-// public Response<TokenDTO> loginByTtAuthorizationCode(String authorizationCode ){
|
|
|
-// ToutiaoTokenDTO toutiaoTokenDTO = new ToutiaoTokenDTO();
|
|
|
-// toutiaoTokenDTO.setCode(authorizationCode);
|
|
|
-// toutiaoTokenDTO.setAppid(ttappid);
|
|
|
-// toutiaoTokenDTO.setSecret(ttappSecret);
|
|
|
-// String ttResultStr = toutiaoService.getTtUserInfo(toutiaoTokenDTO);
|
|
|
-// logger.info("字节小程序授权码登录返回值:"+ttResultStr);
|
|
|
-// TtResult ttResult = JSONObject.parseObject(ttResultStr,TtResult.class);
|
|
|
-//
|
|
|
-// // 生成令牌
|
|
|
-// if (ttResult.getErr_no() != 0){
|
|
|
-// throw new CustomException("抖音授权登录无效,错误原因:"+ttResult.getErr_tips());
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// ServletUtils.getRequest().setAttribute("third","douyin");
|
|
|
-// ServletUtils.getRequest().setAttribute("headImage","");
|
|
|
-// ServletUtils.getRequest().setAttribute("nickName","");
|
|
|
-// ServletUtils.getRequest().setAttribute("openid",ttResult.getData().getOpenid());
|
|
|
-//
|
|
|
-// String token = loginService.login(ttResult.getData().getUnionid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_TT_LOGIN.getCode());
|
|
|
-// TokenDTO tokenDTO = new TokenDTO();
|
|
|
-// tokenDTO.setToken(token);
|
|
|
-// tokenDTO.setThirdResult(ttResult);
|
|
|
-// return Response.success(tokenDTO) ;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// *
|
|
|
-// */
|
|
|
-// @PostMapping("/login/ttcodeTest")
|
|
|
-// @ApiOperation("字节小程序授权码模式登录(测试,固定uionid)")
|
|
|
-// public Response<TokenDTO> loginByTtAuthorizationCodeTest(){
|
|
|
-//
|
|
|
-//
|
|
|
-// ServletUtils.getRequest().setAttribute("third","douyin");
|
|
|
-// ServletUtils.getRequest().setAttribute("headImage","");
|
|
|
-// ServletUtils.getRequest().setAttribute("nickName","");
|
|
|
-// ServletUtils.getRequest().setAttribute("openid","a99b2d43-0609-4273-8d5f-ae3fdc0dec35");
|
|
|
-//
|
|
|
-// String token = loginService.login("0e412d99-1186-40c2-a004-213f06f75df9",null, StudentLoginTypeEnum.AUTHORIZATION_CODE_TT_LOGIN.getCode());
|
|
|
-// TokenDTO tokenDTO = new TokenDTO();
|
|
|
-// tokenDTO.setToken(token);
|
|
|
-// tokenDTO.setThirdResult(null);
|
|
|
-// return Response.success(tokenDTO) ;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 用户 openid登录
|
|
|
-// *
|
|
|
-// */
|
|
|
-// @PostMapping("/login/dycode")
|
|
|
-// @ApiOperation("抖音用户授权码模式登录")
|
|
|
-// public Response<TokenDTO> loginByDyAuthorizationCode(String authorizationCode ){
|
|
|
-// DyTokenDTO dyTokenDTO = new DyTokenDTO();
|
|
|
-// MultiValueMap<String,Object> paramsMap = new LinkedMultiValueMap<String,Object>();
|
|
|
-// paramsMap.add("grant_type","authorization_code");
|
|
|
-// paramsMap.add("client_secret",dyappSecret);
|
|
|
-// paramsMap.add("code",authorizationCode);
|
|
|
-// paramsMap.add("client_key",dyappid);
|
|
|
-//// dyTokenDTO.setGrantType("authorization_code");
|
|
|
-//// dyTokenDTO.setClientKey(dyappid);
|
|
|
-//// dyTokenDTO.setClientSecret(dyappSecret);
|
|
|
-//// dyTokenDTO.setCode(authorizationCode);
|
|
|
-// String dyResultStr = dyService.getDyToken1(dyappSecret,authorizationCode,"authorization_code",dyappid);
|
|
|
-// //HttpUtils.sendPost()
|
|
|
-// // String dyResultStr = dyService.getDyToken1(dyappSecret,authorizationCode,"authorization_code",dyappid);
|
|
|
-// logger.info("抖音授权码登录返回值:"+dyResultStr);
|
|
|
-// DyResult dyResult = JSONObject.parseObject(dyResultStr,DyResult.class);
|
|
|
-//
|
|
|
-// // 生成令牌
|
|
|
-// if (dyResult.getData().getError_code() != 0){
|
|
|
-// throw new CustomException("抖音授权登录无效,错误原因:"+dyResult.getData().getDescription());
|
|
|
-// }
|
|
|
-// DyUserInfoDTO dyUserInfoDTO= new DyUserInfoDTO();
|
|
|
-// dyUserInfoDTO.setOpen_id(dyResult.getData().getOpen_id());
|
|
|
-// dyUserInfoDTO.setAccess_token(dyResult.getData().getAccess_token());
|
|
|
-// String userInfoStr = dyService.getUserInfo(dyUserInfoDTO);
|
|
|
-// DyUserInfoResult dyUserInfoResult = JSONObject.parseObject(userInfoStr,DyUserInfoResult.class);
|
|
|
-//
|
|
|
-// ServletUtils.getRequest().setAttribute("third","douyin");
|
|
|
-// ServletUtils.getRequest().setAttribute("headImage",dyUserInfoResult.getData().getAvatar());
|
|
|
-// ServletUtils.getRequest().setAttribute("nickName",dyUserInfoResult.getData().getNickname());
|
|
|
-// ServletUtils.getRequest().setAttribute("openid",dyUserInfoResult.getData().getOpen_id());
|
|
|
-// String token = loginService.login(dyUserInfoResult.getData().getUnion_id(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_DY_LOGIN.getCode());
|
|
|
-// TokenDTO tokenDTO = new TokenDTO();
|
|
|
-// tokenDTO.setToken(token);
|
|
|
-// tokenDTO.setThirdResult(dyUserInfoResult);
|
|
|
-// return Response.success(tokenDTO) ;
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
+
|
|
|
@PostMapping("/login/code/test")
|
|
|
@ApiOperation("微信用户授权码模式登录--测试")
|
|
|
public Response<TokenDTO> testloginByAuthorizationCode(String authorizationCode ){
|
|
@@ -321,37 +218,6 @@ public class SysLoginController
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 用户 openid登录
|
|
|
- *
|
|
|
- */
|
|
|
- @PostMapping("/login/gzhcode")
|
|
|
- @ApiOperation("公众号微信用户授权码模式登录")
|
|
|
- public Response<TokenDTO> loginByAuthorizationGzhCode(String authorizationCode ){
|
|
|
- String wxResultStr = wxService.getWxToken(gzhAppid, gzhAppSecret, authorizationCode, "authorization_code");
|
|
|
- logger.info("微信授权码登录返回值:"+wxResultStr);
|
|
|
- WxResult wxResult = JSONObject.parseObject(wxResultStr,WxResult.class);
|
|
|
-
|
|
|
- // 生成令牌
|
|
|
- if (wxResult.getErrcode() != null){
|
|
|
- throw new CustomException("微信授权无效,请重新授权");
|
|
|
- }
|
|
|
- String userInfoStr = wxService.getUserInfo("zh_CN", wxResult.getAccess_token(), wxResult.getOpenid());
|
|
|
-
|
|
|
-
|
|
|
- WxUserInfo wxUserInfo = JSONObject.parseObject(userInfoStr,WxUserInfo.class);
|
|
|
- ServletUtils.getRequest().setAttribute("openid",wxUserInfo.getOpenid());
|
|
|
- ServletUtils.getRequest().setAttribute("headImage",wxUserInfo.getHeadimgurl());
|
|
|
- ServletUtils.getRequest().setAttribute("nickName",wxUserInfo.getNickname());
|
|
|
- String token = loginService.login(wxUserInfo.getUnionid(),null, StudentLoginTypeEnum.AUTHORIZATION_CODE_GZH_LOGIN.getCode());
|
|
|
- TokenDTO tokenDTO = new TokenDTO();
|
|
|
- tokenDTO.setToken(token);
|
|
|
- tokenDTO.setThirdResult(wxUserInfo);
|
|
|
- return Response.success(tokenDTO) ;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|