bug修复
This commit is contained in:
@@ -58,7 +58,7 @@ public class CacheConstants
|
||||
/**
|
||||
* 用户邮箱 redis key
|
||||
*/
|
||||
public static final String USER_EMAIL_KEY = "user_email_key:";
|
||||
// public static final String USER_EMAIL_KEY = "user_email_key:";
|
||||
/**
|
||||
* 角色 redis key
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@ public enum AnnexTypeEnum implements EnumsInterface {
|
||||
RES_PAYMENT_RECEIPT(9, "被申请人缴费单"),
|
||||
SEAL_PICTURE(10, "印章图片"),
|
||||
FLOW_SVG(11, "流程节点SVG"),
|
||||
MEETING_FILE(12, "被申请人证据"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
import com.ruoyi.common.interfaces.EnumsInterface;
|
||||
|
||||
/**
|
||||
* @author wangqiong
|
||||
* @description 短信状态枚举
|
||||
* @date 2023-11-17 14:05
|
||||
*/
|
||||
public enum SMSStatusEnum implements EnumsInterface
|
||||
{
|
||||
SUCCESS(1, "成功"),
|
||||
SENDING(2, "发送中"),
|
||||
FAIL(3, "失败"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
SMSStatusEnum(Integer code, String text)
|
||||
{
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取text
|
||||
* @param codeNo
|
||||
* @return
|
||||
*/
|
||||
public static String getTextByCode(Integer codeNo){
|
||||
for (SMSStatusEnum value : SMSStatusEnum.values()) {
|
||||
if (value.getCode().equals(codeNo)){
|
||||
return value.getText();
|
||||
}
|
||||
}
|
||||
return codeNo.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据text获取code
|
||||
* @param textStr
|
||||
* @return
|
||||
*/
|
||||
public static String getCodeByText(String textStr){
|
||||
for (SMSStatusEnum value : SMSStatusEnum.values()) {
|
||||
if (value.getText().equals(textStr)){
|
||||
return value.getText();
|
||||
}
|
||||
}
|
||||
return textStr;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
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;
|
||||
@@ -24,7 +26,8 @@ public class SmsUtils {
|
||||
//签名内容
|
||||
private static final String SIGN_NAME = "乙巢智慧仲裁网";
|
||||
|
||||
public static Boolean sendSms(SendSmsRequest request) {
|
||||
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");
|
||||
@@ -40,18 +43,23 @@ public class SmsUtils {
|
||||
res = client.SendSms(req);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.error("发送短信出错:", e);
|
||||
return Boolean.FALSE;
|
||||
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())){
|
||||
return Boolean.TRUE;
|
||||
jsonObject.set("status", SMSStatusEnum.SENDING.getCode());
|
||||
}else {
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
jsonObject.set("sid", sendStatus.getSerialNo());
|
||||
return jsonObject;
|
||||
}
|
||||
public static Boolean sendSms(Long caseId,String templateId,String phone,String[] templateParamSet) {
|
||||
SendSmsRequest request = new SendSmsRequest(phone,templateId,templateParamSet,caseId);
|
||||
public static JSONObject sendSms(Long caseId,String templateId,String phone,String[] templateParamSet) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
SmsUtils1.SendSmsRequest request = new SmsUtils1.SendSmsRequest(phone,templateId,templateParamSet,caseId);
|
||||
Credential cred = new Credential(SECRET_ID, SECRET_KEY );
|
||||
|
||||
SmsClient client = new SmsClient(cred, "ap-guangzhou");
|
||||
@@ -66,16 +74,19 @@ public class SmsUtils {
|
||||
try {
|
||||
res = client.SendSms(req);
|
||||
} catch (TencentCloudSDKException e) {
|
||||
log.error("发送短信出错:", e);
|
||||
return Boolean.FALSE;
|
||||
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())){
|
||||
return Boolean.TRUE;
|
||||
jsonObject.set("status", SMSStatusEnum.SENDING.getCode());
|
||||
}else {
|
||||
jsonObject.set("status", SMSStatusEnum.FAIL.getCode());
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
jsonObject.set("sid", sendStatus.getSerialNo());
|
||||
return jsonObject;
|
||||
}
|
||||
/**
|
||||
* 参数对象
|
||||
|
||||
Reference in New Issue
Block a user