From 241d327e57cbfe504aa806c61aa22e6205706098 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期六, 11 四月 2026 16:59:46 +0800
Subject: [PATCH] 引用纠正

---
 fzzy-igdss-web/src/main/java/com/fzzy/appwx/util/WeChatUtil.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/appwx/util/WeChatUtil.java b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/util/WeChatUtil.java
new file mode 100644
index 0000000..38fad8c
--- /dev/null
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/util/WeChatUtil.java
@@ -0,0 +1,58 @@
+package com.fzzy.appwx.util;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.fzzy.appwx.constant.WeChatConst;
+import com.fzzy.igds.data.ConfigData;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * 寰俊宸ュ叿绫�
+ *
+ * @author chen
+ */
+@Slf4j
+@Component
+public class WeChatUtil {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private ConfigData configData;
+
+    /**
+     * get璇锋眰
+     *
+     * @param url
+     * @return
+     */
+    public String doGet(String url) {
+        return restTemplate.getForObject(url, String.class);
+    }
+
+
+    /**
+     * 鏍规嵁缃戦〉鎺堟潈code鑾峰彇openid
+     *
+     * @param code
+     * @return
+     */
+    public String getOpenid(String code) {
+
+        String url = WeChatConst.OAUTH2_CODE_ACCESS_TOKEN_URL
+                .replace("APPID", configData.getWxAppId())
+                .replace("SECRET", configData.getWxSecret()).replace("CODE", code);
+
+        String result = this.doGet(url);
+        if (null == result) {
+            return null;
+        }
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        return jsonObject.getString("openid");
+    }
+
+}

--
Gitblit v1.9.3