功能优化
This commit is contained in:
@@ -47,6 +47,7 @@ public class CacheConstants
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
public static final String WE_CHAT_SMS_VERIFY_CODE_KEY="we_chat_sms_verify_code:";
|
||||
public static final String EMAIL_VERIFY_CODE_KEY="email_verify_code:";
|
||||
/**
|
||||
* 案件 redis key
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ public class UserConstants
|
||||
* 用户名长度限制
|
||||
*/
|
||||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
public static final int USERNAME_MAX_LENGTH = 50;
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
|
||||
@@ -47,12 +47,12 @@ public class EmailOutUtil {
|
||||
// private static String fromOut;
|
||||
@Value("${spring.mail.host}")
|
||||
private String hostOut;
|
||||
// @Value("${spring.mail.username}")
|
||||
// private String usernameOut;
|
||||
private String usernameOut="wq18792927508@163.com";
|
||||
// @Value("${spring.mail.password}")
|
||||
// private String passwordOut;
|
||||
private String passwordOut= "WDFHKSEMCKVRELEA";
|
||||
@Value("${spring.mail.username}")
|
||||
private String usernameOut;
|
||||
|
||||
@Value("${spring.mail.password}")
|
||||
private String passwordOut;
|
||||
|
||||
@Value("${spring.mail.port}")
|
||||
private Integer portOut;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class EmailOutUtil {
|
||||
public Boolean sendMessage(String to, String subject, String content, String from, JavaMailSender mailSender) {
|
||||
try {
|
||||
if(mailSender==null){
|
||||
rebuildMailSender();
|
||||
mailSender= rebuildMailSender();
|
||||
}
|
||||
// 创建一个邮件对象
|
||||
SimpleMailMessage msg = new SimpleMailMessage();
|
||||
@@ -97,7 +97,6 @@ public class EmailOutUtil {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
////System.out.println("发送成功:" + from + ":to:" + to);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.ruoyi.common.enums.SMSStatusEnum;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||
import com.tencentcloudapi.sms.v20210111.models.SendStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.var;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class SmsUtils {
|
||||
//应用id
|
||||
private static final String SDK_APP_ID = "1400854852";
|
||||
//API的SecretId
|
||||
private static final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp";
|
||||
//API的SecretKey
|
||||
private static final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V";
|
||||
//签名内容
|
||||
private static final String SIGN_NAME = "乙巢智慧仲裁网";
|
||||
|
||||
public static JSONObject sendSms(SendSmsRequest request) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEY );
|
||||
|
||||
SmsClient client = new SmsClient(cred, "ap-guangzhou");
|
||||
|
||||
final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest();
|
||||
req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()});
|
||||
req.setSmsSdkAppId(SDK_APP_ID );
|
||||
req.setSignName(SIGN_NAME);
|
||||
req.setTemplateId(request.getTemplateId());
|
||||
req.setTemplateParamSet(request.getTemplateParamSet());
|
||||
SendSmsResponse res = null;
|
||||
try {
|
||||
res = client.SendSms(req);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.error("发送短信出错:", e);
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
return jsonObject;
|
||||
}
|
||||
SendStatus sendStatus = res.getSendStatusSet()[0];
|
||||
log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage());
|
||||
|
||||
if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){
|
||||
jsonObject.set("status", SMSStatusEnum.SENDING.getCode());
|
||||
}else {
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
}
|
||||
jsonObject.set("sid", sendStatus.getSerialNo());
|
||||
return jsonObject;
|
||||
}
|
||||
public static JSONObject sendSms(Long caseId,String templateId,String phone,String[] templateParamSet) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
SendSmsRequest request = new SendSmsRequest(phone,templateId,templateParamSet,caseId);
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEY );
|
||||
|
||||
SmsClient client = new SmsClient(cred, "ap-guangzhou");
|
||||
|
||||
final var req = new com.tencentcloudapi.sms.v20210111.models.SendSmsRequest();
|
||||
req.setPhoneNumberSet(new String[]{"+86" + request.getPhone()});
|
||||
req.setSmsSdkAppId(SDK_APP_ID );
|
||||
req.setSignName(SIGN_NAME);
|
||||
req.setTemplateId(request.getTemplateId());
|
||||
req.setTemplateParamSet(request.getTemplateParamSet());
|
||||
SendSmsResponse res = null;
|
||||
try {
|
||||
res = client.SendSms(req);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
return jsonObject;
|
||||
}
|
||||
SendStatus sendStatus = res.getSendStatusSet()[0];
|
||||
log.info("发送短信结果:Code={}, Message={}", sendStatus.getCode(), sendStatus.getMessage());
|
||||
// todo 短信发送时,需要将SerialNo存到数据库,在短信回调时去更新短信发送状态,以及失败原因写到数据库,发送时状态统一为发送中
|
||||
if (Objects.nonNull(res.getSendStatusSet()) && res.getSendStatusSet().length > 0 && "Ok".equals(res.getSendStatusSet()[0].getCode())){
|
||||
jsonObject.set("status", SMSStatusEnum.SENDING.getCode());
|
||||
}else {
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
}
|
||||
jsonObject.set("sid", sendStatus.getSerialNo());
|
||||
return jsonObject;
|
||||
}
|
||||
/**
|
||||
* 参数对象
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SendSmsRequest {
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 模板 ID: 必须填写已审核通过的模板 ID
|
||||
*/
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空
|
||||
*/
|
||||
private String[] templateParamSet;
|
||||
private Long caseId;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,19 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
|
||||
import cn.hutool.core.io.resource.ClassPathResource;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.deepoove.poi.config.Configure;
|
||||
import com.deepoove.poi.data.*;
|
||||
import com.deepoove.poi.data.style.ParagraphStyle;
|
||||
import com.deepoove.poi.data.style.Style;
|
||||
import com.deepoove.poi.policy.PictureRenderPolicy;
|
||||
import com.deepoove.poi.util.PoitlIOUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.wp.usermodel.Paragraph;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
|
||||
import javax.print.Doc;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -205,6 +198,24 @@ public class WordUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换标签内容
|
||||
* @param map
|
||||
* @param templatePath 模板路径
|
||||
* @param outputPath 文件输出路径
|
||||
*/
|
||||
public static void render(Map<String, Object> map,String templatePath,String outputPath){
|
||||
XWPFTemplate template = XWPFTemplate.compile(templatePath).render(map);
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(outputPath);
|
||||
template.write(out);
|
||||
out.flush();
|
||||
out.close();
|
||||
template.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user