mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	短信提交 2021-03-31,重构返回的结果
This commit is contained in:
		| @ -1,41 +0,0 @@ | |||||||
| package cn.iocoder.dashboard.common.exception; |  | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants; |  | ||||||
| import lombok.Data; |  | ||||||
| import lombok.EqualsAndHashCode; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * 全局异常 Exception |  | ||||||
|  */ |  | ||||||
| @Data |  | ||||||
| @EqualsAndHashCode(callSuper = true) |  | ||||||
| public class GlobalException extends RuntimeException { |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 全局错误码 |  | ||||||
|      * |  | ||||||
|      * @see GlobalErrorCodeConstants |  | ||||||
|      */ |  | ||||||
|     private Integer code; |  | ||||||
|     /** |  | ||||||
|      * 错误提示 |  | ||||||
|      */ |  | ||||||
|     private String message; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 空构造方法,避免反序列化问题 |  | ||||||
|      */ |  | ||||||
|     public GlobalException() { |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public GlobalException(ErrorCode errorCode) { |  | ||||||
|         this.code = errorCode.getCode(); |  | ||||||
|         this.message = errorCode.getMessage(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public GlobalException(Integer code, String message) { |  | ||||||
|         this.code = code; |  | ||||||
|         this.message = message; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,7 +1,6 @@ | |||||||
| package cn.iocoder.dashboard.common.pojo; | package cn.iocoder.dashboard.common.pojo; | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.common.exception.ErrorCode; | import cn.iocoder.dashboard.common.exception.ErrorCode; | ||||||
| import cn.iocoder.dashboard.common.exception.GlobalException; |  | ||||||
| import cn.iocoder.dashboard.common.exception.ServiceException; | import cn.iocoder.dashboard.common.exception.ServiceException; | ||||||
| import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants; | import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants; | ||||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | import com.fasterxml.jackson.annotation.JsonIgnore; | ||||||
| @ -16,7 +15,7 @@ import java.io.Serializable; | |||||||
|  * @param <T> 数据泛型 |  * @param <T> 数据泛型 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public final class CommonResult<T> implements Serializable { | public class CommonResult<T> implements Serializable { | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 错误码 |      * 错误码 | ||||||
| @ -81,16 +80,12 @@ public final class CommonResult<T> implements Serializable { | |||||||
|     // ========= 和 Exception 异常体系集成 ========= |     // ========= 和 Exception 异常体系集成 ========= | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 判断是否有异常。如果有,则抛出 {@link GlobalException} 或 {@link ServiceException} 异常 |      * 判断是否有异常。如果有,则抛出 {@link ServiceException} 异常 | ||||||
|      */ |      */ | ||||||
|     public void checkError() throws GlobalException, ServiceException { |     public void checkError() throws ServiceException { | ||||||
|         if (isSuccess()) { |         if (isSuccess()) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // 全局异常 |  | ||||||
|         if (GlobalErrorCodeConstants.isMatch(code)) { |  | ||||||
|             throw new GlobalException(code, msg); |  | ||||||
|         } |  | ||||||
|         // 业务异常 |         // 业务异常 | ||||||
|         throw new ServiceException(code, msg); |         throw new ServiceException(code, msg); | ||||||
|     } |     } | ||||||
| @ -99,8 +94,4 @@ public final class CommonResult<T> implements Serializable { | |||||||
|         return error(serviceException.getCode(), serviceException.getMessage()); |         return error(serviceException.getCode(), serviceException.getMessage()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static <T> CommonResult<T> error(GlobalException globalException) { |  | ||||||
|         return error(globalException.getCode(), globalException.getMessage()); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,9 +8,6 @@ package cn.iocoder.dashboard.framework.sms.core; | |||||||
|  */ |  */ | ||||||
| public interface SmsConstants { | public interface SmsConstants { | ||||||
|  |  | ||||||
|     String OK = "OK"; |  | ||||||
|  |  | ||||||
|     String JING_HAO = "#"; |  | ||||||
|  |  | ||||||
|     String COMMA = ","; |     String COMMA = ","; | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,77 +0,0 @@ | |||||||
| package cn.iocoder.dashboard.framework.sms.core; |  | ||||||
|  |  | ||||||
| import cn.hutool.core.exceptions.ExceptionUtil; |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| import java.io.Serializable; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * 消息内容实体类 |  | ||||||
|  */ |  | ||||||
| @Data |  | ||||||
| public class SmsResult implements Serializable { |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 是否成功 |  | ||||||
|      * |  | ||||||
|      * 注意,是调用 API 短信平台的请求是否成功 |  | ||||||
|      */ |  | ||||||
|     private Boolean success; |  | ||||||
|     /** |  | ||||||
|      * 发送失败的类型 |  | ||||||
|      * |  | ||||||
|      * 枚举 {@link SmsSendFailureTypeEnum#getType()} |  | ||||||
|      */ |  | ||||||
|     private Integer sendFailureType; |  | ||||||
|     /** |  | ||||||
|      * 发送失败的提示 |  | ||||||
|      * |  | ||||||
|      * 一般情况下,使用 {@link SmsSendFailureTypeEnum#getMsg()} |  | ||||||
|      * 异常情况下,通过格式化 Exception 的提示存储 |  | ||||||
|      */ |  | ||||||
|     private String sendFailureMsg; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 短信 API 发送的错误码 |  | ||||||
|      * |  | ||||||
|      * 由于第三方的错误码可能是字符串,所以使用 String 类型 |  | ||||||
|      */ |  | ||||||
|     private String apiSendCode; |  | ||||||
|     /** |  | ||||||
|      * 短信 API 发送的提示 |  | ||||||
|      */ |  | ||||||
|     private String apiSendMsg; |  | ||||||
|     /** |  | ||||||
|      * 短信 API 发送返回的唯一请求 ID |  | ||||||
|      * |  | ||||||
|      * 用于和短信 API 进行定位于排错 |  | ||||||
|      */ |  | ||||||
|     private String apiRequestId; |  | ||||||
|     /** |  | ||||||
|      * 短信 API 发送返回的序号 |  | ||||||
|      * |  | ||||||
|      * 用于和短信 API 平台的发送记录关联 |  | ||||||
|      */ |  | ||||||
|     private String apiSerialNo; |  | ||||||
|  |  | ||||||
|     private SmsResult() { |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static SmsResult success(SmsSendFailureTypeEnum sendFailureType, |  | ||||||
|                                     String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo) { |  | ||||||
|         SmsResult result = new SmsResult().setSuccess(true).setApiSendCode(apiSendCode).setApiSendMsg(apiSendMsg) |  | ||||||
|                 .setApiRequestId(apiRequestId).setApiSerialNo(apiSerialNo); |  | ||||||
|         if (sendFailureType != null) { |  | ||||||
|             result.setSendFailureType(sendFailureType.getType()).setSendFailureMsg(sendFailureType.getMsg()); |  | ||||||
|         } |  | ||||||
|         return result; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static SmsResult error(Throwable ex) { |  | ||||||
|         return new SmsResult().setSuccess(false) |  | ||||||
|                 .setSendFailureType(SmsSendFailureTypeEnum.SMS_SEND_EXCEPTION.getType()) |  | ||||||
|                 .setSendFailureMsg(ExceptionUtil.getRootCauseMessage(ex)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,7 +1,7 @@ | |||||||
| package cn.iocoder.dashboard.framework.sms.core.client; | package cn.iocoder.dashboard.framework.sms.core.client; | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | ||||||
|  | import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO; | ||||||
|  |  | ||||||
| import javax.servlet.ServletRequest; | import javax.servlet.ServletRequest; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @ -30,7 +30,7 @@ public interface SmsClient { | |||||||
|      * @param templateParams 短信模板参数 |      * @param templateParams 短信模板参数 | ||||||
|      * @return 短信发送结果 |      * @return 短信发送结果 | ||||||
|      */ |      */ | ||||||
|     SmsResult send(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams); |     SmsCommonResult<SmsSendRespDTO> send(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams); | ||||||
|  |  | ||||||
|     // TODO FROM 芋艿 to ZZF:是不是可以改成意图更明确的解析返回结果,例如说 parseXXXX |     // TODO FROM 芋艿 to ZZF:是不是可以改成意图更明确的解析返回结果,例如说 parseXXXX | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -0,0 +1,59 @@ | |||||||
|  | package cn.iocoder.dashboard.framework.sms.core.client; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.exceptions.ExceptionUtil; | ||||||
|  | import cn.iocoder.dashboard.common.pojo.CommonResult; | ||||||
|  | import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  | import lombok.ToString; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 短信的 CommonResult 拓展类 | ||||||
|  |  * | ||||||
|  |  * 考虑到不同的平台,返回的 code 和 msg 是不同的,所以统一额外返回 {@link #apiCode} 和 {@link #apiMsg} 字段 | ||||||
|  |  * | ||||||
|  |  * 另外,一些短信平台(例如说阿里云、腾讯云)会返回一个请求编号,用于排查请求失败的问题,我们设置到 {@link #apiRequestId} 字段 | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | @ToString(callSuper = true) | ||||||
|  | public class SmsCommonResult<T> extends CommonResult<T> { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * API 返回错误码 | ||||||
|  |      * | ||||||
|  |      * 由于第三方的错误码可能是字符串,所以使用 String 类型 | ||||||
|  |      */ | ||||||
|  |     private String apiCode; | ||||||
|  |     /** | ||||||
|  |      * API 返回提示 | ||||||
|  |      */ | ||||||
|  |     private String apiMsg; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * API 请求编号 | ||||||
|  |      */ | ||||||
|  |     private String apiRequestId; | ||||||
|  |  | ||||||
|  |     private SmsCommonResult() { | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static SmsCommonResult success(SmsSendFailureTypeEnum sendFailureType, | ||||||
|  |                                           String apiSendCode, String apiSendMsg, String apiRequestId, String apiSerialNo) { | ||||||
|  |         SmsCommonResult result = new SmsCommonResult().setSuccess(true).setApiSendCode(apiSendCode).setApiSendMsg(apiSendMsg) | ||||||
|  |                 .setApiRequestId(apiRequestId).setApiSerialNo(apiSerialNo); | ||||||
|  |         if (sendFailureType != null) { | ||||||
|  |             result.setSendFailureType(sendFailureType.getType()).setSendFailureMsg(sendFailureType.getMsg()); | ||||||
|  |         } | ||||||
|  |         return result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static SmsCommonResult error(Throwable ex) { | ||||||
|  |         return new SmsCommonResult().setSuccess(false) | ||||||
|  |                 .setSendFailureType(SmsSendFailureTypeEnum.SMS_SEND_EXCEPTION.getType()) | ||||||
|  |                 .setSendFailureMsg(ExceptionUtil.getRootCauseMessage(ex)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -0,0 +1,15 @@ | |||||||
|  | package cn.iocoder.dashboard.framework.sms.core.client.dto; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 短信发送响应 DTO | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | public class SmsSendRespDTO { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 短信 API 发送返回的序号 | ||||||
|  |      */ | ||||||
|  |     private String serialNo; | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -1,7 +1,8 @@ | |||||||
| package cn.iocoder.dashboard.framework.sms.core.client.impl; | package cn.iocoder.dashboard.framework.sms.core.client.impl; | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.client.SmsClient; | import cn.iocoder.dashboard.framework.sms.core.client.SmsClient; | ||||||
|  | import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
|  |  | ||||||
| @ -60,8 +61,10 @@ public abstract class AbstractSmsClient implements SmsClient { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public final SmsResult send(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) { |     public final SmsCommonResult<SmsSendRespDTO> send(Long sendLogId, String mobile, | ||||||
|         SmsResult result; |                                                       String apiTemplateId, Map<String, Object> templateParams) { | ||||||
|  |         // 执行短信发送 | ||||||
|  |         SmsCommonResult<SmsSendRespDTO> result; | ||||||
|         try { |         try { | ||||||
|             result = doSend(sendLogId, mobile, apiTemplateId, templateParams); |             result = doSend(sendLogId, mobile, apiTemplateId, templateParams); | ||||||
|         } catch (Throwable ex) { |         } catch (Throwable ex) { | ||||||
| @ -69,7 +72,7 @@ public abstract class AbstractSmsClient implements SmsClient { | |||||||
|             log.error("[send][发送短信异常,sendLogId({}) mobile({}) apiTemplateId({}) templateParams({})]", |             log.error("[send][发送短信异常,sendLogId({}) mobile({}) apiTemplateId({}) templateParams({})]", | ||||||
|                     sendLogId, mobile, apiTemplateId, templateParams, ex); |                     sendLogId, mobile, apiTemplateId, templateParams, ex); | ||||||
|             // 封装返回 |             // 封装返回 | ||||||
|             return SmsResult.error(ex); |             return SmsCommonResult.error(ex); | ||||||
|         } |         } | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
| @ -83,7 +86,7 @@ public abstract class AbstractSmsClient implements SmsClient { | |||||||
|      * @param templateParams 短信模板参数 |      * @param templateParams 短信模板参数 | ||||||
|      * @return 短信发送结果 |      * @return 短信发送结果 | ||||||
|      */ |      */ | ||||||
|     protected abstract SmsResult doSend(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) |     protected abstract SmsCommonResult<SmsSendRespDTO> doSend(Long sendLogId, String mobile, | ||||||
|             throws Throwable; |                                                               String apiTemplateId, Map<String, Object> templateParams) throws Throwable; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun; | |||||||
| import cn.hutool.core.collection.CollectionUtil; | import cn.hutool.core.collection.CollectionUtil; | ||||||
| import cn.hutool.core.date.DateUtil; | import cn.hutool.core.date.DateUtil; | ||||||
| import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient; | import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | ||||||
| @ -59,7 +59,7 @@ public class AliyunSmsClient extends AbstractSmsClient { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected SmsResult doSend(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) throws Exception { |     protected SmsCommonResult doSend(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) throws Exception { | ||||||
|         // 构建参数 |         // 构建参数 | ||||||
|         SendSmsRequest request = new SendSmsRequest(); |         SendSmsRequest request = new SendSmsRequest(); | ||||||
|         request.setSysMethod(MethodType.POST); |         request.setSysMethod(MethodType.POST); | ||||||
| @ -73,10 +73,10 @@ public class AliyunSmsClient extends AbstractSmsClient { | |||||||
|             // 执行发送 |             // 执行发送 | ||||||
|             SendSmsResponse sendResult = acsClient.getAcsResponse(request); |             SendSmsResponse sendResult = acsClient.getAcsResponse(request); | ||||||
|             // 解析结果 |             // 解析结果 | ||||||
|             return SmsResult.success(parseSendFailureType(sendResult.getCode()), // 将 API 短信平台,解析成统一的错误码 |             return SmsCommonResult.success(parseSendFailureType(sendResult.getCode()), // 将 API 短信平台,解析成统一的错误码 | ||||||
|                     sendResult.getCode(), sendResult.getMessage(), sendResult.getRequestId(), sendResult.getBizId()); |                     sendResult.getCode(), sendResult.getMessage(), sendResult.getRequestId(), sendResult.getBizId()); | ||||||
|         } catch (ClientException ex) { |         } catch (ClientException ex) { | ||||||
|             return SmsResult.success(parseSendFailureType(ex.getErrCode()), // 将 API 短信平台,解析成统一的错误码 |             return SmsCommonResult.success(parseSendFailureType(ex.getErrCode()), // 将 API 短信平台,解析成统一的错误码 | ||||||
|                     ex.getErrCode(), formatResultMsg(ex), ex.getRequestId(), null); |                     ex.getErrCode(), formatResultMsg(ex), ex.getRequestId(), null); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ import cn.hutool.core.util.CharsetUtil; | |||||||
| import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||||
| import cn.hutool.core.util.URLUtil; | import cn.hutool.core.util.URLUtil; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsConstants; | import cn.iocoder.dashboard.framework.sms.core.SmsConstants; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | import cn.iocoder.dashboard.framework.sms.core.SmsResultDetail; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient; | import cn.iocoder.dashboard.framework.sms.core.client.impl.AbstractSmsClient; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | ||||||
| @ -66,7 +66,7 @@ public class YunpianSmsClient extends AbstractSmsClient { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected SmsResult doSend(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) throws Throwable { |     protected SmsCommonResult doSend(Long sendLogId, String mobile, String apiTemplateId, Map<String, Object> templateParams) throws Throwable { | ||||||
|         // 构建参数 |         // 构建参数 | ||||||
|         Map<String, String> request = new HashMap<>(); |         Map<String, String> request = new HashMap<>(); | ||||||
|         request.put(YunpianConstant.APIKEY, properties.getApiKey()); |         request.put(YunpianConstant.APIKEY, properties.getApiKey()); | ||||||
| @ -82,7 +82,7 @@ public class YunpianSmsClient extends AbstractSmsClient { | |||||||
|             throw sendResult.getThrowable(); |             throw sendResult.getThrowable(); | ||||||
|         } |         } | ||||||
|         // 解析结果 |         // 解析结果 | ||||||
|         return SmsResult.success(parseSendFailureType(sendResult), // 将 API 短信平台,解析成统一的错误码 |         return SmsCommonResult.success(parseSendFailureType(sendResult), // 将 API 短信平台,解析成统一的错误码 | ||||||
|                 String.valueOf(sendResult.getCode()), formatResultMsg(sendResult), null, getApiSerialNo(sendResult)); |                 String.valueOf(sendResult.getCode()), formatResultMsg(sendResult), null, getApiSerialNo(sendResult)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil; | |||||||
| import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||||
| import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | ||||||
| import cn.iocoder.dashboard.common.enums.UserTypeEnum; | import cn.iocoder.dashboard.common.enums.UserTypeEnum; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.client.SmsClient; | import cn.iocoder.dashboard.framework.sms.core.client.SmsClient; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.client.SmsClientFactory; | import cn.iocoder.dashboard.framework.sms.core.client.SmsClientFactory; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | import cn.iocoder.dashboard.framework.sms.core.enums.SmsSendFailureTypeEnum; | ||||||
| @ -137,7 +137,7 @@ public class SysSmsServiceImpl implements SysSmsService { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // 发送短信 |         // 发送短信 | ||||||
|         SmsResult sendResult = smsClient.send(message.getSendLogId(), message.getMobile(), |         SmsCommonResult sendResult = smsClient.send(message.getSendLogId(), message.getMobile(), | ||||||
|                 message.getApiTemplateId(), message.getTemplateParams()); |                 message.getApiTemplateId(), message.getTemplateParams()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun; | package cn.iocoder.dashboard.framework.sms.core.client.impl.aliyun; | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum; | import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | ||||||
| import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||||
| @ -30,7 +30,7 @@ public class AliyunSmsClientTest { | |||||||
|         templateParams.put("code", "1024"); |         templateParams.put("code", "1024"); | ||||||
| //        templateParams.put("operation", "嘿嘿"); | //        templateParams.put("operation", "嘿嘿"); | ||||||
| //        SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams); | //        SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams); | ||||||
|         SmsResult result = smsClient.send(1L, "15601691399", "SMS_207945135", templateParams); |         SmsCommonResult result = smsClient.send(1L, "15601691399", "SMS_207945135", templateParams); | ||||||
|         System.out.println(result); |         System.out.println(result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| package cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian; | package cn.iocoder.dashboard.framework.sms.core.client.impl.yunpian; | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.framework.sms.core.SmsResult; | import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum; | import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum; | ||||||
| import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties; | ||||||
| import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||||
| @ -29,7 +29,7 @@ public class YunpianSmsClientIntegrationTest { | |||||||
|         templateParams.put("code", "1024"); |         templateParams.put("code", "1024"); | ||||||
|         templateParams.put("operation", "嘿嘿"); |         templateParams.put("operation", "嘿嘿"); | ||||||
| //        SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams); | //        SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams); | ||||||
|         SmsResult result = smsClient.send(1L, "15601691399", "4383920", templateParams); |         SmsCommonResult result = smsClient.send(1L, "15601691399", "4383920", templateParams); | ||||||
|         System.out.println(result); |         System.out.println(result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV