cleanup code
This commit is contained in:
@@ -50,6 +50,12 @@
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-common3</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>io.netty</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--集成springmvc框架并实现自动配置 -->
|
||||
<dependency>
|
||||
@@ -67,14 +73,14 @@
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
<!-- websocket -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-websocket</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-mail</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
@@ -89,10 +95,10 @@
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<!--springboot2.6+解决metrics端点不显示jvm信息的问题-->
|
||||
<dependency>
|
||||
<groupId>io.micrometer</groupId>
|
||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.micrometer</groupId>-->
|
||||
<!-- <artifactId>micrometer-registry-prometheus</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- commons -->
|
||||
<dependency>
|
||||
@@ -141,51 +147,51 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- sqlserver-->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>sqljdbc4</artifactId>
|
||||
<version>${sqljdbc4.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.microsoft.sqlserver</groupId>-->
|
||||
<!-- <artifactId>sqljdbc4</artifactId>-->
|
||||
<!-- <version>${sqljdbc4.version}</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- oracle驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>${ojdbc6.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle</groupId>-->
|
||||
<!-- <artifactId>ojdbc6</artifactId>-->
|
||||
<!-- <version>${ojdbc6.version}</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- postgresql驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.postgresql</groupId>-->
|
||||
<!-- <artifactId>postgresql</artifactId>-->
|
||||
<!-- <version>${postgresql.version}</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!--人大金仓驱动 版本号V008R006C005B0013 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>kingbase8</artifactId>
|
||||
<version>${kingbase8.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework</groupId>-->
|
||||
<!-- <artifactId>kingbase8</artifactId>-->
|
||||
<!-- <version>${kingbase8.version}</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!--达梦数据库驱动 版本号1-3-26-2023.07.26-197096-20046-ENT -->
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>Dm8JdbcDriver18</artifactId>
|
||||
<version>${dm8.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmDialect-for-hibernate5.0</artifactId>
|
||||
<version>${dm8.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.dameng</groupId>-->
|
||||
<!-- <artifactId>Dm8JdbcDriver18</artifactId>-->
|
||||
<!-- <version>${dm8.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.dameng</groupId>-->
|
||||
<!-- <artifactId>DmDialect-for-hibernate5.0</artifactId>-->
|
||||
<!-- <version>${dm8.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- Quartz定时任务 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-quartz</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-quartz</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--JWT-->
|
||||
<dependency>
|
||||
@@ -280,19 +286,19 @@
|
||||
|
||||
<!-- 代码生成器 -->
|
||||
<!-- 如下载失败,请参考此文档 https://help.jeecg.com/java/setup/maven.html -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>codegenerate</artifactId>
|
||||
<version>${codegenerate.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot</groupId>-->
|
||||
<!-- <artifactId>codegenerate</artifactId>-->
|
||||
<!-- <version>${codegenerate.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- AutoPoi Excel工具类-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot3</groupId>
|
||||
<artifactId>autopoi-web</artifactId>
|
||||
<version>${autopoi-web.version}</version>
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>lib/autopoi-web-3.7.0.jar</systemPath>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>lib/autopoi-web-3.7.0.jar</systemPath>-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-codec</groupId>
|
||||
@@ -318,32 +324,32 @@
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云短信 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
|
||||
<version>${aliyun-java-sdk-dysmsapi.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.aliyun</groupId>-->
|
||||
<!-- <artifactId>aliyun-java-sdk-dysmsapi</artifactId>-->
|
||||
<!-- <version>${aliyun-java-sdk-dysmsapi.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- aliyun oss -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>${aliyun.oss.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.aliyun.oss</groupId>-->
|
||||
<!-- <artifactId>aliyun-sdk-oss</artifactId>-->
|
||||
<!-- <version>${aliyun.oss.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 第三方登录 -->
|
||||
<dependency>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.xkcoding.justauth</groupId>-->
|
||||
<!-- <artifactId>justauth-spring-boot-starter</artifactId>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-autoconfigure</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-configuration-processor</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
@@ -370,8 +376,8 @@
|
||||
<groupId>org.jeecgframework.boot3</groupId>
|
||||
<artifactId>autopoi</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>lib/autopoi-3.7.0.jar</systemPath>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>lib/autopoi-3.7.0.jar</systemPath>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.deepoove</groupId>
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyuncs.profile.IClientProfile;
|
||||
import org.jeecg.common.constant.enums.DySmsEnum;
|
||||
import org.jeecg.config.StaticConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Created on 17/6/7.
|
||||
* 短信API产品的DEMO程序,工程中包含了一个SmsDemo类,直接通过
|
||||
* 执行main函数即可体验短信产品API功能(只需要将AK替换成开通了云通信-短信产品功能的AK即可)
|
||||
* 工程依赖了2个jar包(存放在工程的libs目录下)
|
||||
* 1:aliyun-java-sdk-core.jar
|
||||
* 2:aliyun-java-sdk-dysmsapi.jar
|
||||
* <p>
|
||||
* 备注:Demo工程编码采用UTF-8
|
||||
* 国际短信发送请勿参照此DEMO
|
||||
*
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
public class DySmsHelper {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(DySmsHelper.class);
|
||||
|
||||
/**
|
||||
* 产品名称:云通信短信API产品,开发者无需替换
|
||||
*/
|
||||
static final String PRODUCT = "Dysmsapi";
|
||||
/**
|
||||
* 产品域名,开发者无需替换
|
||||
*/
|
||||
static final String DOMAIN = "dysmsapi.aliyuncs.com";
|
||||
|
||||
/**
|
||||
* TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
|
||||
*/
|
||||
static String accessKeyId;
|
||||
static String accessKeySecret;
|
||||
|
||||
public static void setAccessKeyId(String accessKeyId) {
|
||||
DySmsHelper.accessKeyId = accessKeyId;
|
||||
}
|
||||
|
||||
public static void setAccessKeySecret(String accessKeySecret) {
|
||||
DySmsHelper.accessKeySecret = accessKeySecret;
|
||||
}
|
||||
|
||||
public static String getAccessKeyId() {
|
||||
return accessKeyId;
|
||||
}
|
||||
|
||||
public static String getAccessKeySecret() {
|
||||
return accessKeySecret;
|
||||
}
|
||||
|
||||
|
||||
public static boolean sendSms(String phone, JSONObject templateParamJson, DySmsEnum dySmsEnum) throws ClientException {
|
||||
//可自助调整超时时间
|
||||
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
|
||||
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
|
||||
|
||||
//update-begin-author:taoyan date:20200811 for:配置类数据获取
|
||||
StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
//logger.info("阿里大鱼短信秘钥 accessKeyId:" + staticConfig.getAccessKeyId());
|
||||
//logger.info("阿里大鱼短信秘钥 accessKeySecret:"+ staticConfig.getAccessKeySecret());
|
||||
setAccessKeyId(staticConfig.getAccessKeyId());
|
||||
setAccessKeySecret(staticConfig.getAccessKeySecret());
|
||||
//update-end-author:taoyan date:20200811 for:配置类数据获取
|
||||
|
||||
//初始化acsClient,暂不支持region化
|
||||
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
||||
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", PRODUCT, DOMAIN);
|
||||
IAcsClient acsClient = new DefaultAcsClient(profile);
|
||||
|
||||
//验证json参数
|
||||
validateParam(templateParamJson, dySmsEnum);
|
||||
|
||||
//组装请求对象-具体描述见控制台-文档部分内容
|
||||
SendSmsRequest request = new SendSmsRequest();
|
||||
//必填:待发送手机号
|
||||
request.setPhoneNumbers(phone);
|
||||
//必填:短信签名-可在短信控制台中找到
|
||||
request.setSignName(dySmsEnum.getSignName());
|
||||
//必填:短信模板-可在短信控制台中找到
|
||||
request.setTemplateCode(dySmsEnum.getTemplateCode());
|
||||
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
|
||||
request.setTemplateParam(templateParamJson.toJSONString());
|
||||
|
||||
//选填-上行短信扩展码(无特殊需求用户请忽略此字段)
|
||||
//request.setSmsUpExtendCode("90997");
|
||||
|
||||
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
|
||||
//request.setOutId("yourOutId");
|
||||
|
||||
boolean result = false;
|
||||
|
||||
//hint 此处可能会抛出异常,注意catch
|
||||
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
|
||||
logger.info("短信接口返回的数据----------------");
|
||||
logger.info("{Code:" + sendSmsResponse.getCode() + ",Message:" + sendSmsResponse.getMessage() + ",RequestId:" + sendSmsResponse.getRequestId() + ",BizId:" + sendSmsResponse.getBizId() + "}");
|
||||
String ok = "OK";
|
||||
if (ok.equals(sendSmsResponse.getCode())) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static void validateParam(JSONObject templateParamJson, DySmsEnum dySmsEnum) {
|
||||
String keys = dySmsEnum.getKeys();
|
||||
String[] keyArr = keys.split(",");
|
||||
for (String item : keyArr) {
|
||||
if (!templateParamJson.containsKey(item)) {
|
||||
throw new RuntimeException("模板缺少参数:" + item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public static void main(String[] args) throws ClientException, InterruptedException {
|
||||
// JSONObject obj = new JSONObject();
|
||||
// obj.put("code", "1234");
|
||||
// sendSms("13800138000", obj, DySmsEnum.FORGET_PASSWORD_TEMPLATE_CODE);
|
||||
//package org.jeecg.common.util;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.aliyuncs.DefaultAcsClient;
|
||||
//import com.aliyuncs.IAcsClient;
|
||||
//import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
||||
//import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
||||
//import com.aliyuncs.exceptions.ClientException;
|
||||
//import com.aliyuncs.profile.DefaultProfile;
|
||||
//import com.aliyuncs.profile.IClientProfile;
|
||||
//import org.jeecg.common.constant.enums.DySmsEnum;
|
||||
//import org.jeecg.config.StaticConfig;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
///**
|
||||
// * Created on 17/6/7.
|
||||
// * 短信API产品的DEMO程序,工程中包含了一个SmsDemo类,直接通过
|
||||
// * 执行main函数即可体验短信产品API功能(只需要将AK替换成开通了云通信-短信产品功能的AK即可)
|
||||
// * 工程依赖了2个jar包(存放在工程的libs目录下)
|
||||
// * 1:aliyun-java-sdk-core.jar
|
||||
// * 2:aliyun-java-sdk-dysmsapi.jar
|
||||
// * <p>
|
||||
// * 备注:Demo工程编码采用UTF-8
|
||||
// * 国际短信发送请勿参照此DEMO
|
||||
// *
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//public class DySmsHelper {
|
||||
//
|
||||
// private final static Logger logger = LoggerFactory.getLogger(DySmsHelper.class);
|
||||
//
|
||||
// /**
|
||||
// * 产品名称:云通信短信API产品,开发者无需替换
|
||||
// */
|
||||
// static final String PRODUCT = "Dysmsapi";
|
||||
// /**
|
||||
// * 产品域名,开发者无需替换
|
||||
// */
|
||||
// static final String DOMAIN = "dysmsapi.aliyuncs.com";
|
||||
//
|
||||
// /**
|
||||
// * TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
|
||||
// */
|
||||
// static String accessKeyId;
|
||||
// static String accessKeySecret;
|
||||
//
|
||||
// public static void setAccessKeyId(String accessKeyId) {
|
||||
// DySmsHelper.accessKeyId = accessKeyId;
|
||||
// }
|
||||
}
|
||||
//
|
||||
// public static void setAccessKeySecret(String accessKeySecret) {
|
||||
// DySmsHelper.accessKeySecret = accessKeySecret;
|
||||
// }
|
||||
//
|
||||
// public static String getAccessKeyId() {
|
||||
// return accessKeyId;
|
||||
// }
|
||||
//
|
||||
// public static String getAccessKeySecret() {
|
||||
// return accessKeySecret;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static boolean sendSms(String phone, JSONObject templateParamJson, DySmsEnum dySmsEnum) throws ClientException {
|
||||
// //可自助调整超时时间
|
||||
// System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
|
||||
// System.setProperty("sun.net.client.defaultReadTimeout", "10000");
|
||||
//
|
||||
// //update-begin-author:taoyan date:20200811 for:配置类数据获取
|
||||
// StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
// //logger.info("阿里大鱼短信秘钥 accessKeyId:" + staticConfig.getAccessKeyId());
|
||||
// //logger.info("阿里大鱼短信秘钥 accessKeySecret:"+ staticConfig.getAccessKeySecret());
|
||||
// setAccessKeyId(staticConfig.getAccessKeyId());
|
||||
// setAccessKeySecret(staticConfig.getAccessKeySecret());
|
||||
// //update-end-author:taoyan date:20200811 for:配置类数据获取
|
||||
//
|
||||
// //初始化acsClient,暂不支持region化
|
||||
// IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
||||
// DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", PRODUCT, DOMAIN);
|
||||
// IAcsClient acsClient = new DefaultAcsClient(profile);
|
||||
//
|
||||
// //验证json参数
|
||||
// validateParam(templateParamJson, dySmsEnum);
|
||||
//
|
||||
// //组装请求对象-具体描述见控制台-文档部分内容
|
||||
// SendSmsRequest request = new SendSmsRequest();
|
||||
// //必填:待发送手机号
|
||||
// request.setPhoneNumbers(phone);
|
||||
// //必填:短信签名-可在短信控制台中找到
|
||||
// request.setSignName(dySmsEnum.getSignName());
|
||||
// //必填:短信模板-可在短信控制台中找到
|
||||
// request.setTemplateCode(dySmsEnum.getTemplateCode());
|
||||
// //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
|
||||
// request.setTemplateParam(templateParamJson.toJSONString());
|
||||
//
|
||||
// //选填-上行短信扩展码(无特殊需求用户请忽略此字段)
|
||||
// //request.setSmsUpExtendCode("90997");
|
||||
//
|
||||
// //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
|
||||
// //request.setOutId("yourOutId");
|
||||
//
|
||||
// boolean result = false;
|
||||
//
|
||||
// //hint 此处可能会抛出异常,注意catch
|
||||
// SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
|
||||
// logger.info("短信接口返回的数据----------------");
|
||||
// logger.info("{Code:" + sendSmsResponse.getCode() + ",Message:" + sendSmsResponse.getMessage() + ",RequestId:" + sendSmsResponse.getRequestId() + ",BizId:" + sendSmsResponse.getBizId() + "}");
|
||||
// String ok = "OK";
|
||||
// if (ok.equals(sendSmsResponse.getCode())) {
|
||||
// result = true;
|
||||
// }
|
||||
// return result;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private static void validateParam(JSONObject templateParamJson, DySmsEnum dySmsEnum) {
|
||||
// String keys = dySmsEnum.getKeys();
|
||||
// String[] keyArr = keys.split(",");
|
||||
// for (String item : keyArr) {
|
||||
// if (!templateParamJson.containsKey(item)) {
|
||||
// throw new RuntimeException("模板缺少参数:" + item);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// public static void main(String[] args) throws ClientException, InterruptedException {
|
||||
//// JSONObject obj = new JSONObject();
|
||||
//// obj.put("code", "1234");
|
||||
//// sendSms("13800138000", obj, DySmsEnum.FORGET_PASSWORD_TEMPLATE_CODE);
|
||||
//// }
|
||||
//}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 流水号生成规则(按默认规则递增,数字从1-99开始递增,数字到99,递增字母;位数不够增加位数)
|
||||
@@ -158,7 +158,7 @@ public class YouBianCodeUtil {
|
||||
}
|
||||
|
||||
public static String[] cutYouBianCode(String code) {
|
||||
if (code == null || StringUtil.isNullOrEmpty(code)) {
|
||||
if (code == null || StringUtils.isBlank(code)) {
|
||||
return null;
|
||||
} else {
|
||||
//获取标准长度为numLength+1,截取的数量为code.length/numLength+1
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecgframework.codegenerate.generate.util.SimpleFormat;
|
||||
//import org.jeecgframework.codegenerate.generate.util.SimpleFormat;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
@@ -102,7 +102,7 @@ public class FreemarkerParseFactory {
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
//paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString());
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
@@ -138,7 +138,7 @@ public class FreemarkerParseFactory {
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
//paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString(), keepSpace);
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.jeecg.common.util.oss;
|
||||
|
||||
import com.aliyun.oss.ClientConfiguration;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
|
||||
import com.aliyun.oss.model.CannedAccessControlList;
|
||||
import com.aliyun.oss.model.OSSObject;
|
||||
import com.aliyun.oss.model.PutObjectResult;
|
||||
//import com.aliyun.oss.ClientConfiguration;
|
||||
//import com.aliyun.oss.OSSClient;
|
||||
//import com.aliyun.oss.common.auth.DefaultCredentialProvider;
|
||||
//import com.aliyun.oss.model.CannedAccessControlList;
|
||||
//import com.aliyun.oss.model.OSSObject;
|
||||
//import com.aliyun.oss.model.PutObjectResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.fileupload.FileItemStream;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@@ -77,14 +77,14 @@ public class OssBootUtil {
|
||||
return bucketName;
|
||||
}
|
||||
|
||||
public static OSSClient getOssClient() {
|
||||
return ossClient;
|
||||
}
|
||||
//public static OSSClient getOssClient() {
|
||||
// return ossClient;
|
||||
//}
|
||||
|
||||
/**
|
||||
* oss 工具客户端
|
||||
*/
|
||||
private static OSSClient ossClient = null;
|
||||
//private static OSSClient ossClient = null;
|
||||
|
||||
/**
|
||||
* 上传文件至阿里云 OSS
|
||||
@@ -96,7 +96,7 @@ public class OssBootUtil {
|
||||
* @return oss 中的相对文件路径
|
||||
*/
|
||||
public static String upload(MultipartFile file, String fileDir, String customBucket) throws Exception {
|
||||
//update-begin-author:liusq date:20210809 for: 过滤上传文件类型
|
||||
/*//update-begin-author:liusq date:20210809 for: 过滤上传文件类型
|
||||
SsrfFileTypeFilter.checkUploadFileType(file);
|
||||
//update-end-author:liusq date:20210809 for: 过滤上传文件类型
|
||||
|
||||
@@ -146,8 +146,8 @@ public class OssBootUtil {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
return filePath;
|
||||
}*/
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ public class OssBootUtil {
|
||||
*/
|
||||
public static String upload(FileItemStream file, String fileDir) {
|
||||
String filePath = null;
|
||||
initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
/*initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
StringBuilder fileUrl = new StringBuilder();
|
||||
try {
|
||||
String suffix = file.getName().substring(file.getName().lastIndexOf('.'));
|
||||
@@ -210,7 +210,7 @@ public class OssBootUtil {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}*/
|
||||
return filePath;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ public class OssBootUtil {
|
||||
* @param url
|
||||
*/
|
||||
public static void deleteUrl(String url, String bucket) {
|
||||
String newBucket = bucketName;
|
||||
/* String newBucket = bucketName;
|
||||
if (oConvertUtils.isNotEmpty(bucket)) {
|
||||
newBucket = bucket;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class OssBootUtil {
|
||||
//TODO 暂时不允许删除云存储的文件
|
||||
//initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
url = url.replace(bucketUrl, "");
|
||||
ossClient.deleteObject(newBucket, url);
|
||||
ossClient.deleteObject(newBucket, url);*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +251,7 @@ public class OssBootUtil {
|
||||
* @param fileName
|
||||
*/
|
||||
public static void delete(String fileName) {
|
||||
ossClient.deleteObject(bucketName, fileName);
|
||||
//ossClient.deleteObject(bucketName, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ public class OssBootUtil {
|
||||
*/
|
||||
public static InputStream getOssFile(String objectName, String bucket) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
/*try {
|
||||
String newBucket = bucketName;
|
||||
if (oConvertUtils.isNotEmpty(bucket)) {
|
||||
newBucket = bucket;
|
||||
@@ -276,7 +276,7 @@ public class OssBootUtil {
|
||||
inputStream = new BufferedInputStream(ossObject.getObjectContent());
|
||||
} catch (Exception e) {
|
||||
log.info("文件获取失败" + e.getMessage());
|
||||
}
|
||||
}*/
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ public class OssBootUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getObjectUrl(String bucketName, String objectName, Date expires) {
|
||||
initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
/* initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
//update-begin---author:liusq Date:20220120 for:替换objectName前缀,防止key不一致导致获取不到文件----
|
||||
objectName = OssBootUtil.replacePrefix(objectName, bucketName);
|
||||
@@ -312,7 +312,7 @@ public class OssBootUtil {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("文件路径获取失败" + e.getMessage());
|
||||
}
|
||||
}*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -321,14 +321,14 @@ public class OssBootUtil {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static OSSClient initOss(String endpoint, String accessKeyId, String accessKeySecret) {
|
||||
if (ossClient == null) {
|
||||
ossClient = new OSSClient(endpoint,
|
||||
new DefaultCredentialProvider(accessKeyId, accessKeySecret),
|
||||
new ClientConfiguration());
|
||||
}
|
||||
return ossClient;
|
||||
}
|
||||
//private static OSSClient initOss(String endpoint, String accessKeyId, String accessKeySecret) {
|
||||
// if (ossClient == null) {
|
||||
// ossClient = new OSSClient(endpoint,
|
||||
// new DefaultCredentialProvider(accessKeyId, accessKeySecret),
|
||||
// new ClientConfiguration());
|
||||
// }
|
||||
// return ossClient;
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
@@ -340,7 +340,7 @@ public class OssBootUtil {
|
||||
*/
|
||||
public static String upload(InputStream stream, String relativePath) {
|
||||
String filePath = null;
|
||||
String fileUrl = relativePath;
|
||||
/*String fileUrl = relativePath;
|
||||
initOss(endPoint, accessKeyId, accessKeySecret);
|
||||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith(CommonConstant.STR_HTTP)) {
|
||||
filePath = staticDomain + SymbolConstant.SINGLE_SLASH + relativePath;
|
||||
@@ -352,7 +352,7 @@ public class OssBootUtil {
|
||||
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
|
||||
if (result != null) {
|
||||
log.info("------OSS文件上传成功------" + fileUrl);
|
||||
}
|
||||
}*/
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
//import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
@@ -54,8 +54,8 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||
@Value("${spring.resource.static-locations:}")
|
||||
private String staticLocations;
|
||||
|
||||
@Autowired(required = false)
|
||||
private PrometheusMeterRegistry prometheusMeterRegistry;
|
||||
//@Autowired(required = false)
|
||||
//private PrometheusMeterRegistry prometheusMeterRegistry;
|
||||
|
||||
@Autowired
|
||||
private ObjectProvider<Jackson2ObjectMapperBuilder> builderProvider;
|
||||
@@ -158,10 +158,10 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||
/**
|
||||
* 解决metrics端点不显示jvm信息的问题(zyf)
|
||||
*/
|
||||
@Bean
|
||||
InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor) {
|
||||
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, "");
|
||||
}
|
||||
//@Bean
|
||||
//InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor) {
|
||||
// return () -> meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, "");
|
||||
//}
|
||||
|
||||
// /**
|
||||
// * 注册拦截器【拦截器拦截参数,自动切换数据源——后期实现多租户切换数据源功能】
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package org.jeecg.config;
|
||||
|
||||
import org.jeecg.config.filter.WebsocketFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
/**
|
||||
* @Description: WebSocketConfig
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
/**
|
||||
* 注入ServerEndpointExporter,
|
||||
* 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
|
||||
*/
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebsocketFilter websocketFilter() {
|
||||
return new WebsocketFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean getFilterRegistrationBean() {
|
||||
FilterRegistrationBean bean = new FilterRegistrationBean();
|
||||
bean.setFilter(websocketFilter());
|
||||
//TODO 临时注释掉,测试下线上socket总断的问题
|
||||
bean.addUrlPatterns("/taskCountSocket/*", "/websocket/*", "/eoaSocket/*", "/eoaNewChatSocket/*", "/newsWebsocket/*", "/vxeSocket/*");
|
||||
return bean;
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.config;
|
||||
//
|
||||
//import org.jeecg.config.filter.WebsocketFilter;
|
||||
//import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
//
|
||||
///**
|
||||
// * @Description: WebSocketConfig
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//@Configuration
|
||||
//public class WebSocketConfig {
|
||||
// /**
|
||||
// * 注入ServerEndpointExporter,
|
||||
// * 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint
|
||||
// */
|
||||
// @Bean
|
||||
// public ServerEndpointExporter serverEndpointExporter() {
|
||||
// return new ServerEndpointExporter();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public WebsocketFilter websocketFilter() {
|
||||
// return new WebsocketFilter();
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public FilterRegistrationBean getFilterRegistrationBean() {
|
||||
// FilterRegistrationBean bean = new FilterRegistrationBean();
|
||||
// bean.setFilter(websocketFilter());
|
||||
// //TODO 临时注释掉,测试下线上socket总断的问题
|
||||
// bean.addUrlPatterns("/taskCountSocket/*", "/websocket/*", "/eoaSocket/*", "/eoaNewChatSocket/*", "/newsWebsocket/*", "/vxeSocket/*");
|
||||
// return bean;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
<dependencies>
|
||||
<!-- SYSTEM 系统管理模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>physical-system-biz</artifactId>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.jeecg;
|
||||
|
||||
import com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration;
|
||||
//import com.xkcoding.justauth.autoconfigure.JustAuthAutoConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -22,7 +22,7 @@ import java.net.UnknownHostException;
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
@ImportAutoConfiguration(JustAuthAutoConfiguration.class) // spring boot 3.x justauth 兼容性处理
|
||||
//@ImportAutoConfiguration(JustAuthAutoConfiguration.class) // spring boot 3.x justauth 兼容性处理
|
||||
//@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
|
||||
public class PhysicalApplication extends SpringBootServletInitializer {
|
||||
|
||||
|
||||
@@ -1,142 +1,142 @@
|
||||
package org.jeecg.modules.message.test;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import org.jeecg.PhysicalApplication;
|
||||
import org.jeecg.common.api.dto.message.BusMessageDTO;
|
||||
import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.enums.DySmsEnum;
|
||||
import org.jeecg.common.constant.enums.EmailTemplateEnum;
|
||||
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.DySmsHelper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 消息推送测试
|
||||
* @Author: lsq
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = PhysicalApplication.class)
|
||||
public class SendMessageTest {
|
||||
|
||||
@Autowired
|
||||
ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*/
|
||||
@Test
|
||||
public void sendSysAnnouncement() {
|
||||
//发送人
|
||||
String fromUser = "admin";
|
||||
//接收人
|
||||
String toUser = "jeecg";
|
||||
//标题
|
||||
String title = "系统消息";
|
||||
//内容
|
||||
String msgContent = "TEST:今日份日程计划已送达!";
|
||||
//发送系统消息
|
||||
sysBaseAPI.sendSysAnnouncement(new MessageDTO(fromUser, toUser, title, msgContent));
|
||||
//消息类型
|
||||
String msgCategory = CommonConstant.MSG_CATEGORY_1;
|
||||
//业务类型
|
||||
String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
//业务ID
|
||||
String busId = "11111";
|
||||
//发送带业务参数的系统消息
|
||||
BusMessageDTO busMessageDTO = new BusMessageDTO(fromUser, toUser, title, msgContent, msgCategory, busType, busId);
|
||||
sysBaseAPI.sendBusAnnouncement(busMessageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送模版消息
|
||||
*/
|
||||
@Test
|
||||
public void sendTemplateAnnouncement() {
|
||||
//发送人
|
||||
String fromUser = "admin";
|
||||
//接收人
|
||||
String toUser = "jeecg";
|
||||
//标题
|
||||
String title = "通知公告";
|
||||
//模版编码
|
||||
String templateCode = "412358";
|
||||
//模版参数
|
||||
Map templateParam = new HashMap<>();
|
||||
templateParam.put("realname", "JEECG用户");
|
||||
sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser, toUser, title, templateParam, templateCode));
|
||||
//业务类型
|
||||
String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
//业务ID
|
||||
String busId = "11111";
|
||||
//发送带业务参数的模版消息
|
||||
BusTemplateMessageDTO busMessageDTO = new BusTemplateMessageDTO(fromUser, toUser, title, templateParam, templateCode, busType, busId);
|
||||
sysBaseAPI.sendBusTemplateAnnouncement(busMessageDTO);
|
||||
//新发送模版消息
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setType(MessageTypeEnum.XT.getType());
|
||||
messageDTO.setToAll(false);
|
||||
messageDTO.setToUser(toUser);
|
||||
messageDTO.setTitle("【流程错误】");
|
||||
messageDTO.setFromUser("admin");
|
||||
HashMap data = new HashMap<>();
|
||||
data.put(CommonConstant.NOTICE_MSG_BUS_TYPE, "msg_node");
|
||||
messageDTO.setData(data);
|
||||
messageDTO.setContent("TEST:流程执行失败!任务节点未找到");
|
||||
sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
@Test
|
||||
public void sendEmailMsg() {
|
||||
String title = "【日程提醒】您的日程任务即将开始";
|
||||
String content = "TEST:尊敬的王先生,您购买的演唱会将于本周日10:08分在国家大剧院如期举行,届时请携带好您的门票和身份证到场";
|
||||
String email = "250678106@qq.com";
|
||||
sysBaseAPI.sendEmailMsg(email, title, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送html模版邮件
|
||||
*/
|
||||
@Test
|
||||
public void sendTemplateEmailMsg() {
|
||||
String title = "收到一个催办";
|
||||
String email = "250678106@qq.com";
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("bpm_name", "高级设置");
|
||||
params.put("bpm_task", "审批人");
|
||||
params.put("datetime", "2023-10-07 18:00:49");
|
||||
params.put("url", "http://boot3.jeecg.com/message/template");
|
||||
params.put("remark", "快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点");
|
||||
sysBaseAPI.sendHtmlTemplateEmail(email, title, EmailTemplateEnum.BPM_CUIBAN_EMAIL, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
*/
|
||||
@Test
|
||||
public void sendSms() throws ClientException {
|
||||
//手机号
|
||||
String mobile = "159***";
|
||||
//消息模版
|
||||
DySmsEnum templateCode = DySmsEnum.LOGIN_TEMPLATE_CODE;
|
||||
//模版所需参数
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", "4XDP");
|
||||
DySmsHelper.sendSms(mobile, obj, templateCode);
|
||||
}
|
||||
}
|
||||
//package org.jeecg.modules.message.test;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.aliyuncs.exceptions.ClientException;
|
||||
//import org.jeecg.PhysicalApplication;
|
||||
//import org.jeecg.common.api.dto.message.BusMessageDTO;
|
||||
//import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
|
||||
//import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
//import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
||||
//import org.jeecg.common.constant.CommonConstant;
|
||||
//import org.jeecg.common.constant.enums.DySmsEnum;
|
||||
//import org.jeecg.common.constant.enums.EmailTemplateEnum;
|
||||
//import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
//import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
|
||||
//import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
//import org.jeecg.common.util.DySmsHelper;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//import org.springframework.test.context.junit4.SpringRunner;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * @Description: 消息推送测试
|
||||
// * @Author: lsq
|
||||
// */
|
||||
//@RunWith(SpringRunner.class)
|
||||
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = PhysicalApplication.class)
|
||||
//public class SendMessageTest {
|
||||
//
|
||||
// @Autowired
|
||||
// ISysBaseAPI sysBaseAPI;
|
||||
//
|
||||
// /**
|
||||
// * 发送系统消息
|
||||
// */
|
||||
// @Test
|
||||
// public void sendSysAnnouncement() {
|
||||
// //发送人
|
||||
// String fromUser = "admin";
|
||||
// //接收人
|
||||
// String toUser = "jeecg";
|
||||
// //标题
|
||||
// String title = "系统消息";
|
||||
// //内容
|
||||
// String msgContent = "TEST:今日份日程计划已送达!";
|
||||
// //发送系统消息
|
||||
// sysBaseAPI.sendSysAnnouncement(new MessageDTO(fromUser, toUser, title, msgContent));
|
||||
// //消息类型
|
||||
// String msgCategory = CommonConstant.MSG_CATEGORY_1;
|
||||
// //业务类型
|
||||
// String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
// //业务ID
|
||||
// String busId = "11111";
|
||||
// //发送带业务参数的系统消息
|
||||
// BusMessageDTO busMessageDTO = new BusMessageDTO(fromUser, toUser, title, msgContent, msgCategory, busType, busId);
|
||||
// sysBaseAPI.sendBusAnnouncement(busMessageDTO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送模版消息
|
||||
// */
|
||||
// @Test
|
||||
// public void sendTemplateAnnouncement() {
|
||||
// //发送人
|
||||
// String fromUser = "admin";
|
||||
// //接收人
|
||||
// String toUser = "jeecg";
|
||||
// //标题
|
||||
// String title = "通知公告";
|
||||
// //模版编码
|
||||
// String templateCode = "412358";
|
||||
// //模版参数
|
||||
// Map templateParam = new HashMap<>();
|
||||
// templateParam.put("realname", "JEECG用户");
|
||||
// sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser, toUser, title, templateParam, templateCode));
|
||||
// //业务类型
|
||||
// String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
// //业务ID
|
||||
// String busId = "11111";
|
||||
// //发送带业务参数的模版消息
|
||||
// BusTemplateMessageDTO busMessageDTO = new BusTemplateMessageDTO(fromUser, toUser, title, templateParam, templateCode, busType, busId);
|
||||
// sysBaseAPI.sendBusTemplateAnnouncement(busMessageDTO);
|
||||
// //新发送模版消息
|
||||
// MessageDTO messageDTO = new MessageDTO();
|
||||
// messageDTO.setType(MessageTypeEnum.XT.getType());
|
||||
// messageDTO.setToAll(false);
|
||||
// messageDTO.setToUser(toUser);
|
||||
// messageDTO.setTitle("【流程错误】");
|
||||
// messageDTO.setFromUser("admin");
|
||||
// HashMap data = new HashMap<>();
|
||||
// data.put(CommonConstant.NOTICE_MSG_BUS_TYPE, "msg_node");
|
||||
// messageDTO.setData(data);
|
||||
// messageDTO.setContent("TEST:流程执行失败!任务节点未找到");
|
||||
// sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送邮件
|
||||
// */
|
||||
// @Test
|
||||
// public void sendEmailMsg() {
|
||||
// String title = "【日程提醒】您的日程任务即将开始";
|
||||
// String content = "TEST:尊敬的王先生,您购买的演唱会将于本周日10:08分在国家大剧院如期举行,届时请携带好您的门票和身份证到场";
|
||||
// String email = "250678106@qq.com";
|
||||
// sysBaseAPI.sendEmailMsg(email, title, content);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送html模版邮件
|
||||
// */
|
||||
// @Test
|
||||
// public void sendTemplateEmailMsg() {
|
||||
// String title = "收到一个催办";
|
||||
// String email = "250678106@qq.com";
|
||||
// JSONObject params = new JSONObject();
|
||||
// params.put("bpm_name", "高级设置");
|
||||
// params.put("bpm_task", "审批人");
|
||||
// params.put("datetime", "2023-10-07 18:00:49");
|
||||
// params.put("url", "http://boot3.jeecg.com/message/template");
|
||||
// params.put("remark", "快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点");
|
||||
// sysBaseAPI.sendHtmlTemplateEmail(email, title, EmailTemplateEnum.BPM_CUIBAN_EMAIL, params);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送短信
|
||||
// */
|
||||
// @Test
|
||||
// public void sendSms() throws ClientException {
|
||||
// //手机号
|
||||
// String mobile = "159***";
|
||||
// //消息模版
|
||||
// DySmsEnum templateCode = DySmsEnum.LOGIN_TEMPLATE_CODE;
|
||||
// //模版所需参数
|
||||
// JSONObject obj = new JSONObject();
|
||||
// obj.put("code", "4XDP");
|
||||
// DySmsHelper.sendSms(mobile, obj, templateCode);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot3</groupId>
|
||||
<artifactId>hibernate-re</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot3</groupId>-->
|
||||
<!-- <artifactId>hibernate-re</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 引入分布式锁依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
@@ -37,20 +37,20 @@
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
<!-- 企业微信/钉钉 api -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>jeewx-api</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework</groupId>-->
|
||||
<!-- <artifactId>jeewx-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 积木报表 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimureport-spring-boot3-starter-fastjson2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>drag-free-springboot3</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.jimureport</groupId>-->
|
||||
<!-- <artifactId>jimureport-spring-boot3-starter-fastjson2</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.jimureport</groupId>-->
|
||||
<!-- <artifactId>drag-free-springboot3</artifactId>-->
|
||||
<!-- <version>1.1.2</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
@@ -60,17 +60,17 @@
|
||||
<artifactId>hutool-http</artifactId>
|
||||
</dependency>
|
||||
<!-- chatgpt -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter3-chatgpt</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot</groupId>-->
|
||||
<!-- <artifactId>jeecg-boot-starter3-chatgpt</artifactId>-->
|
||||
<!-- <version>3.7.0</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>cn.hutool</groupId>-->
|
||||
<!-- <artifactId>hutool-all</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
|
||||
<groupId>org.jsoup</groupId>
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.jeecg.config.init;
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.codegenerate.database.CodegenDatasourceConfig;
|
||||
//import org.jeecgframework.codegenerate.database.CodegenDatasourceConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -46,7 +46,7 @@ public class CodeGenerateDbConfig {
|
||||
log.error(" 代码生成器数据库连接,数据库密码解密失败!");
|
||||
}
|
||||
}
|
||||
CodegenDatasourceConfig.initDbConfig(driverClassName, url, username, password);
|
||||
//CodegenDatasourceConfig.initDbConfig(driverClassName, url, username, password);
|
||||
log.info(" Init CodeGenerate Config [ Get Db Config From application.yml ] ");
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,105 +1,105 @@
|
||||
package org.jeecg.config.jimureport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.dto.LogDTO;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.drag.service.IOnlDragExternalService;
|
||||
import org.jeecg.modules.drag.vo.DragDictModel;
|
||||
import org.jeecg.modules.drag.vo.DragLogDTO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 字典处理
|
||||
* @Author: lsq
|
||||
* @Date:2023-01-09
|
||||
* @Version:V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("onlDragExternalServiceImpl")
|
||||
public class JimuDragExternalServiceImpl implements IOnlDragExternalService {
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ISysBaseAPI sysBaseApi;
|
||||
|
||||
/**
|
||||
* 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param codeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
@Override
|
||||
public Map<String, List<DragDictModel>> getManyDictItems(List<String> codeList) {
|
||||
Map<String, List<DragDictModel>> manyDragDictItems = new HashMap<>();
|
||||
Map<String, List<DictModel>> dictItemsMap = sysBaseApi.getManyDictItems(codeList);
|
||||
dictItemsMap.forEach((k, v) -> {
|
||||
List<DragDictModel> dictItems = new ArrayList<>();
|
||||
v.forEach(dictItem -> {
|
||||
DragDictModel dictModel = new DragDictModel();
|
||||
BeanUtils.copyProperties(dictItem, dictModel);
|
||||
dictItems.add(dictModel);
|
||||
});
|
||||
manyDragDictItems.put(k, dictItems);
|
||||
});
|
||||
return manyDragDictItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DragDictModel> getDictItems(String dictCode) {
|
||||
List<DragDictModel> dictItems = new ArrayList<>();
|
||||
if (oConvertUtils.isNotEmpty(dictCode)) {
|
||||
List<DictModel> dictItemsList = sysBaseApi.getDictItems(dictCode);
|
||||
dictItemsList.forEach(dictItem -> {
|
||||
DragDictModel dictModel = new DragDictModel();
|
||||
BeanUtils.copyProperties(dictItem, dictModel);
|
||||
dictItems.add(dictModel);
|
||||
});
|
||||
}
|
||||
return dictItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加日志
|
||||
*
|
||||
* @param dragLogDTO
|
||||
*/
|
||||
@Override
|
||||
public void addLog(DragLogDTO dragLogDTO) {
|
||||
if (oConvertUtils.isNotEmpty(dragLogDTO)) {
|
||||
LogDTO dto = new LogDTO();
|
||||
BeanUtils.copyProperties(dragLogDTO, dto);
|
||||
baseCommonService.addLog(dto);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
*
|
||||
* @param logMsg
|
||||
* @param logType
|
||||
* @param operateType
|
||||
*/
|
||||
@Override
|
||||
public void addLog(String logMsg, int logType, int operateType) {
|
||||
baseCommonService.addLog(logMsg, logType, operateType);
|
||||
}
|
||||
}
|
||||
//package org.jeecg.config.jimureport;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.jeecg.common.api.dto.LogDTO;
|
||||
//import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
//import org.jeecg.common.system.vo.DictModel;
|
||||
//import org.jeecg.common.util.oConvertUtils;
|
||||
//import org.jeecg.modules.base.service.BaseCommonService;
|
||||
//import org.jeecg.modules.drag.service.IOnlDragExternalService;
|
||||
//import org.jeecg.modules.drag.vo.DragDictModel;
|
||||
//import org.jeecg.modules.drag.vo.DragLogDTO;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Lazy;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * @Description: 字典处理
|
||||
// * @Author: lsq
|
||||
// * @Date:2023-01-09
|
||||
// * @Version:V1.0
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Service("onlDragExternalServiceImpl")
|
||||
//public class JimuDragExternalServiceImpl implements IOnlDragExternalService {
|
||||
//
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private BaseCommonService baseCommonService;
|
||||
//
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private ISysBaseAPI sysBaseApi;
|
||||
//
|
||||
// /**
|
||||
// * 根据多个字典code查询多个字典项
|
||||
// *
|
||||
// * @param codeList
|
||||
// * @return key = dictCode ; value=对应的字典项
|
||||
// */
|
||||
// @Override
|
||||
// public Map<String, List<DragDictModel>> getManyDictItems(List<String> codeList) {
|
||||
// Map<String, List<DragDictModel>> manyDragDictItems = new HashMap<>();
|
||||
// Map<String, List<DictModel>> dictItemsMap = sysBaseApi.getManyDictItems(codeList);
|
||||
// dictItemsMap.forEach((k, v) -> {
|
||||
// List<DragDictModel> dictItems = new ArrayList<>();
|
||||
// v.forEach(dictItem -> {
|
||||
// DragDictModel dictModel = new DragDictModel();
|
||||
// BeanUtils.copyProperties(dictItem, dictModel);
|
||||
// dictItems.add(dictModel);
|
||||
// });
|
||||
// manyDragDictItems.put(k, dictItems);
|
||||
// });
|
||||
// return manyDragDictItems;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param dictCode
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public List<DragDictModel> getDictItems(String dictCode) {
|
||||
// List<DragDictModel> dictItems = new ArrayList<>();
|
||||
// if (oConvertUtils.isNotEmpty(dictCode)) {
|
||||
// List<DictModel> dictItemsList = sysBaseApi.getDictItems(dictCode);
|
||||
// dictItemsList.forEach(dictItem -> {
|
||||
// DragDictModel dictModel = new DragDictModel();
|
||||
// BeanUtils.copyProperties(dictItem, dictModel);
|
||||
// dictItems.add(dictModel);
|
||||
// });
|
||||
// }
|
||||
// return dictItems;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 添加日志
|
||||
// *
|
||||
// * @param dragLogDTO
|
||||
// */
|
||||
// @Override
|
||||
// public void addLog(DragLogDTO dragLogDTO) {
|
||||
// if (oConvertUtils.isNotEmpty(dragLogDTO)) {
|
||||
// LogDTO dto = new LogDTO();
|
||||
// BeanUtils.copyProperties(dragLogDTO, dto);
|
||||
// baseCommonService.addLog(dto);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存日志
|
||||
// *
|
||||
// * @param logMsg
|
||||
// * @param logType
|
||||
// * @param operateType
|
||||
// */
|
||||
// @Override
|
||||
// public void addLog(String logMsg, int logType, int operateType) {
|
||||
// baseCommonService.addLog(logMsg, logType, operateType);
|
||||
// }
|
||||
//}
|
||||
@@ -1,82 +1,82 @@
|
||||
package org.jeecg.config.jimureport;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||
import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 自定义积木报表鉴权(如果不进行自定义,则所有请求不做权限控制)
|
||||
* * 1.自定义获取登录token
|
||||
* * 2.自定义获取登录用户
|
||||
*
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JimuReportTokenService implements JmReportTokenServiceI {
|
||||
@Autowired
|
||||
private SysBaseApiImpl sysBaseApi;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public String getToken(HttpServletRequest request) {
|
||||
return TokenUtils.getTokenByRequest(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername(String token) {
|
||||
return JwtUtil.getUsername(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getRoles(String token) {
|
||||
String username = JwtUtil.getUsername(token);
|
||||
Set roles = sysBaseApi.getUserRoleSet(username);
|
||||
if (CollectionUtils.isEmpty(roles)) {
|
||||
return null;
|
||||
}
|
||||
return (String[]) roles.toArray(new String[roles.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean verifyToken(String token) {
|
||||
return TokenUtils.verifyToken(token, sysBaseApi, redisUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getUserInfo(String token) {
|
||||
Map<String, Object> map = new HashMap(5);
|
||||
String username = JwtUtil.getUsername(token);
|
||||
//此处通过token只能拿到一个信息 用户账号 后面的就是根据账号获取其他信息 查询数据或是走redis 用户根据自身业务可自定义
|
||||
SysUserCacheInfo userInfo = null;
|
||||
try {
|
||||
userInfo = sysBaseApi.getCacheUser(username);
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户信息异常:" + e.getMessage());
|
||||
return map;
|
||||
}
|
||||
//设置账号名
|
||||
map.put(SYS_USER_CODE, userInfo.getSysUserCode());
|
||||
//设置部门编码
|
||||
map.put(SYS_ORG_CODE, userInfo.getSysOrgCode());
|
||||
// 将所有信息存放至map 解析sql/api会根据map的键值解析
|
||||
return map;
|
||||
}
|
||||
}
|
||||
//package org.jeecg.config.jimureport;
|
||||
//
|
||||
//import jakarta.servlet.http.HttpServletRequest;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.jeecg.common.system.util.JwtUtil;
|
||||
//import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
//import org.jeecg.common.util.RedisUtil;
|
||||
//import org.jeecg.common.util.TokenUtils;
|
||||
////import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||
//import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Lazy;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.CollectionUtils;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * 自定义积木报表鉴权(如果不进行自定义,则所有请求不做权限控制)
|
||||
// * * 1.自定义获取登录token
|
||||
// * * 2.自定义获取登录用户
|
||||
// *
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//
|
||||
//
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class JimuReportTokenService implements JmReportTokenServiceI {
|
||||
// @Autowired
|
||||
// private SysBaseApiImpl sysBaseApi;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private RedisUtil redisUtil;
|
||||
//
|
||||
// @Override
|
||||
// public String getToken(HttpServletRequest request) {
|
||||
// return TokenUtils.getTokenByRequest(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getUsername(String token) {
|
||||
// return JwtUtil.getUsername(token);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String[] getRoles(String token) {
|
||||
// String username = JwtUtil.getUsername(token);
|
||||
// Set roles = sysBaseApi.getUserRoleSet(username);
|
||||
// if (CollectionUtils.isEmpty(roles)) {
|
||||
// return null;
|
||||
// }
|
||||
// return (String[]) roles.toArray(new String[roles.size()]);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Boolean verifyToken(String token) {
|
||||
// return TokenUtils.verifyToken(token, sysBaseApi, redisUtil);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Map<String, Object> getUserInfo(String token) {
|
||||
// Map<String, Object> map = new HashMap(5);
|
||||
// String username = JwtUtil.getUsername(token);
|
||||
// //此处通过token只能拿到一个信息 用户账号 后面的就是根据账号获取其他信息 查询数据或是走redis 用户根据自身业务可自定义
|
||||
// SysUserCacheInfo userInfo = null;
|
||||
// try {
|
||||
// userInfo = sysBaseApi.getCacheUser(username);
|
||||
// } catch (Exception e) {
|
||||
// log.error("获取用户信息异常:" + e.getMessage());
|
||||
// return map;
|
||||
// }
|
||||
// //设置账号名
|
||||
// map.put(SYS_USER_CODE, userInfo.getSysUserCode());
|
||||
// //设置部门编码
|
||||
// map.put(SYS_ORG_CODE, userInfo.getSysOrgCode());
|
||||
// // 将所有信息存放至map 解析sql/api会根据map的键值解析
|
||||
// return map;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,106 +1,106 @@
|
||||
package org.jeecg.modules.cas.util;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* @Description: CasServiceUtil
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
public class CasServiceUtil {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String serviceUrl = "https://cas.8f8.com.cn:8443/cas/p3/serviceValidate";
|
||||
String service = "http://localhost:3003/user/login";
|
||||
String ticket = "ST-5-1g-9cNES6KXNRwq-GuRET103sm0-DESKTOP-VKLS8B3";
|
||||
String res = getStValidate(serviceUrl, ticket, service);
|
||||
|
||||
System.out.println("---------res-----" + res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证ST
|
||||
*/
|
||||
public static String getStValidate(String url, String st, String service) {
|
||||
try {
|
||||
url = url + "?service=" + service + "&ticket=" + st;
|
||||
CloseableHttpClient httpclient = createHttpClientWithNoSsl();
|
||||
HttpGet httpget = new HttpGet(url);
|
||||
HttpResponse response = httpclient.execute(httpget);
|
||||
String res = readResponse(response);
|
||||
return res == null ? null : (res == "" ? null : res);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取 response body 内容为字符串
|
||||
*
|
||||
* @param response
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
private static String readResponse(HttpResponse response) throws IOException {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
||||
String result = new String();
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result += line;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建模拟客户端(针对 https 客户端禁用 SSL 验证)
|
||||
*
|
||||
* @param cookieStore 缓存的 Cookies 信息
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static CloseableHttpClient createHttpClientWithNoSsl() throws Exception {
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||
// don't check
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||
// don't check
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
ctx.init(null, trustAllCerts, null);
|
||||
LayeredConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(ctx);
|
||||
return HttpClients.custom()
|
||||
.setSSLSocketFactory(sslSocketFactory)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.modules.cas.util;
|
||||
//
|
||||
//import org.apache.http.HttpResponse;
|
||||
//import org.apache.http.client.methods.HttpGet;
|
||||
//import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
|
||||
//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
//import org.apache.http.impl.client.CloseableHttpClient;
|
||||
//import org.apache.http.impl.client.HttpClients;
|
||||
//
|
||||
//import javax.net.ssl.SSLContext;
|
||||
//import javax.net.ssl.TrustManager;
|
||||
//import javax.net.ssl.X509TrustManager;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStreamReader;
|
||||
//import java.security.cert.X509Certificate;
|
||||
//
|
||||
///**
|
||||
// * @Description: CasServiceUtil
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//public class CasServiceUtil {
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// String serviceUrl = "https://cas.8f8.com.cn:8443/cas/p3/serviceValidate";
|
||||
// String service = "http://localhost:3003/user/login";
|
||||
// String ticket = "ST-5-1g-9cNES6KXNRwq-GuRET103sm0-DESKTOP-VKLS8B3";
|
||||
// String res = getStValidate(serviceUrl, ticket, service);
|
||||
//
|
||||
// System.out.println("---------res-----" + res);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 验证ST
|
||||
// */
|
||||
// public static String getStValidate(String url, String st, String service) {
|
||||
// try {
|
||||
// url = url + "?service=" + service + "&ticket=" + st;
|
||||
// CloseableHttpClient httpclient = createHttpClientWithNoSsl();
|
||||
// HttpGet httpget = new HttpGet(url);
|
||||
// HttpResponse response = httpclient.execute(httpget);
|
||||
// String res = readResponse(response);
|
||||
// return res == null ? null : (res == "" ? null : res);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 读取 response body 内容为字符串
|
||||
// *
|
||||
// * @param response
|
||||
// * @return
|
||||
// * @throws IOException
|
||||
// */
|
||||
// private static String readResponse(HttpResponse response) throws IOException {
|
||||
// BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
||||
// String result = new String();
|
||||
// String line;
|
||||
// while ((line = in.readLine()) != null) {
|
||||
// result += line;
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 创建模拟客户端(针对 https 客户端禁用 SSL 验证)
|
||||
// *
|
||||
// * @param cookieStore 缓存的 Cookies 信息
|
||||
// * @return
|
||||
// * @throws Exception
|
||||
// */
|
||||
// private static CloseableHttpClient createHttpClientWithNoSsl() throws Exception {
|
||||
// // Create a trust manager that does not validate certificate chains
|
||||
// TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
// new X509TrustManager() {
|
||||
// @Override
|
||||
// public X509Certificate[] getAcceptedIssuers() {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||
// // don't check
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||
// // don't check
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
// ctx.init(null, trustAllCerts, null);
|
||||
// LayeredConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(ctx);
|
||||
// return HttpClients.custom()
|
||||
// .setSSLSocketFactory(sslSocketFactory)
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description: 发钉钉消息模板
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("ddSendMsgHandle")
|
||||
public class DdSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
@Autowired
|
||||
private ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
|
||||
@Override
|
||||
public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
log.info("发微信消息模板");
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setToUser(esReceiver);
|
||||
messageDTO.setTitle(esTitle);
|
||||
messageDTO.setContent(esContent);
|
||||
messageDTO.setToAll(false);
|
||||
sendMessage(messageDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
dingtalkService.sendMessage(messageDTO, true);
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.modules.message.handle.impl;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
//import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
//import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * @Description: 发钉钉消息模板
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component("ddSendMsgHandle")
|
||||
//public class DdSendMsgHandle implements ISendMsgHandle {
|
||||
//
|
||||
// @Autowired
|
||||
// private ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
//
|
||||
// @Override
|
||||
// public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
// log.info("发微信消息模板");
|
||||
// MessageDTO messageDTO = new MessageDTO();
|
||||
// messageDTO.setToUser(esReceiver);
|
||||
// messageDTO.setTitle(esTitle);
|
||||
// messageDTO.setContent(esContent);
|
||||
// messageDTO.setToAll(false);
|
||||
// sendMessage(messageDTO);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendMessage(MessageDTO messageDTO) {
|
||||
// dingtalkService.sendMessage(messageDTO, true);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,219 +1,219 @@
|
||||
package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.StaticConfig;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description: 邮箱发送信息
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("emailSendMsgHandle")
|
||||
public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
static String emailFrom;
|
||||
|
||||
public static void setEmailFrom(String emailFrom) {
|
||||
EmailSendMsgHandle.emailFrom = emailFrom;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 真实姓名变量
|
||||
*/
|
||||
private static final String realNameExp = "{REALNAME}";
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
//update-begin-author:taoyan date:20200811 for:配置类数据获取
|
||||
if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
setEmailFrom(staticConfig.getEmailFrom());
|
||||
}
|
||||
//update-end-author:taoyan date:20200811 for:配置类数据获取
|
||||
try {
|
||||
helper = new MimeMessageHelper(message, true);
|
||||
// 设置发送方邮箱地址
|
||||
helper.setFrom(emailFrom);
|
||||
helper.setTo(esReceiver);
|
||||
helper.setSubject(esTitle);
|
||||
helper.setText(esContent, true);
|
||||
mailSender.send(message);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
String[] arr = messageDTO.getToUser().split(",");
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>().in(SysUser::getUsername, arr);
|
||||
List<SysUser> list = sysUserMapper.selectList(query);
|
||||
String content = messageDTO.getContent();
|
||||
String title = messageDTO.getTitle();
|
||||
for (SysUser user : list) {
|
||||
String email = user.getEmail();
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
content = replaceContent(user, content);
|
||||
log.info("邮件内容:" + content);
|
||||
sendMsg(email, title, content);
|
||||
}
|
||||
|
||||
//update-begin-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
Set<String> toEmailList = messageDTO.getToEmailList();
|
||||
if (toEmailList != null && toEmailList.size() > 0) {
|
||||
for (String email : toEmailList) {
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
log.info("邮件内容:" + content);
|
||||
sendMsg(email, title, content);
|
||||
}
|
||||
}
|
||||
//update-end-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
|
||||
//发送给抄送人
|
||||
sendMessageToCopyUser(messageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件给抄送人
|
||||
*
|
||||
* @param messageDTO
|
||||
*/
|
||||
public void sendMessageToCopyUser(MessageDTO messageDTO) {
|
||||
String copyToUser = messageDTO.getCopyToUser();
|
||||
if (ObjectUtils.isNotEmpty(copyToUser)) {
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>().in(SysUser::getUsername, copyToUser.split(","));
|
||||
List<SysUser> list = sysUserMapper.selectList(query);
|
||||
String content = messageDTO.getContent();
|
||||
String title = messageDTO.getTitle();
|
||||
|
||||
for (SysUser user : list) {
|
||||
String email = user.getEmail();
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
content = replaceContent(user, content);
|
||||
log.info("邮件内容:" + content);
|
||||
|
||||
//update-begin-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
sendEmail(email, content, title);
|
||||
}
|
||||
|
||||
Set<String> ccEmailList = messageDTO.getCcEmailList();
|
||||
if (ccEmailList != null && ccEmailList.size() > 0) {
|
||||
for (String email : ccEmailList) {
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
log.info("邮件内容:" + content);
|
||||
sendEmail(email, content, title);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件给抄送人调用
|
||||
*
|
||||
* @param email
|
||||
* @param content
|
||||
* @param title
|
||||
*/
|
||||
private void sendEmail(String email, String content, String title) {
|
||||
JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
setEmailFrom(staticConfig.getEmailFrom());
|
||||
}
|
||||
try {
|
||||
helper = new MimeMessageHelper(message, true);
|
||||
// 设置发送方邮箱地址
|
||||
helper.setFrom(emailFrom);
|
||||
helper.setTo(email);
|
||||
//设置抄送人
|
||||
helper.setCc(email);
|
||||
helper.setSubject(title);
|
||||
helper.setText(content, true);
|
||||
mailSender.send(message);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//update-end-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
|
||||
|
||||
/**
|
||||
* 替换邮件内容变量
|
||||
*
|
||||
* @param user
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
private String replaceContent(SysUser user, String content) {
|
||||
if (content.indexOf(realNameExp) > 0) {
|
||||
content = content.replace("$" + realNameExp, user.getRealname()).replace(realNameExp, user.getRealname());
|
||||
}
|
||||
if (content.indexOf(CommonConstant.LOGIN_TOKEN) > 0) {
|
||||
String token = getToken(user);
|
||||
try {
|
||||
content = content.replace(CommonConstant.LOGIN_TOKEN, URLEncoder.encode(token, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("邮件消息token编码失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
private String getToken(SysUser user) {
|
||||
// 生成token
|
||||
String token = JwtUtil.sign(user.getUsername(), user.getPassword());
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
// 设置超时时间 1个小时
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 1 / 1000);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
//package org.jeecg.modules.message.handle.impl;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import jakarta.mail.MessagingException;
|
||||
//import jakarta.mail.internet.MimeMessage;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.ObjectUtils;
|
||||
//import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
//import org.jeecg.common.constant.CommonConstant;
|
||||
//import org.jeecg.common.system.util.JwtUtil;
|
||||
//import org.jeecg.common.util.RedisUtil;
|
||||
//import org.jeecg.common.util.SpringContextUtils;
|
||||
//import org.jeecg.common.util.oConvertUtils;
|
||||
//import org.jeecg.config.StaticConfig;
|
||||
//import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
//import org.jeecg.modules.system.entity.SysUser;
|
||||
//import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.mail.javamail.JavaMailSender;
|
||||
//import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.UnsupportedEncodingException;
|
||||
//import java.net.URLEncoder;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * @Description: 邮箱发送信息
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component("emailSendMsgHandle")
|
||||
//public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
// static String emailFrom;
|
||||
//
|
||||
// public static void setEmailFrom(String emailFrom) {
|
||||
// EmailSendMsgHandle.emailFrom = emailFrom;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// SysUserMapper sysUserMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisUtil redisUtil;
|
||||
//
|
||||
// /**
|
||||
// * 真实姓名变量
|
||||
// */
|
||||
// private static final String realNameExp = "{REALNAME}";
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
// JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
// MimeMessage message = mailSender.createMimeMessage();
|
||||
// MimeMessageHelper helper = null;
|
||||
// //update-begin-author:taoyan date:20200811 for:配置类数据获取
|
||||
// if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
// StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
// setEmailFrom(staticConfig.getEmailFrom());
|
||||
// }
|
||||
// //update-end-author:taoyan date:20200811 for:配置类数据获取
|
||||
// try {
|
||||
// helper = new MimeMessageHelper(message, true);
|
||||
// // 设置发送方邮箱地址
|
||||
// helper.setFrom(emailFrom);
|
||||
// helper.setTo(esReceiver);
|
||||
// helper.setSubject(esTitle);
|
||||
// helper.setText(esContent, true);
|
||||
// mailSender.send(message);
|
||||
// } catch (MessagingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendMessage(MessageDTO messageDTO) {
|
||||
// String[] arr = messageDTO.getToUser().split(",");
|
||||
// LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>().in(SysUser::getUsername, arr);
|
||||
// List<SysUser> list = sysUserMapper.selectList(query);
|
||||
// String content = messageDTO.getContent();
|
||||
// String title = messageDTO.getTitle();
|
||||
// for (SysUser user : list) {
|
||||
// String email = user.getEmail();
|
||||
// if (ObjectUtils.isEmpty(email)) {
|
||||
// continue;
|
||||
// }
|
||||
// content = replaceContent(user, content);
|
||||
// log.info("邮件内容:" + content);
|
||||
// sendMsg(email, title, content);
|
||||
// }
|
||||
//
|
||||
// //update-begin-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
// Set<String> toEmailList = messageDTO.getToEmailList();
|
||||
// if (toEmailList != null && toEmailList.size() > 0) {
|
||||
// for (String email : toEmailList) {
|
||||
// if (ObjectUtils.isEmpty(email)) {
|
||||
// continue;
|
||||
// }
|
||||
// log.info("邮件内容:" + content);
|
||||
// sendMsg(email, title, content);
|
||||
// }
|
||||
// }
|
||||
// //update-end-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
//
|
||||
// //发送给抄送人
|
||||
// sendMessageToCopyUser(messageDTO);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送邮件给抄送人
|
||||
// *
|
||||
// * @param messageDTO
|
||||
// */
|
||||
// public void sendMessageToCopyUser(MessageDTO messageDTO) {
|
||||
// String copyToUser = messageDTO.getCopyToUser();
|
||||
// if (ObjectUtils.isNotEmpty(copyToUser)) {
|
||||
// LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>().in(SysUser::getUsername, copyToUser.split(","));
|
||||
// List<SysUser> list = sysUserMapper.selectList(query);
|
||||
// String content = messageDTO.getContent();
|
||||
// String title = messageDTO.getTitle();
|
||||
//
|
||||
// for (SysUser user : list) {
|
||||
// String email = user.getEmail();
|
||||
// if (ObjectUtils.isEmpty(email)) {
|
||||
// continue;
|
||||
// }
|
||||
// content = replaceContent(user, content);
|
||||
// log.info("邮件内容:" + content);
|
||||
//
|
||||
// //update-begin-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
// sendEmail(email, content, title);
|
||||
// }
|
||||
//
|
||||
// Set<String> ccEmailList = messageDTO.getCcEmailList();
|
||||
// if (ccEmailList != null && ccEmailList.size() > 0) {
|
||||
// for (String email : ccEmailList) {
|
||||
// if (ObjectUtils.isEmpty(email)) {
|
||||
// continue;
|
||||
// }
|
||||
// log.info("邮件内容:" + content);
|
||||
// sendEmail(email, content, title);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 发送邮件给抄送人调用
|
||||
// *
|
||||
// * @param email
|
||||
// * @param content
|
||||
// * @param title
|
||||
// */
|
||||
// private void sendEmail(String email, String content, String title) {
|
||||
// JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
// MimeMessage message = mailSender.createMimeMessage();
|
||||
// MimeMessageHelper helper = null;
|
||||
// if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
// StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
// setEmailFrom(staticConfig.getEmailFrom());
|
||||
// }
|
||||
// try {
|
||||
// helper = new MimeMessageHelper(message, true);
|
||||
// // 设置发送方邮箱地址
|
||||
// helper.setFrom(emailFrom);
|
||||
// helper.setTo(email);
|
||||
// //设置抄送人
|
||||
// helper.setCc(email);
|
||||
// helper.setSubject(title);
|
||||
// helper.setText(content, true);
|
||||
// mailSender.send(message);
|
||||
// } catch (MessagingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// //update-end-author:taoyan date:2023-6-20 for: QQYUN-5557【简流】通知节点 发送邮箱 表单上有一个邮箱字段,流程中,邮件发送节点,邮件接收人 不可选择邮箱
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 替换邮件内容变量
|
||||
// *
|
||||
// * @param user
|
||||
// * @param content
|
||||
// * @return
|
||||
// */
|
||||
// private String replaceContent(SysUser user, String content) {
|
||||
// if (content.indexOf(realNameExp) > 0) {
|
||||
// content = content.replace("$" + realNameExp, user.getRealname()).replace(realNameExp, user.getRealname());
|
||||
// }
|
||||
// if (content.indexOf(CommonConstant.LOGIN_TOKEN) > 0) {
|
||||
// String token = getToken(user);
|
||||
// try {
|
||||
// content = content.replace(CommonConstant.LOGIN_TOKEN, URLEncoder.encode(token, "UTF-8"));
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// log.error("邮件消息token编码失败", e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// return content;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取token
|
||||
// *
|
||||
// * @param user
|
||||
// * @return
|
||||
// */
|
||||
// private String getToken(SysUser user) {
|
||||
// // 生成token
|
||||
// String token = JwtUtil.sign(user.getUsername(), user.getPassword());
|
||||
// redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
// // 设置超时时间 1个小时
|
||||
// redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 1 / 1000);
|
||||
// return token;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description: 发企业微信消息模板
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("qywxSendMsgHandle")
|
||||
public class QywxSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
@Autowired
|
||||
private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
|
||||
@Override
|
||||
public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
log.info("发微信消息模板");
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setToUser(esReceiver);
|
||||
messageDTO.setTitle(esTitle);
|
||||
messageDTO.setContent(esContent);
|
||||
messageDTO.setToAll(false);
|
||||
sendMessage(messageDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(MessageDTO messageDTO) {
|
||||
wechatEnterpriseService.sendMessage(messageDTO, true);
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.modules.message.handle.impl;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
//import org.jeecg.modules.message.handle.ISendMsgHandle;
|
||||
//import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * @Description: 发企业微信消息模板
|
||||
// * @author: jeecg-boot
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component("qywxSendMsgHandle")
|
||||
//public class QywxSendMsgHandle implements ISendMsgHandle {
|
||||
//
|
||||
// @Autowired
|
||||
// private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
//
|
||||
// @Override
|
||||
// public void sendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
// log.info("发微信消息模板");
|
||||
// MessageDTO messageDTO = new MessageDTO();
|
||||
// messageDTO.setToUser(esReceiver);
|
||||
// messageDTO.setTitle(esTitle);
|
||||
// messageDTO.setContent(esContent);
|
||||
// messageDTO.setToAll(false);
|
||||
// sendMessage(messageDTO);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void sendMessage(MessageDTO messageDTO) {
|
||||
// wechatEnterpriseService.sendMessage(messageDTO, true);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
package org.jeecg.modules.system.cache;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import me.zhyd.oauth.cache.AuthCacheConfig;
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class AuthStateRedisCache implements AuthStateCache {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
valueOperations = redisTemplate.opsForValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 存入缓存,默认3分钟
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param value 缓存内容
|
||||
*/
|
||||
@Override
|
||||
public void cache(String key, String value) {
|
||||
valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 存入缓存
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @param value 缓存内容
|
||||
* @param timeout 指定缓存过期时间(毫秒)
|
||||
*/
|
||||
@Override
|
||||
public void cache(String key, String value, long timeout) {
|
||||
valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存内容
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @return 缓存内容
|
||||
*/
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return valueOperations.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在key,如果对应key的value值已过期,也返回false
|
||||
*
|
||||
* @param key 缓存key
|
||||
* @return true:存在key,并且value没过期;false:key不存在或者已过期
|
||||
*/
|
||||
@Override
|
||||
public boolean containsKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
}
|
||||
//package org.jeecg.modules.system.cache;
|
||||
//
|
||||
//import jakarta.annotation.PostConstruct;
|
||||
//import me.zhyd.oauth.cache.AuthCacheConfig;
|
||||
//import me.zhyd.oauth.cache.AuthStateCache;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.core.ValueOperations;
|
||||
//
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
//
|
||||
//public class AuthStateRedisCache implements AuthStateCache {
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisTemplate<String, String> redisTemplate;
|
||||
//
|
||||
// private ValueOperations<String, String> valueOperations;
|
||||
//
|
||||
// @PostConstruct
|
||||
// public void init() {
|
||||
// valueOperations = redisTemplate.opsForValue();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 存入缓存,默认3分钟
|
||||
// *
|
||||
// * @param key 缓存key
|
||||
// * @param value 缓存内容
|
||||
// */
|
||||
// @Override
|
||||
// public void cache(String key, String value) {
|
||||
// valueOperations.set(key, value, AuthCacheConfig.timeout, TimeUnit.MILLISECONDS);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 存入缓存
|
||||
// *
|
||||
// * @param key 缓存key
|
||||
// * @param value 缓存内容
|
||||
// * @param timeout 指定缓存过期时间(毫秒)
|
||||
// */
|
||||
// @Override
|
||||
// public void cache(String key, String value, long timeout) {
|
||||
// valueOperations.set(key, value, timeout, TimeUnit.MILLISECONDS);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取缓存内容
|
||||
// *
|
||||
// * @param key 缓存key
|
||||
// * @return 缓存内容
|
||||
// */
|
||||
// @Override
|
||||
// public String get(String key) {
|
||||
// return valueOperations.get(key);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 是否存在key,如果对应key的value值已过期,也返回false
|
||||
// *
|
||||
// * @param key 缓存key
|
||||
// * @return true:存在key,并且value没过期;false:key不存在或者已过期
|
||||
// */
|
||||
// @Override
|
||||
// public boolean containsKey(String key) {
|
||||
// return redisTemplate.hasKey(key);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package org.jeecg.modules.system.config;
|
||||
|
||||
import me.zhyd.oauth.cache.AuthStateCache;
|
||||
import org.jeecg.modules.system.cache.AuthStateRedisCache;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class AuthStateConfiguration {
|
||||
|
||||
@Bean
|
||||
public AuthStateCache authStateCache() {
|
||||
return new AuthStateRedisCache();
|
||||
}
|
||||
}
|
||||
//package org.jeecg.modules.system.config;
|
||||
//
|
||||
//import me.zhyd.oauth.cache.AuthStateCache;
|
||||
//import org.jeecg.modules.system.cache.AuthStateRedisCache;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//@Configuration
|
||||
//public class AuthStateConfiguration {
|
||||
//
|
||||
// @Bean
|
||||
// public AuthStateCache authStateCache() {
|
||||
// return new AuthStateRedisCache();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
//import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -294,101 +294,101 @@ public class LoginController {
|
||||
@PostMapping(value = "/sms")
|
||||
public Result<String> sms(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
|
||||
Result<String> result = new Result<String>();
|
||||
String clientIp = IpUtils.getIpAddr(request);
|
||||
String mobile = jsonObject.get("mobile").toString();
|
||||
//手机号模式 登录模式: "2" 注册模式: "1"
|
||||
String smsmode = jsonObject.get("smsmode").toString();
|
||||
log.info("-------- IP:{}, 手机号:{},获取绑定验证码", clientIp, mobile);
|
||||
|
||||
if (oConvertUtils.isEmpty(mobile)) {
|
||||
result.setMessage("手机号不允许为空!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
|
||||
Object object = redisUtil.get(redisKey);
|
||||
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
|
||||
if (object != null) {
|
||||
result.setMessage("验证码10分钟内,仍然有效!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//增加 check防止恶意刷短信接口
|
||||
if (!DySmsLimit.canSendSms(clientIp)) {
|
||||
log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp);
|
||||
result.setMessage("短信接口请求太多,请稍后再试!");
|
||||
result.setCode(CommonConstant.PHONE_SMS_FAIL_CODE);
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
//随机数
|
||||
String captcha = RandomUtil.randomNumbers(6);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", captcha);
|
||||
try {
|
||||
boolean b = false;
|
||||
//注册模板
|
||||
if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
|
||||
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
if (sysUser != null) {
|
||||
result.error500(" 手机号已经注册,请直接登录!");
|
||||
baseCommonService.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
|
||||
return result;
|
||||
}
|
||||
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.REGISTER_TEMPLATE_CODE);
|
||||
} else {
|
||||
//登录模式,校验用户有效性
|
||||
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if (!result.isSuccess()) {
|
||||
String message = result.getMessage();
|
||||
String userNotExist = "该用户不存在,请注册";
|
||||
if (userNotExist.equals(message)) {
|
||||
result.error500("该用户不存在或未绑定手机号");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* smsmode 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板
|
||||
*/
|
||||
if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
|
||||
//登录模板
|
||||
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
|
||||
} else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
|
||||
//忘记密码模板
|
||||
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.FORGET_PASSWORD_TEMPLATE_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (b == false) {
|
||||
result.setMessage("短信验证码发送失败,请稍后重试");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
//验证码10分钟内有效
|
||||
redisUtil.set(redisKey, captcha, 600);
|
||||
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
|
||||
//update-begin--Author:scott Date:20190812 for:issues#391
|
||||
//result.setResult(captcha);
|
||||
//update-end--Author:scott Date:20190812 for:issues#391
|
||||
result.setSuccess(true);
|
||||
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
result.error500(" 短信接口未配置,请联系管理员!");
|
||||
return result;
|
||||
}
|
||||
//String clientIp = IpUtils.getIpAddr(request);
|
||||
//String mobile = jsonObject.get("mobile").toString();
|
||||
////手机号模式 登录模式: "2" 注册模式: "1"
|
||||
//String smsmode = jsonObject.get("smsmode").toString();
|
||||
//log.info("-------- IP:{}, 手机号:{},获取绑定验证码", clientIp, mobile);
|
||||
//
|
||||
//if (oConvertUtils.isEmpty(mobile)) {
|
||||
// result.setMessage("手机号不允许为空!");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
//}
|
||||
//
|
||||
////update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
//String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
|
||||
//Object object = redisUtil.get(redisKey);
|
||||
////update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
//
|
||||
//if (object != null) {
|
||||
// result.setMessage("验证码10分钟内,仍然有效!");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------------
|
||||
////增加 check防止恶意刷短信接口
|
||||
//if (!DySmsLimit.canSendSms(clientIp)) {
|
||||
// log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp);
|
||||
// result.setMessage("短信接口请求太多,请稍后再试!");
|
||||
// result.setCode(CommonConstant.PHONE_SMS_FAIL_CODE);
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
//}
|
||||
////-------------------------------------------------------------------------------------
|
||||
//
|
||||
////随机数
|
||||
//String captcha = RandomUtil.randomNumbers(6);
|
||||
//JSONObject obj = new JSONObject();
|
||||
//obj.put("code", captcha);
|
||||
//try {
|
||||
// boolean b = false;
|
||||
// //注册模板
|
||||
// if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
|
||||
// SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
// if (sysUser != null) {
|
||||
// result.error500(" 手机号已经注册,请直接登录!");
|
||||
// baseCommonService.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
|
||||
// return result;
|
||||
// }
|
||||
// b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.REGISTER_TEMPLATE_CODE);
|
||||
// } else {
|
||||
// //登录模式,校验用户有效性
|
||||
// SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
// result = sysUserService.checkUserIsEffective(sysUser);
|
||||
// if (!result.isSuccess()) {
|
||||
// String message = result.getMessage();
|
||||
// String userNotExist = "该用户不存在,请注册";
|
||||
// if (userNotExist.equals(message)) {
|
||||
// result.error500("该用户不存在或未绑定手机号");
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * smsmode 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板
|
||||
// */
|
||||
// if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
|
||||
// //登录模板
|
||||
// b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
|
||||
// } else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
|
||||
// //忘记密码模板
|
||||
// b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.FORGET_PASSWORD_TEMPLATE_CODE);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (b == false) {
|
||||
// result.setMessage("短信验证码发送失败,请稍后重试");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
// //验证码10分钟内有效
|
||||
// redisUtil.set(redisKey, captcha, 600);
|
||||
// //update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
//
|
||||
// //update-begin--Author:scott Date:20190812 for:issues#391
|
||||
// //result.setResult(captcha);
|
||||
// //update-end--Author:scott Date:20190812 for:issues#391
|
||||
// result.setSuccess(true);
|
||||
//
|
||||
//} catch (ClientException e) {
|
||||
// e.printStackTrace();
|
||||
// result.error500(" 短信接口未配置,请联系管理员!");
|
||||
// return result;
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -759,46 +759,46 @@ public class LoginController {
|
||||
@PostMapping(value = "/sendChangePwdSms")
|
||||
public Result<String> sendSms(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<>();
|
||||
String mobile = jsonObject.get("mobile").toString();
|
||||
if (oConvertUtils.isEmpty(mobile)) {
|
||||
result.setMessage("手机号不允许为空!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String username = sysUser.getUsername();
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUser::getUsername, username).eq(SysUser::getPhone, mobile);
|
||||
SysUser user = sysUserService.getOne(query);
|
||||
if (null == user) {
|
||||
return Result.error("当前登录用户和绑定的手机号不匹配,无法修改密码!");
|
||||
}
|
||||
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
|
||||
Object object = redisUtil.get(redisKey);
|
||||
if (object != null) {
|
||||
result.setMessage("验证码10分钟内,仍然有效!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
//随机数
|
||||
String captcha = RandomUtil.randomNumbers(6);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", captcha);
|
||||
try {
|
||||
boolean b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.CHANGE_PASSWORD_TEMPLATE_CODE);
|
||||
if (!b) {
|
||||
result.setMessage("短信验证码发送失败,请稍后重试");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
//验证码5分钟内有效
|
||||
redisUtil.set(redisKey, captcha, 300);
|
||||
result.setSuccess(true);
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
result.error500(" 短信接口未配置,请联系管理员!");
|
||||
return result;
|
||||
}
|
||||
//String mobile = jsonObject.get("mobile").toString();
|
||||
//if (oConvertUtils.isEmpty(mobile)) {
|
||||
// result.setMessage("手机号不允许为空!");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
//}
|
||||
//LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//String username = sysUser.getUsername();
|
||||
//LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
//query.eq(SysUser::getUsername, username).eq(SysUser::getPhone, mobile);
|
||||
//SysUser user = sysUserService.getOne(query);
|
||||
//if (null == user) {
|
||||
// return Result.error("当前登录用户和绑定的手机号不匹配,无法修改密码!");
|
||||
//}
|
||||
//String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
|
||||
//Object object = redisUtil.get(redisKey);
|
||||
//if (object != null) {
|
||||
// result.setMessage("验证码10分钟内,仍然有效!");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
//}
|
||||
////随机数
|
||||
//String captcha = RandomUtil.randomNumbers(6);
|
||||
//JSONObject obj = new JSONObject();
|
||||
//obj.put("code", captcha);
|
||||
//try {
|
||||
// boolean b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.CHANGE_PASSWORD_TEMPLATE_CODE);
|
||||
// if (!b) {
|
||||
// result.setMessage("短信验证码发送失败,请稍后重试");
|
||||
// result.setSuccess(false);
|
||||
// return result;
|
||||
// }
|
||||
// //验证码5分钟内有效
|
||||
// redisUtil.set(redisKey, captcha, 300);
|
||||
// result.setSuccess(true);
|
||||
//} catch (ClientException e) {
|
||||
// e.printStackTrace();
|
||||
// result.error500(" 短信接口未配置,请联系管理员!");
|
||||
// return result;
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jeecg.dingtalk.api.core.response.Response;
|
||||
//import com.jeecg.dingtalk.api.core.response.Response;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -29,8 +29,8 @@ import org.jeecg.modules.system.entity.SysAnnouncementSend;
|
||||
import org.jeecg.modules.system.service.ISysAnnouncementSendService;
|
||||
import org.jeecg.modules.system.service.ISysAnnouncementService;
|
||||
import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
//import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
//import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
import org.jeecg.modules.system.util.XssUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
@@ -77,10 +77,10 @@ public class SysAnnouncementController {
|
||||
private ISysAnnouncementSendService sysAnnouncementSendService;
|
||||
@Resource
|
||||
private WebSocket webSocket;
|
||||
@Autowired
|
||||
ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
@Autowired
|
||||
ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
//@Autowired
|
||||
//ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
//@Autowired
|
||||
//ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
@Autowired
|
||||
private SysBaseApiImpl sysBaseApi;
|
||||
@Autowired
|
||||
@@ -288,14 +288,14 @@ public class SysAnnouncementController {
|
||||
}
|
||||
try {
|
||||
// 同步企业微信、钉钉的消息通知
|
||||
Response<String> dtResponse = dingtalkService.sendActionCardMessage(sysAnnouncement, null, true);
|
||||
wechatEnterpriseService.sendTextCardMessage(sysAnnouncement, true);
|
||||
|
||||
if (dtResponse != null && dtResponse.isSuccess()) {
|
||||
String taskId = dtResponse.getResult();
|
||||
sysAnnouncement.setDtTaskId(taskId);
|
||||
sysAnnouncementService.updateById(sysAnnouncement);
|
||||
}
|
||||
//Response<String> dtResponse = dingtalkService.sendActionCardMessage(sysAnnouncement, null, true);
|
||||
//wechatEnterpriseService.sendTextCardMessage(sysAnnouncement, true);
|
||||
//
|
||||
//if (dtResponse != null && dtResponse.isSuccess()) {
|
||||
// String taskId = dtResponse.getResult();
|
||||
// sysAnnouncement.setDtTaskId(taskId);
|
||||
// sysAnnouncementService.updateById(sysAnnouncement);
|
||||
//}
|
||||
} catch (Exception e) {
|
||||
log.error("同步发送第三方APP消息失败:", e);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public class SysAnnouncementController {
|
||||
result.success("该系统通知撤销成功");
|
||||
if (oConvertUtils.isNotEmpty(sysAnnouncement.getDtTaskId())) {
|
||||
try {
|
||||
dingtalkService.recallMessage(sysAnnouncement.getDtTaskId());
|
||||
//dingtalkService.recallMessage(sysAnnouncement.getDtTaskId());
|
||||
} catch (Exception e) {
|
||||
log.error("第三方APP撤回消息失败:", e);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,9 +41,9 @@ import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.message.entity.SysMessageTemplate;
|
||||
import org.jeecg.modules.message.handle.impl.DdSendMsgHandle;
|
||||
import org.jeecg.modules.message.handle.impl.EmailSendMsgHandle;
|
||||
import org.jeecg.modules.message.handle.impl.QywxSendMsgHandle;
|
||||
//import org.jeecg.modules.message.handle.impl.DdSendMsgHandle;
|
||||
//import org.jeecg.modules.message.handle.impl.EmailSendMsgHandle;
|
||||
//import org.jeecg.modules.message.handle.impl.QywxSendMsgHandle;
|
||||
import org.jeecg.modules.message.handle.impl.SystemSendMsgHandle;
|
||||
import org.jeecg.modules.message.service.ISysMessageTemplateService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
@@ -115,10 +115,10 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
private SysPermissionMapper sysPermissionMapper;
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
@Autowired
|
||||
private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
@Autowired
|
||||
private ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
//@Autowired
|
||||
//private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
//@Autowired
|
||||
//private ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
@Autowired
|
||||
ISysCategoryService sysCategoryService;
|
||||
@Autowired
|
||||
@@ -425,8 +425,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
message.getCategory());
|
||||
try {
|
||||
// 同步发送第三方APP消息
|
||||
wechatEnterpriseService.sendMessage(message, true);
|
||||
dingtalkService.sendMessage(message, true);
|
||||
//wechatEnterpriseService.sendMessage(message, true);
|
||||
//dingtalkService.sendMessage(message, true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步发送第三方APP消息失败!", e);
|
||||
}
|
||||
@@ -443,8 +443,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
message.getBusId());
|
||||
try {
|
||||
// 同步发送第三方APP消息
|
||||
wechatEnterpriseService.sendMessage(message, true);
|
||||
dingtalkService.sendMessage(message, true);
|
||||
//wechatEnterpriseService.sendMessage(message, true);
|
||||
//dingtalkService.sendMessage(message, true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步发送第三方APP消息失败!", e);
|
||||
}
|
||||
@@ -516,8 +516,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
try {
|
||||
// 同步企业微信、钉钉的消息通知
|
||||
dingtalkService.sendActionCardMessage(announcement, mobileOpenUrl, true);
|
||||
wechatEnterpriseService.sendTextCardMessage(announcement, true);
|
||||
//dingtalkService.sendActionCardMessage(announcement, mobileOpenUrl, true);
|
||||
//wechatEnterpriseService.sendTextCardMessage(announcement, true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步发送第三方APP消息失败!", e);
|
||||
}
|
||||
@@ -601,9 +601,9 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
try {
|
||||
// 钉钉的消息通知
|
||||
dingtalkService.sendActionCardMessage(announcement, mobileOpenUrl, true);
|
||||
//dingtalkService.sendActionCardMessage(announcement, mobileOpenUrl, true);
|
||||
// 企业微信通知
|
||||
wechatEnterpriseService.sendTextCardMessage(announcement, true);
|
||||
//wechatEnterpriseService.sendTextCardMessage(announcement, true);
|
||||
} catch (Exception e) {
|
||||
log.error("同步发送第三方APP消息失败!", e);
|
||||
}
|
||||
@@ -1388,8 +1388,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
*/
|
||||
@Override
|
||||
public void sendEmailMsg(String email, String title, String content) {
|
||||
EmailSendMsgHandle emailHandle = new EmailSendMsgHandle();
|
||||
emailHandle.sendMsg(email, title, content);
|
||||
//EmailSendMsgHandle emailHandle = new EmailSendMsgHandle();
|
||||
//emailHandle.sendMsg(email, title, content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1402,31 +1402,31 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
*/
|
||||
@Override
|
||||
public void sendHtmlTemplateEmail(String email, String title, EmailTemplateEnum emailTemplateEnum, JSONObject params) {
|
||||
EmailSendMsgHandle emailHandle = new EmailSendMsgHandle();
|
||||
String htmlText = "";
|
||||
try {
|
||||
//获取模板实例
|
||||
Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
|
||||
//设置模板文件的目录
|
||||
String url = emailTemplateEnum.getUrl();
|
||||
configuration.setClassForTemplateLoading(this.getClass(), url.substring(0, url.lastIndexOf("/")));
|
||||
configuration.setDefaultEncoding("UTF-8");
|
||||
//空值报错设置
|
||||
configuration.setClassicCompatible(true);
|
||||
configuration.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
|
||||
Template template = configuration.getTemplate(url.substring(url.lastIndexOf("/")));
|
||||
//解析模板文件
|
||||
htmlText = FreeMarkerTemplateUtils.processTemplateIntoString(template, params);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (TemplateException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.info("Email Html Text:{}", htmlText);
|
||||
emailHandle.sendMsg(email, title, htmlText);
|
||||
//EmailSendMsgHandle emailHandle = new EmailSendMsgHandle();
|
||||
//String htmlText = "";
|
||||
//try {
|
||||
// //获取模板实例
|
||||
// Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
|
||||
// //设置模板文件的目录
|
||||
// String url = emailTemplateEnum.getUrl();
|
||||
// configuration.setClassForTemplateLoading(this.getClass(), url.substring(0, url.lastIndexOf("/")));
|
||||
// configuration.setDefaultEncoding("UTF-8");
|
||||
// //空值报错设置
|
||||
// configuration.setClassicCompatible(true);
|
||||
// configuration.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
|
||||
// Template template = configuration.getTemplate(url.substring(url.lastIndexOf("/")));
|
||||
// //解析模板文件
|
||||
// htmlText = FreeMarkerTemplateUtils.processTemplateIntoString(template, params);
|
||||
//} catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
//} catch (TemplateException e) {
|
||||
// e.printStackTrace();
|
||||
//} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
//}
|
||||
//
|
||||
//log.info("Email Html Text:{}", htmlText);
|
||||
//emailHandle.sendMsg(email, title, htmlText);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1570,17 +1570,17 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
//update-end---author:chenrui ---date:20231221 for:[issues/#5643]解决分布式下表字典跨库无法查询问题------------
|
||||
|
||||
//-------------------------------------流程节点发送模板消息-----------------------------------------------
|
||||
@Autowired
|
||||
private QywxSendMsgHandle qywxSendMsgHandle;
|
||||
//@Autowired
|
||||
//private QywxSendMsgHandle qywxSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private SystemSendMsgHandle systemSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private EmailSendMsgHandle emailSendMsgHandle;
|
||||
//@Autowired
|
||||
//private EmailSendMsgHandle emailSendMsgHandle;
|
||||
|
||||
@Autowired
|
||||
private DdSendMsgHandle ddSendMsgHandle;
|
||||
//@Autowired
|
||||
//private DdSendMsgHandle ddSendMsgHandle;
|
||||
|
||||
@Override
|
||||
public void sendTemplateMessage(MessageDTO message) {
|
||||
@@ -1615,11 +1615,11 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
// 邮件消息要解析Markdown
|
||||
message.setContent(HTMLUtils.parseMarkdown(message.getContent()));
|
||||
}
|
||||
emailSendMsgHandle.sendMessage(message);
|
||||
//emailSendMsgHandle.sendMessage(message);
|
||||
} else if (MessageTypeEnum.DD.getType().equals(messageType)) {
|
||||
ddSendMsgHandle.sendMessage(message);
|
||||
//ddSendMsgHandle.sendMessage(message);
|
||||
} else if (MessageTypeEnum.QYWX.getType().equals(messageType)) {
|
||||
qywxSendMsgHandle.sendMessage(message);
|
||||
//qywxSendMsgHandle.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
|
||||
import com.jeecg.dingtalk.api.core.response.Response;
|
||||
import com.jeecg.dingtalk.api.core.vo.AccessToken;
|
||||
import com.jeecg.dingtalk.api.user.JdtUserAPI;
|
||||
//import com.jeecg.dingtalk.api.base.JdtBaseAPI;
|
||||
//import com.jeecg.dingtalk.api.core.response.Response;
|
||||
//import com.jeecg.dingtalk.api.core.vo.AccessToken;
|
||||
//import com.jeecg.dingtalk.api.user.JdtUserAPI;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@@ -169,13 +169,13 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
|
||||
//update-begin---author:wangshuai ---date:20230306 for:判断如果是钉钉的情况下,需要将第三方的用户id查询出来,发送模板的时候有用------------
|
||||
//=============begin 判断如果是钉钉的情况下,需要将第三方的用户id查询出来,发送模板的时候有用==========
|
||||
if (CommonConstant.DINGTALK.toLowerCase().equals(tlm.getSource())) {
|
||||
AccessToken accessToken = JdtBaseAPI.getAccessToken(dingTalkClientId, dingTalkClientSecret);
|
||||
Response<String> getUserIdRes = JdtUserAPI.getUseridByUnionid(tlm.getUuid(), accessToken.getAccessToken());
|
||||
if (getUserIdRes.isSuccess()) {
|
||||
user.setThirdUserId(getUserIdRes.getResult());
|
||||
} else {
|
||||
user.setThirdUserId(tlm.getUuid());
|
||||
}
|
||||
//AccessToken accessToken = JdtBaseAPI.getAccessToken(dingTalkClientId, dingTalkClientSecret);
|
||||
//Response<String> getUserIdRes = JdtUserAPI.getUseridByUnionid(tlm.getUuid(), accessToken.getAccessToken());
|
||||
//if (getUserIdRes.isSuccess()) {
|
||||
// user.setThirdUserId(getUserIdRes.getResult());
|
||||
//} else {
|
||||
// user.setThirdUserId(tlm.getUuid());
|
||||
//}
|
||||
//=============end 判断如果是钉钉的情况下,需要将第三方的用户id查询出来,发送模板的时候有用==========
|
||||
} else {
|
||||
user.setThirdUserId(tlm.getUuid());
|
||||
|
||||
@@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
//import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -102,10 +102,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
private BaseCommonService baseCommonService;
|
||||
@Autowired
|
||||
private SysThirdAccountMapper sysThirdAccountMapper;
|
||||
@Autowired
|
||||
ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
@Autowired
|
||||
ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
//@Autowired
|
||||
//ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService;
|
||||
//@Autowired
|
||||
//ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
@Autowired
|
||||
ISysRoleIndexService sysRoleIndexService;
|
||||
@Autowired
|
||||
@@ -710,8 +710,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds));
|
||||
//4.同步删除第三方App的用户
|
||||
try {
|
||||
dingtalkService.removeThirdAppUser(userIds);
|
||||
wechatEnterpriseService.removeThirdAppUser(userIds);
|
||||
//dingtalkService.removeThirdAppUser(userIds);
|
||||
//wechatEnterpriseService.removeThirdAppUser(userIds);
|
||||
} catch (Exception e) {
|
||||
log.error("同步删除第三方App的用户失败:", e);
|
||||
}
|
||||
@@ -2010,33 +2010,33 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @param phone
|
||||
*/
|
||||
private void sendPhoneSms(String phone, String clientIp) {
|
||||
String redisKey = CommonConstant.CHANGE_PHONE_REDIS_KEY_PRE + phone;
|
||||
Object object = redisUtil.get(redisKey);
|
||||
|
||||
if (object != null) {
|
||||
throw new JeecgBootException("验证码10分钟内,仍然有效!");
|
||||
}
|
||||
|
||||
//增加 check防止恶意刷短信接口
|
||||
if (!DySmsLimit.canSendSms(clientIp)) {
|
||||
log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp);
|
||||
throw new JeecgBootException("短信接口请求太多,请稍后再试!", CommonConstant.PHONE_SMS_FAIL_CODE);
|
||||
}
|
||||
|
||||
//随机数
|
||||
String captcha = RandomUtil.randomNumbers(6);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", captcha);
|
||||
try {
|
||||
boolean sendSmsSuccess = DySmsHelper.sendSms(phone, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
|
||||
if (!sendSmsSuccess) {
|
||||
throw new JeecgBootException("短信验证码发送失败,请稍后重试!");
|
||||
}
|
||||
//验证码10分钟内有效
|
||||
redisUtil.set(redisKey, captcha, 600);
|
||||
} catch (ClientException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new JeecgBootException("短信接口未配置,请联系管理员!");
|
||||
}
|
||||
//String redisKey = CommonConstant.CHANGE_PHONE_REDIS_KEY_PRE + phone;
|
||||
//Object object = redisUtil.get(redisKey);
|
||||
//
|
||||
//if (object != null) {
|
||||
// throw new JeecgBootException("验证码10分钟内,仍然有效!");
|
||||
//}
|
||||
//
|
||||
////增加 check防止恶意刷短信接口
|
||||
//if (!DySmsLimit.canSendSms(clientIp)) {
|
||||
// log.warn("--------[警告] IP地址:{}, 短信接口请求太多-------", clientIp);
|
||||
// throw new JeecgBootException("短信接口请求太多,请稍后再试!", CommonConstant.PHONE_SMS_FAIL_CODE);
|
||||
//}
|
||||
//
|
||||
////随机数
|
||||
//String captcha = RandomUtil.randomNumbers(6);
|
||||
//JSONObject obj = new JSONObject();
|
||||
//obj.put("code", captcha);
|
||||
//try {
|
||||
// boolean sendSmsSuccess = DySmsHelper.sendSms(phone, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
|
||||
// if (!sendSmsSuccess) {
|
||||
// throw new JeecgBootException("短信验证码发送失败,请稍后重试!");
|
||||
// }
|
||||
// //验证码10分钟内有效
|
||||
// redisUtil.set(redisKey, captcha, 600);
|
||||
//} catch (ClientException e) {
|
||||
// log.error(e.getMessage(), e);
|
||||
// throw new JeecgBootException("短信接口未配置,请联系管理员!");
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,89 +1,89 @@
|
||||
package org.jeecg.modules.system.vo.thirdapp;
|
||||
|
||||
import com.jeecg.dingtalk.api.department.vo.Department;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 钉钉树结构的部门
|
||||
*
|
||||
* @author sunjianlei
|
||||
*/
|
||||
public class JdtDepartmentTreeVo extends Department {
|
||||
|
||||
private List<JdtDepartmentTreeVo> children;
|
||||
|
||||
public List<JdtDepartmentTreeVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public JdtDepartmentTreeVo setChildren(List<JdtDepartmentTreeVo> children) {
|
||||
this.children = children;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JdtDepartmentTreeVo(Department department) {
|
||||
BeanUtils.copyProperties(department, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有子项
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return children != null && children.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JwDepartmentTree{" +
|
||||
"children=" + children +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态辅助方法,将list转为tree结构
|
||||
*/
|
||||
public static List<JdtDepartmentTreeVo> listToTree(List<Department> allDepartment) {
|
||||
// 先找出所有的父级
|
||||
List<JdtDepartmentTreeVo> treeList = getByParentId(1, allDepartment);
|
||||
Optional<Department> departmentOptional = allDepartment.stream().filter(item -> item.getParent_id() == null).findAny();
|
||||
Department department = new Department();
|
||||
//判断是否找到数据
|
||||
if (departmentOptional.isPresent()) {
|
||||
department = departmentOptional.get();
|
||||
}
|
||||
getChildrenRecursion(treeList, allDepartment);
|
||||
//update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
JdtDepartmentTreeVo treeVo = new JdtDepartmentTreeVo(department);
|
||||
treeVo.setChildren(treeList);
|
||||
List<JdtDepartmentTreeVo> list = new ArrayList<>();
|
||||
list.add(treeVo);
|
||||
return list;
|
||||
//update-end---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
}
|
||||
|
||||
private static List<JdtDepartmentTreeVo> getByParentId(Integer parentId, List<Department> allDepartment) {
|
||||
List<JdtDepartmentTreeVo> list = new ArrayList<>();
|
||||
for (Department department : allDepartment) {
|
||||
if (parentId.equals(department.getParent_id())) {
|
||||
list.add(new JdtDepartmentTreeVo(department));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void getChildrenRecursion(List<JdtDepartmentTreeVo> treeList, List<Department> allDepartment) {
|
||||
for (JdtDepartmentTreeVo departmentTree : treeList) {
|
||||
// 递归寻找子级
|
||||
List<JdtDepartmentTreeVo> children = getByParentId(departmentTree.getDept_id(), allDepartment);
|
||||
if (children.size() > 0) {
|
||||
departmentTree.setChildren(children);
|
||||
getChildrenRecursion(children, allDepartment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.modules.system.vo.thirdapp;
|
||||
//
|
||||
//import com.jeecg.dingtalk.api.department.vo.Department;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
///**
|
||||
// * 钉钉树结构的部门
|
||||
// *
|
||||
// * @author sunjianlei
|
||||
// */
|
||||
//public class JdtDepartmentTreeVo extends Department {
|
||||
//
|
||||
// private List<JdtDepartmentTreeVo> children;
|
||||
//
|
||||
// public List<JdtDepartmentTreeVo> getChildren() {
|
||||
// return children;
|
||||
// }
|
||||
//
|
||||
// public JdtDepartmentTreeVo setChildren(List<JdtDepartmentTreeVo> children) {
|
||||
// this.children = children;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public JdtDepartmentTreeVo(Department department) {
|
||||
// BeanUtils.copyProperties(department, this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 是否有子项
|
||||
// */
|
||||
// public boolean hasChildren() {
|
||||
// return children != null && children.size() > 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "JwDepartmentTree{" +
|
||||
// "children=" + children +
|
||||
// "} " + super.toString();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 静态辅助方法,将list转为tree结构
|
||||
// */
|
||||
// public static List<JdtDepartmentTreeVo> listToTree(List<Department> allDepartment) {
|
||||
// // 先找出所有的父级
|
||||
// List<JdtDepartmentTreeVo> treeList = getByParentId(1, allDepartment);
|
||||
// Optional<Department> departmentOptional = allDepartment.stream().filter(item -> item.getParent_id() == null).findAny();
|
||||
// Department department = new Department();
|
||||
// //判断是否找到数据
|
||||
// if (departmentOptional.isPresent()) {
|
||||
// department = departmentOptional.get();
|
||||
// }
|
||||
// getChildrenRecursion(treeList, allDepartment);
|
||||
// //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
// JdtDepartmentTreeVo treeVo = new JdtDepartmentTreeVo(department);
|
||||
// treeVo.setChildren(treeList);
|
||||
// List<JdtDepartmentTreeVo> list = new ArrayList<>();
|
||||
// list.add(treeVo);
|
||||
// return list;
|
||||
// //update-end---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
// }
|
||||
//
|
||||
// private static List<JdtDepartmentTreeVo> getByParentId(Integer parentId, List<Department> allDepartment) {
|
||||
// List<JdtDepartmentTreeVo> list = new ArrayList<>();
|
||||
// for (Department department : allDepartment) {
|
||||
// if (parentId.equals(department.getParent_id())) {
|
||||
// list.add(new JdtDepartmentTreeVo(department));
|
||||
// }
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// private static void getChildrenRecursion(List<JdtDepartmentTreeVo> treeList, List<Department> allDepartment) {
|
||||
// for (JdtDepartmentTreeVo departmentTree : treeList) {
|
||||
// // 递归寻找子级
|
||||
// List<JdtDepartmentTreeVo> children = getByParentId(departmentTree.getDept_id(), allDepartment);
|
||||
// if (children.size() > 0) {
|
||||
// departmentTree.setChildren(children);
|
||||
// getChildrenRecursion(children, allDepartment);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
package org.jeecg.modules.system.vo.thirdapp;
|
||||
|
||||
import com.jeecg.qywx.api.department.vo.Department;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 企业微信树结构的部门
|
||||
*
|
||||
* @author sunjianlei
|
||||
*/
|
||||
public class JwDepartmentTreeVo extends Department {
|
||||
|
||||
private List<JwDepartmentTreeVo> children;
|
||||
|
||||
public List<JwDepartmentTreeVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public JwDepartmentTreeVo setChildren(List<JwDepartmentTreeVo> children) {
|
||||
this.children = children;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JwDepartmentTreeVo(Department department) {
|
||||
BeanUtils.copyProperties(department, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有子项
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return children != null && children.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JwDepartmentTree{" +
|
||||
"children=" + children +
|
||||
"} " + super.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态辅助方法,将list转为tree结构
|
||||
*/
|
||||
public static List<JwDepartmentTreeVo> listToTree(List<Department> allDepartment) {
|
||||
// 先找出所有的父级
|
||||
List<JwDepartmentTreeVo> treeList = getByParentId("1", allDepartment);
|
||||
Optional<Department> departmentOptional = allDepartment.stream().filter(item -> "0".equals(item.getParentid())).findAny();
|
||||
Department department = new Department();
|
||||
//判断是否找到数据
|
||||
if (departmentOptional.isPresent()) {
|
||||
department = departmentOptional.get();
|
||||
}
|
||||
getChildrenRecursion(treeList, allDepartment);
|
||||
//update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
JwDepartmentTreeVo treeVo = new JwDepartmentTreeVo(department);
|
||||
treeVo.setChildren(treeList);
|
||||
List<JwDepartmentTreeVo> list = new ArrayList<>();
|
||||
list.add(treeVo);
|
||||
return list;
|
||||
//update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
}
|
||||
|
||||
private static List<JwDepartmentTreeVo> getByParentId(String parentId, List<Department> allDepartment) {
|
||||
List<JwDepartmentTreeVo> list = new ArrayList<>();
|
||||
for (Department department : allDepartment) {
|
||||
if (parentId.equals(department.getParentid())) {
|
||||
list.add(new JwDepartmentTreeVo(department));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void getChildrenRecursion(List<JwDepartmentTreeVo> treeList, List<Department> allDepartment) {
|
||||
for (JwDepartmentTreeVo departmentTree : treeList) {
|
||||
// 递归寻找子级
|
||||
List<JwDepartmentTreeVo> children = getByParentId(departmentTree.getId(), allDepartment);
|
||||
if (children.size() > 0) {
|
||||
departmentTree.setChildren(children);
|
||||
getChildrenRecursion(children, allDepartment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg.modules.system.vo.thirdapp;
|
||||
//
|
||||
//import com.jeecg.qywx.api.department.vo.Department;
|
||||
//import org.springframework.beans.BeanUtils;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
///**
|
||||
// * 企业微信树结构的部门
|
||||
// *
|
||||
// * @author sunjianlei
|
||||
// */
|
||||
//public class JwDepartmentTreeVo extends Department {
|
||||
//
|
||||
// private List<JwDepartmentTreeVo> children;
|
||||
//
|
||||
// public List<JwDepartmentTreeVo> getChildren() {
|
||||
// return children;
|
||||
// }
|
||||
//
|
||||
// public JwDepartmentTreeVo setChildren(List<JwDepartmentTreeVo> children) {
|
||||
// this.children = children;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public JwDepartmentTreeVo(Department department) {
|
||||
// BeanUtils.copyProperties(department, this);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 是否有子项
|
||||
// */
|
||||
// public boolean hasChildren() {
|
||||
// return children != null && children.size() > 0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "JwDepartmentTree{" +
|
||||
// "children=" + children +
|
||||
// "} " + super.toString();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 静态辅助方法,将list转为tree结构
|
||||
// */
|
||||
// public static List<JwDepartmentTreeVo> listToTree(List<Department> allDepartment) {
|
||||
// // 先找出所有的父级
|
||||
// List<JwDepartmentTreeVo> treeList = getByParentId("1", allDepartment);
|
||||
// Optional<Department> departmentOptional = allDepartment.stream().filter(item -> "0".equals(item.getParentid())).findAny();
|
||||
// Department department = new Department();
|
||||
// //判断是否找到数据
|
||||
// if (departmentOptional.isPresent()) {
|
||||
// department = departmentOptional.get();
|
||||
// }
|
||||
// getChildrenRecursion(treeList, allDepartment);
|
||||
// //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
// JwDepartmentTreeVo treeVo = new JwDepartmentTreeVo(department);
|
||||
// treeVo.setChildren(treeList);
|
||||
// List<JwDepartmentTreeVo> list = new ArrayList<>();
|
||||
// list.add(treeVo);
|
||||
// return list;
|
||||
// //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信部门时没有最顶层的部门名,同步用户时,用户没有部门信息---
|
||||
// }
|
||||
//
|
||||
// private static List<JwDepartmentTreeVo> getByParentId(String parentId, List<Department> allDepartment) {
|
||||
// List<JwDepartmentTreeVo> list = new ArrayList<>();
|
||||
// for (Department department : allDepartment) {
|
||||
// if (parentId.equals(department.getParentid())) {
|
||||
// list.add(new JwDepartmentTreeVo(department));
|
||||
// }
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// private static void getChildrenRecursion(List<JwDepartmentTreeVo> treeList, List<Department> allDepartment) {
|
||||
// for (JwDepartmentTreeVo departmentTree : treeList) {
|
||||
// // 递归寻找子级
|
||||
// List<JwDepartmentTreeVo> children = getByParentId(departmentTree.getId(), allDepartment);
|
||||
// if (children.size() > 0) {
|
||||
// departmentTree.setChildren(children);
|
||||
// getChildrenRecursion(children, allDepartment);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
236
pom.xml
236
pom.xml
@@ -215,17 +215,17 @@
|
||||
<version>${jeecgboot.version}</version>
|
||||
</dependency>
|
||||
<!--rabbitmq消息队列-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>physical-boot-starter3-rabbitmq</artifactId>
|
||||
<version>${jeecgboot.version}</version>
|
||||
</dependency>
|
||||
<!--rocketmq-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>physical-boot-starter3-rocketmq</artifactId>
|
||||
<version>${jeecgboot.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot</groupId>-->
|
||||
<!-- <artifactId>physical-boot-starter3-rabbitmq</artifactId>-->
|
||||
<!-- <version>${jeecgboot.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!–rocketmq–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot</groupId>-->
|
||||
<!-- <artifactId>physical-boot-starter3-rocketmq</artifactId>-->
|
||||
<!-- <version>${jeecgboot.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!--分库分表shardingsphere-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
@@ -243,11 +243,11 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot3</groupId>
|
||||
<artifactId>hibernate-re</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot3</groupId>-->
|
||||
<!-- <artifactId>hibernate-re</artifactId>-->
|
||||
<!-- <version>3.7.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- update-begin-author:chenrui -date:20240104 for:[issue/5723]指定jaxb-runtime版本 -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
@@ -256,42 +256,42 @@
|
||||
</dependency>
|
||||
<!-- update-end-author:chenrui -date:20240104 for:[issue/5723]指定jaxb-runtime版本 -->
|
||||
|
||||
<!--mongon db-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>physical-boot-starter3-mongon</artifactId>
|
||||
<version>${jeecgboot.version}</version>
|
||||
</dependency>
|
||||
<!--人大金仓驱动 版本号V008R006C005B0013 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>kingbase8</artifactId>
|
||||
<version>9.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--达梦8数据库最新驱动 版本号1-3-26-2023.07.26-197096-20046-ENT -->
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>Dm8JdbcDriver18</artifactId>
|
||||
<version>8.1.1.49</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmDialect-for-hibernate5.0</artifactId>
|
||||
<version>8.1.1.49</version>
|
||||
</dependency>
|
||||
<!-- <!–mongon db–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.boot</groupId>-->
|
||||
<!-- <artifactId>physical-boot-starter3-mongon</artifactId>-->
|
||||
<!-- <version>${jeecgboot.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!–人大金仓驱动 版本号V008R006C005B0013 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework</groupId>-->
|
||||
<!-- <artifactId>kingbase8</artifactId>-->
|
||||
<!-- <version>9.0.0</version>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!–达梦8数据库最新驱动 版本号1-3-26-2023.07.26-197096-20046-ENT –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.dameng</groupId>-->
|
||||
<!-- <artifactId>Dm8JdbcDriver18</artifactId>-->
|
||||
<!-- <version>8.1.1.49</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.dameng</groupId>-->
|
||||
<!-- <artifactId>DmDialect-for-hibernate5.0</artifactId>-->
|
||||
<!-- <version>8.1.1.49</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 七牛云SDK -->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>${qiniu-java-sdk.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.qiniu</groupId>-->
|
||||
<!-- <artifactId>qiniu-java-sdk</artifactId>-->
|
||||
<!-- <version>${qiniu-java-sdk.version}</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>okhttp</artifactId>-->
|
||||
<!-- <groupId>com.squareup.okhttp3</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- dom4j -->
|
||||
<dependency>
|
||||
<groupId>dom4j</groupId>
|
||||
@@ -312,21 +312,21 @@
|
||||
</dependency>
|
||||
|
||||
<!-- justauth第三方登录 -->
|
||||
<dependency>
|
||||
<groupId>com.xkcoding.justauth</groupId>
|
||||
<artifactId>justauth-spring-boot-starter</artifactId>
|
||||
<version>${justauth-spring-boot-starter.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<groupId>cn.hutool</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.xkcoding.justauth</groupId>-->
|
||||
<!-- <artifactId>justauth-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>${justauth-spring-boot-starter.version}</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>hutool-core</artifactId>-->
|
||||
<!-- <groupId>cn.hutool</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>fastjson</artifactId>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
@@ -365,62 +365,62 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 企业微信和钉钉 api -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>jeewx-api</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>commons-collections</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework</groupId>-->
|
||||
<!-- <artifactId>jeewx-api</artifactId>-->
|
||||
<!-- <version>1.5.2</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>commons-beanutils</artifactId>-->
|
||||
<!-- <groupId>commons-beanutils</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>commons-lang</artifactId>-->
|
||||
<!-- <groupId>commons-lang</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>commons-collections</artifactId>-->
|
||||
<!-- <groupId>commons-collections</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>commons-logging</artifactId>-->
|
||||
<!-- <groupId>commons-logging</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>commons-io</artifactId>-->
|
||||
<!-- <groupId>commons-io</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 积木报表-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimureport-spring-boot3-starter-fastjson2</artifactId>
|
||||
<version>${jimureport-spring-boot-starter.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>autopoi-web</artifactId>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>druid</artifactId>
|
||||
<groupId>com.alibaba</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimureport-nosql-starter</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.jimureport</groupId>-->
|
||||
<!-- <artifactId>jimureport-spring-boot3-starter-fastjson2</artifactId>-->
|
||||
<!-- <version>${jimureport-spring-boot-starter.version}</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>autopoi-web</artifactId>-->
|
||||
<!-- <groupId>org.jeecgframework</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>druid</artifactId>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.jeecgframework.jimureport</groupId>-->
|
||||
<!-- <artifactId>jimureport-nosql-starter</artifactId>-->
|
||||
<!-- <version>1.6.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--flyway 支持 mysql5.7+、MariaDB10.3.16-->
|
||||
<!--mysql5.6,需要把版本号改成5.2.1-->
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>7.15.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.flywaydb</groupId>-->
|
||||
<!-- <artifactId>flyway-core</artifactId>-->
|
||||
<!-- <version>7.15.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user