Browse Source

日志添加

hxd 3 months ago
parent
commit
1c8d690b59

+ 7 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/UserGatewayImpl.java

@@ -113,17 +113,23 @@ public class UserGatewayImpl implements UserGateway {
     @Override
     public String getOpenId(String code) {
         //首先检查传入的code是否为空,如果为空则抛出业务异常
+        log.info("code:{}", code);
         if (StringUtils.isEmpty(code)) {
             throw new BizException(ErrorEnum.WECHAT_CODE_ISNULL.getErrorCode(), ErrorEnum.WECHAT_CODE_ISNULL.getErrorMessage());
         }
         //构建请求URL
         String url = String.format("https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code", appid, secret, code);
+        log.info("url:{}", url);
         try {
             //调用微信接口
             String res = restTemplate.getForObject(url, String.class);
+            log.info("微信登录返回结果:{}", res);
             //解析返回结果
             JSONObject obj = JSONObject.parseObject(res);
-            return Objects.requireNonNull(obj).getString("openid");
+            String openId = Objects.requireNonNull(obj).getString("openid");
+            log.info("openId:{}",openId);
+            return openId;
+
         } catch (Exception e) {   //异常处理
             log.error("微信登录接口异常", e);
             throw new BizException(ErrorEnum.WECHAT_INTERFACE_CALL_EXCEPTION.getErrorCode(), ErrorEnum.WECHAT_INTERFACE_CALL_EXCEPTION.getErrorMessage());