| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.config.WxMiniConfig; |
| | | import org.springblade.common.exception.CustomException; |
| | | import org.springblade.common.utils.HttpClientUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | * @return 小程序登录校验对象 |
| | | */ |
| | | @Override |
| | | public WeChatMiniAuthorizeVo miniAuthCode(String code) throws Exception { |
| | | public WeChatMiniAuthorizeVo miniAuthCode(String code) { |
| | | String url = StrUtil.format(wxMiniConfig.getJscode2sessionUrl(), wxMiniConfig.getAppid(), wxMiniConfig.getSecret(), code); |
| | | JSONObject data = JSON.parseObject(HttpClientUtils.doGet(url)); |
| | | if (ObjectUtil.isNull(data)) { |
| | | logger.error("微信平台接口异常,没任何数据返回!"); |
| | | throw new Exception("微信平台接口异常,没任何数据返回!"); |
| | | throw new CustomException("微信平台接口异常,没任何数据返回!"); |
| | | } |
| | | if (data.containsKey("errcode") && !data.getString("errcode").equals("0")) { |
| | | if (data.containsKey("errmsg")) { |
| | | logger.error("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg")); |
| | | throw new Exception("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg")); |
| | | throw new CustomException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg")); |
| | | } |
| | | } |
| | | WeChatMiniAuthorizeVo weChatMiniAuthorizeVo = JSONObject.parseObject(data.toJSONString(), WeChatMiniAuthorizeVo.class); |