浏览代码

修改飞书登录接口跳转

syh 5 年之前
父节点
当前提交
6d37435c5a

+ 0 - 103
feishu-sdk/pom.xml

@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>cn.feishu.sdk</groupId>
-  <artifactId>feishu-sdk</artifactId>
-  <version>2.0.2</version>
-
-  <name>feishu-sdk</name>
-  <!-- FIXME change it to the project's website -->
-  <url>http://www.example.com</url>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <maven.compiler.source>1.7</maven.compiler.source>
-    <maven.compiler.target>1.7</maven.compiler.target>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>2.6</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.6</version>
-    </dependency>
-    <dependency>
-      <groupId>org.projectlombok</groupId>
-      <artifactId>lombok</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.alibaba</groupId>
-      <artifactId>fastjson</artifactId>
-      <version>1.2.56</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpclient</artifactId>
-      <version>4.5.9</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpcore</artifactId>
-      <version>4.4</version>
-    </dependency>
-    <dependency>
-      <groupId>cn.hutool</groupId>
-      <artifactId>hutool-all</artifactId>
-      <version>4.5.11</version>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
-      <plugins>
-        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
-        <plugin>
-          <artifactId>maven-clean-plugin</artifactId>
-          <version>3.1.0</version>
-        </plugin>
-        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
-        <plugin>
-          <artifactId>maven-resources-plugin</artifactId>
-          <version>3.0.2</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>3.8.0</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-surefire-plugin</artifactId>
-          <version>2.22.1</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-jar-plugin</artifactId>
-          <version>3.0.2</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-install-plugin</artifactId>
-          <version>2.5.2</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-deploy-plugin</artifactId>
-          <version>2.8.2</version>
-        </plugin>
-        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
-        <plugin>
-          <artifactId>maven-site-plugin</artifactId>
-          <version>3.7.1</version>
-        </plugin>
-        <plugin>
-          <artifactId>maven-project-info-reports-plugin</artifactId>
-          <version>3.0.0</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
-  </build>
-</project>

+ 0 - 15
feishu-sdk/src/main/java/cn/feishu/sdk/Test.java

@@ -1,15 +0,0 @@
-package cn.feishu.sdk;
-
-import cn.feishu.sdk.provider.AuthProvider;
-
-public class Test {
-    public static void main(String[] args){
-        try {
-            AuthProvider.getAppAccessToken();
-            AuthProvider.getTenantAccessToken();
-            String string = AuthProvider.getAuthUrl("");
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-}

+ 0 - 167
feishu-sdk/src/main/java/cn/feishu/sdk/util/HttpUtil.java

@@ -1,167 +0,0 @@
-package cn.feishu.sdk.util;
-
-import cn.hutool.extra.ssh.JschRuntimeException;
-import com.alibaba.fastjson.JSONObject;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URI;
-
-public class HttpUtil {
-
-    public static JSONObject feishuGetRequest(String url, JSONObject params){
-        return HttpUtil.feishuGetRequest(null,url,params);
-    }
-    public static JSONObject feishuPostRequest(String url,JSONObject params){
-        return HttpUtil.feishuPostRequest(null,url,params);
-    }
-
-    public static String feishuGetRequestString(String url) {
-        System.out.println(url);
-        // 构造请求
-        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
-            @Override
-            public String getMethod() {
-                return "GET";
-            }
-        };
-        CloseableHttpResponse response = null;
-        CloseableHttpClient client = null;
-        try {
-            client = HttpClientBuilder.create().build();
-            httpEntity.setURI(URI.create(url));
-            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
-            httpEntity.setConfig(requestConfig);
-            response = client.execute(httpEntity);
-            if (response != null && response.getStatusLine().getStatusCode() == 200) {
-                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                StringBuilder result = new StringBuilder();
-                String line = "";
-                while ((line = bufferedReader.readLine()) != null) {
-                    result.append(line);
-                }
-                bufferedReader.close();
-                System.out.println(result.toString());
-                return result.toString();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (response != null) {
-                    response.close();
-                }
-                if (client != null) {
-                    client.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-
-    public static JSONObject feishuGetRequest(String accessToken, String url, JSONObject params) {
-        System.out.println(url);
-        // 构造请求
-        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
-            @Override
-            public String getMethod() {
-                return "GET";
-            }
-        };
-        if(accessToken != null){
-            httpEntity.setHeader("Authorization", accessToken);
-        }
-        CloseableHttpResponse response = null;
-        CloseableHttpClient client = null;
-        try {
-            client = HttpClientBuilder.create().build();
-            httpEntity.setURI(URI.create(url));
-            if (params != null){
-                httpEntity.setEntity(new StringEntity(params.toJSONString(), ContentType.APPLICATION_JSON));
-            }
-            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
-            httpEntity.setConfig(requestConfig);
-            response = client.execute(httpEntity);
-            if (response != null && response.getStatusLine().getStatusCode() == 200) {
-                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                StringBuilder result = new StringBuilder();
-                String line = "";
-                while ((line = bufferedReader.readLine()) != null) {
-                    result.append(line);
-                }
-                bufferedReader.close();
-                System.out.println(result.toString());
-                return JSONObject.parseObject(result.toString());
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (response != null) {
-                    response.close();
-                }
-                if (client != null) {
-                    client.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-
-
-
-    public static JSONObject feishuPostRequest(String accessToken, String url, JSONObject params) {
-        // 构造请求
-        HttpPost httpEntity = new HttpPost(url);
-        if(accessToken != null){
-            httpEntity.setHeader("Authorization", accessToken);
-        }
-        CloseableHttpResponse response = null;
-        CloseableHttpClient client = null;
-        try {
-            client = HttpClientBuilder.create().build();
-            httpEntity.setEntity(new StringEntity(params.toJSONString(), ContentType.APPLICATION_JSON));
-            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
-            httpEntity.setConfig(requestConfig);
-            response = client.execute(httpEntity);
-            if (response != null && response.getStatusLine().getStatusCode() == 200) {
-                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                StringBuilder result = new StringBuilder();
-                String line = "";
-                while ((line = bufferedReader.readLine()) != null) {
-                    result.append(line);
-                }
-                bufferedReader.close();
-                System.out.println(result.toString());
-                return JSONObject.parseObject(result.toString());
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (response != null) {
-                    response.close();
-                }
-                if (client != null) {
-                    client.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-        return null;
-    }
-}

+ 0 - 62
feishu-sdk/src/main/java/cn/feishu/sdk/util/PropertiesUtils.java

@@ -1,62 +0,0 @@
-package cn.feishu.sdk.util;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author jeecg-boot
- * 2019年11月12日10:04:00
- */
-public class PropertiesUtils {
-    private static Map<String, String> cache = new HashMap<String, String>();
-
-    public static String getConfig(String key) {
-        return getValue("config", key);
-    }
-
-    public static String getValue(String name, String key) {
-        try {
-            String cacheValue = (String) cache.get(name + key);
-            if (cacheValue != null) {
-                return cacheValue;
-            }
-            Properties props = new Properties();
-            InputStream in = PropertiesUtils.class.getResourceAsStream("/"
-                    + name + ".properties");
-            props.load(in);
-            String value = props.getProperty(key);
-            cache.put(name + key, value);
-            props.clone();
-            in.close();
-            return value;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    public static Map<String, String> getMap(String name) {
-        try {
-            Properties props = new Properties();
-            InputStream in = PropertiesUtils.class.getResourceAsStream("/"
-                    + name + ".properties");
-            props.load(in);
-            Iterator<Object> it = props.keySet().iterator();
-            Map<String, String> map = new HashMap<String, String>();
-            while (it.hasNext()) {
-                String key = it.next().toString();
-                String value = props.getProperty(key);
-                map.put(key, value);
-            }
-            props.clone();
-            in.close();
-            return map;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-}

+ 0 - 4
feishu-sdk/src/main/resources/config.properties

@@ -1,4 +0,0 @@
-feishu_api_url=https://open.feishu.cn/open-apis
-feishu_app_id=cli_9e68af69ca34d00e
-feishu_app_secret=0RsCBRCLx1rG8HKfeZNeAbddxZ3Rsnwv
-callback_url=https://callback.tjyourong.com.cn/jeecg-boot/feishu/auth

+ 0 - 5
jeecg-boot-module-system/pom.xml

@@ -79,11 +79,6 @@
             <scope>compile</scope>
             <scope>compile</scope>
         </dependency>
         </dependency>
         <dependency>
         <dependency>
-            <groupId>cn.feishu.sdk</groupId>
-            <artifactId>feishu-sdk</artifactId>
-            <version>2.0.2</version>
-        </dependency>
-        <dependency>
             <groupId>com.aliyun.oss</groupId>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>3.5.0</version>
             <version>3.5.0</version>

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

@@ -131,6 +131,7 @@ public class ShiroConfig {
 
 
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
         filterChainDefinitionMap.put("/system/userCompany/**", "anon");
         filterChainDefinitionMap.put("/qywexin", "anon");
         filterChainDefinitionMap.put("/qywexin", "anon");
+        filterChainDefinitionMap.put("/sys/feishu/**", "anon");
         filterChainDefinitionMap.put("/test/getGroupData/**", "anon");
         filterChainDefinitionMap.put("/test/getGroupData/**", "anon");
         filterChainDefinitionMap.put("/test/getVideoAndImage/**", "anon");
         filterChainDefinitionMap.put("/test/getVideoAndImage/**", "anon");
         filterChainDefinitionMap.put("/test/gerCreative/**", "anon");
         filterChainDefinitionMap.put("/test/gerCreative/**", "anon");

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml

@@ -107,7 +107,7 @@
 
 
     <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
     <select id="queryProjectMemberByUserId" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
         select
-        distinct b.id as projectId,
+        distinct b.project_id as projectId,
         b.project_name as projectName,
         b.project_name as projectName,
         a.advertiser_id as advertiserId,
         a.advertiser_id as advertiserId,
         a.advertiser_name as advertiserName,
         a.advertiser_name as advertiserName,

+ 1 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -5,7 +5,6 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.common.module.utils.SpringUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
@@ -16,7 +15,6 @@ import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -72,6 +70,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
     }
     }
 
 
     //视频报表
     //视频报表
+    @Override
     public List<ProjectMember> getProjects(List<Integer> mediaIds) {
     public List<ProjectMember> getProjects(List<Integer> mediaIds) {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String userId = sysUser.getId();

+ 24 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -4,7 +4,9 @@ import cn.com.ctop.common.module.entity.CtopCorpWexinUser;
 import cn.com.ctop.common.module.service.ICtopCorpWexinUserService;
 import cn.com.ctop.common.module.service.ICtopCorpWexinUserService;
 import cn.com.ctop.common.module.utils.AesEncryptUtil;
 import cn.com.ctop.common.module.utils.AesEncryptUtil;
 import cn.com.ctop.common.module.utils.EncryptedString;
 import cn.com.ctop.common.module.utils.EncryptedString;
-import cn.feishu.sdk.provider.AuthProvider;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.feishu.provider.AuthProvider;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.RandomUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.exceptions.ClientException;
 import com.aliyuncs.exceptions.ClientException;
@@ -22,6 +24,7 @@ import me.chanjar.weixin.cp.bean.WxCpUser;
 import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.subject.Subject;
 import org.apache.shiro.subject.Subject;
+import org.eclipse.jetty.util.UrlEncoded;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.api.ISysBaseApi;
 import org.jeecg.common.system.api.ISysBaseApi;
@@ -71,6 +74,20 @@ public class LoginController {
     private ICtopCorpWexinUserService ctopCorpWexinUserService;
     private ICtopCorpWexinUserService ctopCorpWexinUserService;
     @Autowired
     @Autowired
     private ICorpFeishuUserService corpFeishuUserService;
     private ICorpFeishuUserService corpFeishuUserService;
+    @GetMapping("feishu/url")
+    public Map<String,Object> getUrl(){
+        Map<String,Object>result = new HashMap<>();
+        try {
+            String url = AuthProvider.getAuthUrl("");
+            result.put("url",url);
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_SERVER_ERROR);
+            return result;
+        }
+    }
     @GetMapping("/feishu/auth")
     @GetMapping("/feishu/auth")
     public void feishuAuth(HttpServletRequest request,
     public void feishuAuth(HttpServletRequest request,
                            HttpServletResponse response,
                            HttpServletResponse response,
@@ -80,29 +97,31 @@ public class LoginController {
         //1:根据code值获取用户飞书信息
         //1:根据code值获取用户飞书信息
         try {
         try {
             JSONObject data = AuthProvider.getFeishuUserInfo(code);
             JSONObject data = AuthProvider.getFeishuUserInfo(code);
+            System.out.println(data.toJSONString());
             String accessToken = data.getJSONObject("data").getString("access_token");
             String accessToken = data.getJSONObject("data").getString("access_token");
             //根据accessToken
             //根据accessToken
             JSONObject userData = AuthProvider.getUserInfo(accessToken);
             JSONObject userData = AuthProvider.getUserInfo(accessToken);
+            System.out.println(userData.toJSONString());
             JSONObject dataObject = userData.getJSONObject("data");
             JSONObject dataObject = userData.getJSONObject("data");
             String email = dataObject.getString("email");
             String email = dataObject.getString("email");
             if(null == email||email.trim().equals("")){
             if(null == email||email.trim().equals("")){
-                response.sendRedirect("http://localhost:3000/errorPage?desc=飞书尚未绑定邮箱");
+                response.sendRedirect("http://localhost:3000/errorPage?desc="+ UrlEncoded.encodeString("飞书账号未绑定邮箱"));
                 return ;
                 return ;
             }
             }
             SysUser sysUser = sysUserService.getUserByEmail(email);
             SysUser sysUser = sysUserService.getUserByEmail(email);
             if (sysUser == null) {
             if (sysUser == null) {
-                response.sendRedirect("http://localhost:3000/errorPage?desc=该用户未注册系统账户,请联系管理员");
+                response.sendRedirect("http://localhost:3000/errorPage?desc="+ UrlEncoded.encodeString("该用户未注册系统账户,请联系管理员"));
                 return ;
                 return ;
             }
             }
             if(sysUser.getStatus() != 1){
             if(sysUser.getStatus() != 1){
-                response.sendRedirect("http://localhost:3000/errorPage?desc=该用户已冻结,请联系管理员");
+                response.sendRedirect("http://localhost:3000/errorPage?desc="+UrlEncoded.encodeString("该用户已冻结,请联系管理员"));
                 return ;
                 return ;
             }
             }
             String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
             String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
             sysUser.setDepartId(departId);
             sysUser.setDepartId(departId);
             result = sysUserService.checkUserIsEffective(sysUser);
             result = sysUserService.checkUserIsEffective(sysUser);
             if (!result.isSuccess()) {
             if (!result.isSuccess()) {
-                response.sendRedirect("http://localhost:3000/errorPage?desc="+result.getMessage());
+                response.sendRedirect("http://localhost:3000/errorPage?desc="+UrlEncoded.encodeString(result.getMessage()));
                 return ;
                 return ;
             }
             }
             //用户登录信息
             //用户登录信息

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -56,7 +56,7 @@ spring:
   autoconfigure:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
   datasource:
-    url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     username: hcst
     password: test@20190531
     password: test@20190531
     driver-class-name: com.mysql.jdbc.Driver
     driver-class-name: com.mysql.jdbc.Driver
@@ -95,7 +95,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
       datasource:
         master:
         master:
-          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           username: hcst
           password: test@20190531
           password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
           driver-class-name: com.mysql.jdbc.Driver

+ 146 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -793,4 +793,150 @@ public class HttpUtils {
         }
         }
         return strReturn;
         return strReturn;
     }
     }
+
+    public static JSONObject feishuGetRequest(String url, JSONObject params){
+        return feishuGetRequest(null,url,params);
+    }
+    public static JSONObject feishuPostRequest(String url,JSONObject params){
+        return feishuPostRequest(null,url,params);
+    }
+
+    public static String feishuGetRequestString(String url) {
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "GET";
+            }
+        };
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(url));
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
+            httpEntity.setConfig(requestConfig);
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuilder result = new StringBuilder();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                System.out.println(result.toString());
+                return result.toString();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                if (client != null) {
+                    client.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    public static JSONObject feishuGetRequest(String accessToken, String url, JSONObject params) {
+        System.out.println(url);
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "GET";
+            }
+        };
+        if(accessToken != null){
+            httpEntity.setHeader("Authorization", accessToken);
+        }
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(url));
+            if (params != null){
+                httpEntity.setEntity(new StringEntity(params.toJSONString(), ContentType.APPLICATION_JSON));
+            }
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
+            httpEntity.setConfig(requestConfig);
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuilder result = new StringBuilder();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                System.out.println(result.toString());
+                return JSONObject.parseObject(result.toString());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                if (client != null) {
+                    client.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+
+
+    public static JSONObject feishuPostRequest(String accessToken, String url, JSONObject params) {
+        // 构造请求
+        HttpPost httpEntity = new HttpPost(url);
+        if(accessToken != null){
+            httpEntity.setHeader("Authorization", accessToken);
+        }
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setEntity(new StringEntity(params.toJSONString(), ContentType.APPLICATION_JSON));
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
+            httpEntity.setConfig(requestConfig);
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuilder result = new StringBuilder();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                System.out.println(result.toString());
+                return JSONObject.parseObject(result.toString());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                if (client != null) {
+                    client.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
 }
 }

+ 7 - 6
feishu-sdk/src/main/java/cn/feishu/sdk/common/ApiConstant.java

@@ -1,11 +1,10 @@
-package cn.feishu.sdk.common;
+package cn.com.feishu.constant;
 
 
-import cn.feishu.sdk.util.PropertiesUtils;
 
 
-public class ApiConstant {
-    public static final String FEISHU_API_URL = PropertiesUtils.getConfig("feishu_api_url");
-    public static final String FEISHU_APP_ID = PropertiesUtils.getConfig("feishu_app_id");
-    public static final String FEISHU_APP_SECRET = PropertiesUtils.getConfig("feishu_app_secret");
+public class FeishuConstant {
+    public static final String FEISHU_API_URL = "https://open.feishu.cn/open-apis";
+    public static final String FEISHU_APP_ID = "cli_9e68af69ca34d00e";
+    public static final String FEISHU_APP_SECRET = "0RsCBRCLx1rG8HKfeZNeAbddxZ3Rsnwv";
     public static final String APP_ACCESS_TOKEN = "/auth/v3/app_access_token/internal/";
     public static final String APP_ACCESS_TOKEN = "/auth/v3/app_access_token/internal/";
     public static final String TENANT_ACCESS_TOKEN = "/auth/v3/tenant_access_token/internal/";
     public static final String TENANT_ACCESS_TOKEN = "/auth/v3/tenant_access_token/internal/";
     public static final String AUTH_INDEX = "/authen/v1/index";
     public static final String AUTH_INDEX = "/authen/v1/index";
@@ -15,4 +14,6 @@ public class ApiConstant {
     public static final String MESSAGE_BATCH_SEND = "/message/v4/batch_send/";
     public static final String MESSAGE_BATCH_SEND = "/message/v4/batch_send/";
     public static final String MESSAGE_SEND = "/message/v4/send/";
     public static final String MESSAGE_SEND = "/message/v4/send/";
     public static final String NOTIFY_SEND = "/notify/v4/appnotify";
     public static final String NOTIFY_SEND = "/notify/v4/appnotify";
+    public static final String REDIRECT_URL = "https://callback.tjyourong.com.cn/jeecg-boot/feishu/auth";
+//    public static final String REDIRECT_URL = "http://192.168.0.111:8088/jeecg-boot/sys/feishu/auth";
 }
 }

+ 15 - 17
feishu-sdk/src/main/java/cn/feishu/sdk/provider/AuthProvider.java

@@ -1,8 +1,7 @@
-package cn.feishu.sdk.provider;
+package cn.com.feishu.provider;
 
 
-import cn.feishu.sdk.common.ApiConstant;
-import cn.feishu.sdk.util.HttpUtil;
-import cn.feishu.sdk.util.PropertiesUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.feishu.constant.FeishuConstant;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
@@ -17,10 +16,9 @@ public class AuthProvider {
      * @throws UnsupportedEncodingException
      * @throws UnsupportedEncodingException
      * @throws MalformedURLException
      * @throws MalformedURLException
      */
      */
-    public static String getAuthUrl(String state) throws UnsupportedEncodingException, MalformedURLException {
-        String redirectUri = PropertiesUtils.getConfig("callback_url");
-        System.out.println(ApiConstant.FEISHU_API_URL+ApiConstant.AUTH_INDEX+"?redirect_uri="+ URLEncoder.encode(redirectUri,"UTF-8")+"&app_id="+ApiConstant.FEISHU_APP_ID+"&state="+state);
-        return HttpUtil.feishuGetRequestString(ApiConstant.FEISHU_API_URL+ApiConstant.AUTH_INDEX+"?redirect_uri="+ URLEncoder.encode(redirectUri,"UTF-8")+"&app_id="+ApiConstant.FEISHU_APP_ID+"&state="+state);
+    public static String getAuthUrl(String state) throws UnsupportedEncodingException {
+        String redirectUrl = FeishuConstant.REDIRECT_URL;
+        return FeishuConstant.FEISHU_API_URL+FeishuConstant.AUTH_INDEX+"?redirect_uri="+ URLEncoder.encode(redirectUrl,"UTF-8")+"&app_id="+FeishuConstant.FEISHU_APP_ID+"&state="+state;
     }
     }
 
 
     /**
     /**
@@ -34,7 +32,7 @@ public class AuthProvider {
         params.put("app_access_token",getAppAccessToken());
         params.put("app_access_token",getAppAccessToken());
         params.put("grant_type","authorization_code");
         params.put("grant_type","authorization_code");
         params.put("code",code);
         params.put("code",code);
-        return HttpUtil.feishuPostRequest(ApiConstant.FEISHU_API_URL+ApiConstant.AUTH_ACCESS_TOKEN,params);
+        return HttpUtils.feishuPostRequest(FeishuConstant.FEISHU_API_URL+FeishuConstant.AUTH_ACCESS_TOKEN,params);
     }
     }
 
 
     public static JSONObject refreshAccessToken(String refreshToken) throws Exception{
     public static JSONObject refreshAccessToken(String refreshToken) throws Exception{
@@ -42,13 +40,13 @@ public class AuthProvider {
         params.put("app_access_token",getAppAccessToken());
         params.put("app_access_token",getAppAccessToken());
         params.put("grant_type","refresh_token");
         params.put("grant_type","refresh_token");
         params.put("refresh_token",refreshToken);
         params.put("refresh_token",refreshToken);
-        return HttpUtil.feishuPostRequest(ApiConstant.FEISHU_API_URL+ApiConstant.REFRESH_AUTH_ACCESS_TOKEN,params);
+        return HttpUtils.feishuPostRequest(FeishuConstant.FEISHU_API_URL+FeishuConstant.REFRESH_AUTH_ACCESS_TOKEN,params);
     }
     }
 
 
     public static JSONObject getUserInfo(String accessToken){
     public static JSONObject getUserInfo(String accessToken){
         JSONObject params = new JSONObject();
         JSONObject params = new JSONObject();
         params.put("user_access_token",accessToken);
         params.put("user_access_token",accessToken);
-        return HttpUtil.feishuGetRequest("Bearer user_access_token",ApiConstant.FEISHU_API_URL+ApiConstant.USER_INFO,params);
+        return HttpUtils.feishuGetRequest("Bearer user_access_token",FeishuConstant.FEISHU_API_URL+FeishuConstant.USER_INFO,params);
     }
     }
 
 
     /**
     /**
@@ -59,9 +57,9 @@ public class AuthProvider {
      */
      */
     public static String getAppAccessToken() throws Exception {
     public static String getAppAccessToken() throws Exception {
         JSONObject params = new JSONObject();
         JSONObject params = new JSONObject();
-        params.put("app_id",ApiConstant.FEISHU_APP_ID);
-        params.put("app_secret",ApiConstant.FEISHU_APP_SECRET);
-        JSONObject resultNode = HttpUtil.feishuPostRequest(ApiConstant.FEISHU_API_URL+ApiConstant.APP_ACCESS_TOKEN,params);
+        params.put("app_id",FeishuConstant.FEISHU_APP_ID);
+        params.put("app_secret",FeishuConstant.FEISHU_APP_SECRET);
+        JSONObject resultNode = HttpUtils.feishuPostRequest(FeishuConstant.FEISHU_API_URL+FeishuConstant.APP_ACCESS_TOKEN,params);
         if (resultNode.getIntValue("code")==0){
         if (resultNode.getIntValue("code")==0){
             return resultNode.getString("app_access_token");
             return resultNode.getString("app_access_token");
         }else {
         }else {
@@ -77,9 +75,9 @@ public class AuthProvider {
      */
      */
     public static String getTenantAccessToken() throws Exception {
     public static String getTenantAccessToken() throws Exception {
         JSONObject params = new JSONObject();
         JSONObject params = new JSONObject();
-        params.put("app_id",ApiConstant.FEISHU_APP_ID);
-        params.put("app_secret",ApiConstant.FEISHU_APP_SECRET);
-        JSONObject resultNode = HttpUtil.feishuPostRequest(ApiConstant.FEISHU_API_URL+ApiConstant.TENANT_ACCESS_TOKEN,params);
+        params.put("app_id",FeishuConstant.FEISHU_APP_ID);
+        params.put("app_secret",FeishuConstant.FEISHU_APP_SECRET);
+        JSONObject resultNode = HttpUtils.feishuPostRequest(FeishuConstant.FEISHU_API_URL+FeishuConstant.TENANT_ACCESS_TOKEN,params);
         if (resultNode.getIntValue("code")==0){
         if (resultNode.getIntValue("code")==0){
             return resultNode.getString("tenant_access_token");
             return resultNode.getString("tenant_access_token");
         }else {
         }else {

+ 5 - 6
feishu-sdk/src/main/java/cn/feishu/sdk/provider/MessageProvider.java

@@ -1,15 +1,14 @@
-package cn.feishu.sdk.provider;
+package cn.com.feishu.provider;
 
 
-import cn.feishu.sdk.common.ApiConstant;
-import cn.feishu.sdk.util.HttpUtil;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.feishu.constant.FeishuConstant;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
 import java.util.List;
 import java.util.List;
 
 
 public class MessageProvider {
 public class MessageProvider {
     public JSONObject batchSend(List<String> departmentIds,List<String> openIds,List<String> userIds,String content) throws Exception {
     public JSONObject batchSend(List<String> departmentIds,List<String> openIds,List<String> userIds,String content) throws Exception {
-        AuthProvider authProvider = new AuthProvider();
-        String tenantAccessToken = authProvider.getTenantAccessToken();
+        String tenantAccessToken = AuthProvider.getTenantAccessToken();
         JSONObject contentJson = new JSONObject();
         JSONObject contentJson = new JSONObject();
         contentJson.put("text",content);
         contentJson.put("text",content);
         JSONObject params = new JSONObject();
         JSONObject params = new JSONObject();
@@ -18,7 +17,7 @@ public class MessageProvider {
         params.put("user_ids",userIds);
         params.put("user_ids",userIds);
         params.put("msg_type","text");
         params.put("msg_type","text");
         params.put("content",contentJson);
         params.put("content",contentJson);
-        return HttpUtil.feishuPostRequest("Bearer"+tenantAccessToken, ApiConstant.FEISHU_API_URL+ApiConstant.MESSAGE_BATCH_SEND,params);
+        return HttpUtils.feishuPostRequest("Bearer"+tenantAccessToken, FeishuConstant.FEISHU_API_URL+FeishuConstant.MESSAGE_BATCH_SEND,params);
     }
     }
 
 
 
 

+ 0 - 2
pom.xml

@@ -26,8 +26,6 @@
         <module>jeecg-boot-module-system</module>
         <module>jeecg-boot-module-system</module>
         <module>module-job-bytedance</module>
         <module>module-job-bytedance</module>
         <module>module-job-kuaishou</module>
         <module>module-job-kuaishou</module>
-        <module>feishu-sdk</module>
-
     </modules>
     </modules>
 
 
     <distributionManagement>
     <distributionManagement>