| | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("微信小程序登录") |
| | | @GetMapping("/wxProgramLogin") |
| | | public ApiResponse<WxLoginVO> wxProgramLogin (@RequestParam String unionId,@RequestParam String openId, HttpServletRequest request) { |
| | | return ApiResponse.success(wxLoginService.wxProgramLogin(unionId,openId, request)); |
| | | public ApiResponse<WxLoginVO> wxProgramLogin (@RequestParam String code, HttpServletRequest request) { |
| | | return ApiResponse.success(wxLoginService.wxProgramLogin(code, request)); |
| | | } |
| | | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | |
| | | |
| | | void wxLoginOut(WxLoginOutDTO wxLoginOutDTO); |
| | | |
| | | WxLoginVO wxProgramLogin(String unionId, String openId,HttpServletRequest request); |
| | | WxLoginVO wxProgramLogin(String code,HttpServletRequest request); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public WxLoginVO wxProgramLogin(String code, HttpServletRequest request) { |
| | | //TODO---------------任康 |
| | | String appId = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPID).getCode(); |
| | | String appSecret = systemDictDataBiz.queryByCode(Constants.WX_CONFIG,Constants.APPSECRET).getCode(); |
| | | String getTokenUrl = GET_ACCESS_TOKEN_URL.replace("CODE", code).replace("APPID", appId).replace("SECRET", appSecret); |
| | | JSONObject tokenJson = JSONObject.parseObject(HttpsUtil.get(getTokenUrl,true)); |
| | | if(Objects.isNull(tokenJson.get("access_token"))){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),tokenJson.getString("errmsg")); |
| | | } |
| | | String accessToken = tokenJson.getString("access_token"); |
| | | String openId = tokenJson.getString("openid"); |
| | | String getUserInfoUrl = GET_USER_INFO_URL.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openId); |
| | | JSONObject userInfoJson = JSONObject.parseObject(HttpsUtil.get(getUserInfoUrl,true)); |
| | | |
| | | return loginByUnionIdAndReturn(userInfoJson.getString("unionid"),openId,request); |
| | | |
| | | } |
| | | private WxLoginVO loginByUnionIdAndReturn(String unionid,String openId,HttpServletRequest request) { |
| | | WxLoginVO wxLoginVO = new WxLoginVO(); |
| | | wxLoginVO.setOpenid(openId); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public WxLoginVO wxProgramLogin(String unionId,String openId, HttpServletRequest request) { |
| | | return loginByUnionIdAndReturn(unionId,openId,request); |
| | | |
| | | } |
| | | |
| | | |
| | | |