增加钉钉模拟短信的 smsClient 实现类
parent
1740128dc3
commit
be8b892bf6
@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.debug;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.exception.ErrorCode;
|
||||||
|
import cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCodeMapping;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static cn.iocoder.dashboard.framework.sms.core.enums.SmsFrameworkErrorCodeConstants.SMS_UNKNOWN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉的 SmsCodeMapping 实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class DebugDingTalkCodeMapping implements SmsCodeMapping {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorCode apply(String apiCode) {
|
||||||
|
return Objects.equals(apiCode, "0") ? GlobalErrorCodeConstants.SUCCESS : SMS_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.sms.core.client.impl.debug;
|
||||||
|
|
||||||
|
import cn.iocoder.dashboard.common.core.KeyValue;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.SmsCommonResult;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.client.dto.SmsSendRespDTO;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.enums.SmsChannelEnum;
|
||||||
|
import cn.iocoder.dashboard.framework.sms.core.property.SmsChannelProperties;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link DebugDingTalkSmsClient} 的集成测试
|
||||||
|
*/
|
||||||
|
public class DebugDingTalkSmsClientIntegrationTest {
|
||||||
|
|
||||||
|
private static DebugDingTalkSmsClient smsClient;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void init() {
|
||||||
|
// 创建配置类
|
||||||
|
SmsChannelProperties properties = new SmsChannelProperties();
|
||||||
|
properties.setId(1L);
|
||||||
|
properties.setSignature("芋道");
|
||||||
|
properties.setCode(SmsChannelEnum.DEBUG_DING_TALK.getCode());
|
||||||
|
properties.setApiKey("696b5d8ead48071237e4aa5861ff08dbadb2b4ded1c688a7b7c9afc615579859");
|
||||||
|
properties.setApiSecret("SEC5c4e5ff888bc8a9923ae47f59e7ccd30af1f14d93c55b4e2c9cb094e35aeed67");
|
||||||
|
// 创建客户端
|
||||||
|
smsClient = new DebugDingTalkSmsClient(properties);
|
||||||
|
smsClient.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSendSms() {
|
||||||
|
List<KeyValue<String, Object>> templateParams = new ArrayList<>();
|
||||||
|
templateParams.add(new KeyValue<>("code", "1024"));
|
||||||
|
templateParams.add(new KeyValue<>("operation", "嘿嘿"));
|
||||||
|
// SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams);
|
||||||
|
SmsCommonResult<SmsSendRespDTO> result = smsClient.sendSms(1L, "15601691399", "4383920", templateParams);
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue