DESKTOP-USV654P\pc 1 year ago
parent
commit
7017ed7856
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/main/java/com/xjrsoft/common/utils/WeChatUtil.java

+ 3 - 1
src/main/java/com/xjrsoft/common/utils/WeChatUtil.java

@@ -3,6 +3,7 @@ package com.xjrsoft.common.utils;
 
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.module.organization.dto.WeChatDepartDto;
 import com.xjrsoft.module.organization.dto.WeChatUserDto;
 import org.springframework.beans.factory.annotation.Value;
@@ -41,7 +42,8 @@ public class WeChatUtil {
         String result = HttpUtil.get("https://api.weixin.qq.com/sns/oauth2/access_token", paramMap);
         JSONObject jsonObject = JSONObject.parseObject(result);
         if (jsonObject.containsKey("errcode")) {
-            return null;
+            throw new MyException(result);
+            //return null;
         }
         String openId = jsonObject.get("openid").toString();
         return openId;