浏览代码

增加企业微信回调接口

xuzuoyun 5 年之前
父节点
当前提交
26870cb8c4

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -123,6 +123,7 @@ public class ShiroConfig {
 
 
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
+		filterChainDefinitionMap.put("/qywexin", "anon");
 
 
 

+ 7 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -45,7 +45,13 @@ public class CallbackController {
     @Autowired
     private ICtopOauthTokenService ctopOauthTokenService;
 
-
+    @GetMapping("/qywexin")
+    @ResponseBody
+    public String qywexin(HttpServletRequest request,
+                          HttpServletResponse response){
+        System.out.println(request.getQueryString());
+        return request.getQueryString();
+    }
     /**
      * TODO 授权绑定成功/失败 需要跳转特定页面
      *

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/ICorpWeixinService.java

@@ -0,0 +1,4 @@
+package cn.com.ctop.common.module.service;
+
+public interface ICorpWeixinService {
+}

+ 35 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CorpWeixinServiceImpl.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.service.ICorpWeixinService;
+import lombok.extern.slf4j.Slf4j;
+import lombok.val;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.WxCpOAuth2Service;
+import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.api.impl.WxCpOAuth2ServiceImpl;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
+import org.springframework.stereotype.Service;
+
+@Slf4j
+@Service
+public class CorpWeixinServiceImpl implements ICorpWeixinService {
+    public static void main(String[] args){
+        val configStorage = new WxCpDefaultConfigImpl();
+        configStorage.setCorpId("ww24b8a47826f5875f");
+        configStorage.setAgentId(1000002);
+        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
+        configStorage.setToken("hcst2019");
+        configStorage.setAesKey("hcst2019");
+        val service = new WxCpServiceImpl();
+        service.setWxCpConfigStorage(configStorage);
+        WxCpOAuth2Service wxCpOAuth2Service = new WxCpOAuth2ServiceImpl(service);
+        try {
+            wxCpOAuth2Service.getUserInfo(1000002,"");
+        }catch (WxErrorException e){
+            e.printStackTrace();
+        }
+
+    }
+
+}

+ 5 - 1
pom.xml

@@ -303,7 +303,11 @@
             <artifactId>guava</artifactId>
             <version>25.0-jre</version>
         </dependency>
-
+        <dependency>
+            <groupId>com.github.binarywang</groupId>
+            <artifactId>weixin-java-cp</artifactId>
+            <version>3.6.0</version>
+        </dependency>
         <dependency>
             <groupId>us.codecraft</groupId>
             <artifactId>webmagic-core</artifactId>