feat:add module
This commit is contained in:
parent
32bfbaf60b
commit
1097502dc6
25
ensign-module-crm/ensign-module-crm-api/pom.xml
Normal file
25
ensign-module-crm/ensign-module-crm-api/pom.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<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>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-module-crm</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>ensign-module-crm-api</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
59
ensign-module-crm/ensign-module-crm-biz/pom.xml
Normal file
59
ensign-module-crm/ensign-module-crm-biz/pom.xml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<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>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-module-crm</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>ensign-module-crm-biz</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-module-crm-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-spring-boot-starter-mybatis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-module-system-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -1,11 +1,15 @@
|
|||||||
package com.ensign.crm.server.controller;
|
package com.ensign.crm.module.crm.controller.crm;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.client.ClientHttpRequest;
|
import org.springframework.http.client.ClientHttpRequest;
|
||||||
import org.springframework.http.client.ClientHttpResponse;
|
import org.springframework.http.client.ClientHttpResponse;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@ -14,30 +18,30 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: TODO
|
* @Description: TODO
|
||||||
* @Date: 2024/9/20 18:28
|
* @Date: 2024/9/23 9:39
|
||||||
* @Created: by ZZSLL
|
* @Created: by ZZSLL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/ensign/crm")
|
@Tag(name = "CRM - Proxy")
|
||||||
|
@RequestMapping("/crm-api/proxy")
|
||||||
|
@Validated
|
||||||
public class ProxyController {
|
public class ProxyController {
|
||||||
|
|
||||||
private String targetAddr = "http://10.64.112.152:8022";
|
private String targetAddr = "http://122.4.221.133:8022";
|
||||||
|
|
||||||
|
@RequestMapping(value = "/do/**", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
@RequestMapping(value = "/proxy/**", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@Operation(summary = "转发接口")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:proxy:all')")
|
||||||
public void proxy(HttpServletRequest request, HttpServletResponse response) throws IOException, URISyntaxException {
|
public void proxy(HttpServletRequest request, HttpServletResponse response) throws IOException, URISyntaxException {
|
||||||
URI uri = new URI(request.getRequestURI());
|
URI uri = new URI(request.getRequestURI());
|
||||||
String path = uri.getPath();
|
String path = uri.getPath();
|
||||||
String query = request.getQueryString();
|
String query = request.getQueryString();
|
||||||
String target = targetAddr + path.replace("/ensign/crm/proxy", "");
|
String target = targetAddr + path.replace("/crm-api/proxy/do", "");
|
||||||
if (query != null && !query.isEmpty() && !query.equals("null")) {
|
if (query != null && !query.isEmpty() && !query.equals("null")) {
|
||||||
target = target + "?" + query;
|
target = target + "?" + query;
|
||||||
}
|
}
|
||||||
@ -70,5 +74,4 @@ public class ProxyController {
|
|||||||
}));
|
}));
|
||||||
StreamUtils.copy(clientHttpResponse.getBody(), response.getOutputStream());
|
StreamUtils.copy(clientHttpResponse.getBody(), response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
18
ensign-module-crm/pom.xml
Normal file
18
ensign-module-crm/pom.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<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>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>ensign-module-crm</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<modules>
|
||||||
|
<module>ensign-module-crm-api</module>
|
||||||
|
<module>ensign-module-crm-biz</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
@ -44,6 +44,11 @@
|
|||||||
<artifactId>ensign-spring-boot-starter-protection</artifactId>
|
<artifactId>ensign-spring-boot-starter-protection</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ensign</groupId>
|
||||||
|
<artifactId>ensign-module-crm-biz</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package com.ensign.crm.server.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: TODO
|
|
||||||
* @Date: 2024/9/20 18:33
|
|
||||||
* @Created: by ZZSLL
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class AllKingdeeException extends Exception {
|
|
||||||
public AllKingdeeException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
package com.ensign.crm.server.utils;
|
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.ensign.crm.server.exception.AllKingdeeException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.http.HttpEntity;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.client.HttpClient;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.entity.StringEntity;
|
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
|
||||||
import org.apache.http.util.EntityUtils;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: TODO
|
|
||||||
* @Date: 2024/9/20 18:33
|
|
||||||
* @Created: by ZZSLL
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class ProxyUtils {
|
|
||||||
|
|
||||||
public void initAppToken() throws IOException, AllKingdeeException
|
|
||||||
{
|
|
||||||
|
|
||||||
final String END_POINT = "/ierp/api/getAppToken.do";
|
|
||||||
|
|
||||||
HttpClient client = new DefaultHttpClient();
|
|
||||||
|
|
||||||
HttpPost post = new HttpPost(END_POINT);
|
|
||||||
|
|
||||||
Map<String, String> body = new HashMap<>();
|
|
||||||
|
|
||||||
body.put("appId", "");
|
|
||||||
body.put("appSecuret", "");
|
|
||||||
body.put("tenantid", "");
|
|
||||||
body.put("accountId", "");
|
|
||||||
body.put("language", "");
|
|
||||||
|
|
||||||
HttpEntity reqEntity = new StringEntity(JSONUtil.toJsonStr(body), "utf-8");
|
|
||||||
|
|
||||||
post.setEntity(reqEntity);
|
|
||||||
post.setConfig(RequestConf.initRequestConfig());
|
|
||||||
HttpResponse response = client.execute(post);
|
|
||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() == 200) {
|
|
||||||
|
|
||||||
HttpEntity resEntity = response.getEntity();
|
|
||||||
String responseData = EntityUtils.toString(resEntity, "utf-8");
|
|
||||||
|
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(responseData);
|
|
||||||
|
|
||||||
Boolean status = (Boolean) jsonObject.get("status");
|
|
||||||
|
|
||||||
String state = (String) jsonObject.get("state");
|
|
||||||
|
|
||||||
if (status && "success".equals(state)) {
|
|
||||||
|
|
||||||
JSONObject data = (JSONObject) jsonObject.get("data");
|
|
||||||
|
|
||||||
String appToken = (String) data.get("app_token");
|
|
||||||
|
|
||||||
if (appToken != null && !appToken.isEmpty()) {
|
|
||||||
|
|
||||||
Long expireTime = (Long) data.get("expire_time");
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.error("获取appToken失败 {}", jsonObject);
|
|
||||||
throw new AllKingdeeException("获取appToken失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.error("获取appToken失败 {}", EntityUtils.toString(response.getEntity(), "utf-8"));
|
|
||||||
throw new AllKingdeeException("获取appToken失败");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.ensign.crm.server.utils;
|
|
||||||
|
|
||||||
import org.apache.http.client.config.RequestConfig;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: TODO
|
|
||||||
* @Date: 2024/9/20 18:32
|
|
||||||
* @Created: by ZZSLL
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class RequestConf
|
|
||||||
{
|
|
||||||
public static RequestConfig initRequestConfig() {
|
|
||||||
return RequestConfig.custom()
|
|
||||||
.setConnectTimeout(5000)//一、连接超时:connectionTimeout-->指的是连接一个url的连接等待时间
|
|
||||||
.setSocketTimeout(5000)// 二、读取数据超时:SocketTimeout-->指的是连接上一个url,获取response的返回等待时间
|
|
||||||
.setConnectionRequestTimeout(5000)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
@ -185,7 +185,7 @@ ensign:
|
|||||||
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
db-schemas: ${spring.datasource.dynamic.datasource.master.name}
|
||||||
front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
front-type: 10 # 前端模版的类型,参见 CodegenFrontTypeEnum 枚举类
|
||||||
tenant: # 多租户相关配置项
|
tenant: # 多租户相关配置项
|
||||||
enable: true
|
enable: false
|
||||||
ignore-urls:
|
ignore-urls:
|
||||||
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
|
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
|
||||||
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
|
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
|
||||||
@ -196,7 +196,7 @@ ensign:
|
|||||||
- /admin-api/pay/notify/** # 支付回调通知,不携带租户编号
|
- /admin-api/pay/notify/** # 支付回调通知,不携带租户编号
|
||||||
- /jmreport/* # 积木报表,无法携带租户编号
|
- /jmreport/* # 积木报表,无法携带租户编号
|
||||||
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
|
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
|
||||||
- /admin-api/crm/**
|
- /crm-api/**
|
||||||
ignore-tables:
|
ignore-tables:
|
||||||
- system_tenant
|
- system_tenant
|
||||||
- system_tenant_package
|
- system_tenant_package
|
||||||
|
3
pom.xml
3
pom.xml
@ -15,7 +15,8 @@
|
|||||||
<!-- 各种 module 拓展 -->
|
<!-- 各种 module 拓展 -->
|
||||||
<module>ensign-module-system</module>
|
<module>ensign-module-system</module>
|
||||||
<module>ensign-module-infra</module>
|
<module>ensign-module-infra</module>
|
||||||
<!-- <module>ensign-module-member</module>-->
|
<module>ensign-module-crm</module>
|
||||||
|
<!-- <module>ensign-module-member</module>-->
|
||||||
<!-- <module>ensign-module-bpm</module>-->
|
<!-- <module>ensign-module-bpm</module>-->
|
||||||
<!-- <module>ensign-module-report</module>-->
|
<!-- <module>ensign-module-report</module>-->
|
||||||
<!-- <module>ensign-module-mp</module>-->
|
<!-- <module>ensign-module-mp</module>-->
|
||||||
|
Loading…
Reference in New Issue
Block a user