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/controller/WeChatController.java |  157 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/appwx/controller/WeChatController.java b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/controller/WeChatController.java
new file mode 100644
index 0000000..208f528
--- /dev/null
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/appwx/controller/WeChatController.java
@@ -0,0 +1,157 @@
+package com.fzzy.appwx.controller;
+
+
+import com.fzzy.appwx.constant.WeChatConst;
+import com.fzzy.appwx.manager.WeChatManager;
+import com.fzzy.appwx.param.WeChatBaseParam;
+import com.fzzy.igds.data.ConfigData;
+import com.fzzy.igds.data.PageResponse;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.annotation.Resource;
+import java.net.URLEncoder;
+
+@Slf4j
+@Controller
+@RequestMapping("/wx")
+public class WeChatController {
+
+    @Resource
+    private ConfigData configData;
+    @Resource
+    private WeChatManager weChatManager;
+
+
+    /**
+     * 寰俊鑿滃崟閲嶅畾鍚戣幏鍙朿ode
+     *
+     * @param tag
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping
+    public String redirect(
+            @RequestParam(value = "tag", required = false) String tag) throws Exception {
+
+        String url = configData.getWxServeUrl() + "/wx/view-gateway";
+
+        if (StringUtils.isEmpty(tag)) {
+            tag = "home";
+        }
+//
+        String newUrl = WeChatConst.USER_AUTH_UPR
+                .replace("APPID", configData.getWxAppId())
+                .replace("REDIRECT_URI", URLEncoder.encode(url, "UTF-8"))
+                .replace("STATE", tag);
+
+        return "redirect:" + newUrl;
+//        return "redirect:" + url + "?state=" + tag;
+    }
+
+
+    /**
+     * 椤甸潰鍒嗗彂
+     *
+     * @param
+     * @return
+     */
+    @RequestMapping("/view-gateway")
+    public ModelAndView viewGateway(
+            @RequestParam(value = "code", required = false) String code,
+            @RequestParam(value = "state") String state,
+            @RequestParam(value = "id", required = false) String id,
+            @RequestParam(value = "companyId", required = false) String companyId,
+            @RequestParam(value = "loginType", required = false) String loginType,
+            @RequestParam(value = "userName", required = false) String userName) {
+
+        ModelAndView mv = new ModelAndView();
+
+        //code涓嶄负绌哄垯鑾峰彇openid
+        if (StringUtils.isNotEmpty(code)) {
+            String openid = weChatManager.getOpenid(code);
+            mv.addObject("openid", openid);
+            SysUser user = weChatManager.getUser(openid);
+            if (StringUtils.isEmpty(userName)) {
+                if (user != null) {
+                    userName = user.getUserName();
+                }
+            }
+
+        }
+
+        if (StringUtils.isNotEmpty(id)) {
+            mv.addObject("id", id);
+            mv.addObject("companyId", companyId);
+        }
+        //鍒ゆ柇鏄叕浼楀彿杩樻槸APP,榛樿涓哄叕浼楀彿
+        if (StringUtils.isEmpty(loginType)) {
+            loginType = WeChatConst.LOGIN_TYPE_WECHAT;
+        }
+        mv.addObject("loginType", loginType);
+
+        if (StringUtils.isNotEmpty(userName)) {
+            mv.addObject("userName", userName);
+        }
+        mv.setViewName("/wx/" + state);
+
+//        //娴嬭瘯浠g爜寮�鍚�
+//        String openid = "testOpenId";
+//        mv.addObject("openid", openid);
+//        SysUser user = weChatManager.getUser(openid);
+//        if (StringUtils.isEmpty(userName)) {
+//            if (user != null) {
+//                userName = user.getUserName();
+//            }
+//        }
+//        //娴嬭瘯浠g爜缁撴潫
+
+        return mv;
+    }
+
+
+    /**
+     * 鑾峰彇鐢ㄦ埛鐨勭粦瀹氫俊鎭�
+     *
+     * @param param
+     * @author sgj
+     * @since 2026/04/11
+     */
+    @PostMapping(value = "/getUserBindInfo")
+    @ResponseBody
+    public PageResponse<SysUser> getUserBindInfo(  @RequestBody WeChatBaseParam param) {
+        return weChatManager.getUserBindInfo(param);
+    }
+
+
+    /**
+     * 缁戝畾openId
+     *
+     * @param param
+     * @author sgj
+     * @since 2026/04/11
+     */
+    @PostMapping(value = "/bandOpenId")
+    @ResponseBody
+    public PageResponse<String> bandOpenId(  @RequestBody WeChatBaseParam param) {
+        return weChatManager.bandOpenId(param);
+    }
+
+    /**
+     * 瑙g粦openId
+     *
+     * @param param
+     * @author sgj
+     * @since 2026/04/11
+     */
+    @PostMapping(value = "/unBandOpenId")
+    @ResponseBody
+    public PageResponse<String> unBandOpenId(  @RequestBody WeChatBaseParam param) {
+        return weChatManager.unBandOpenId(param);
+    }
+
+}

--
Gitblit v1.9.3