result = requestConsumer.get();
- if (result.getThrowable() != null) {
- throw result.getThrowable();
- }
- // 解析结果
- R data = null;
- if (result.getData() != null) {
- data = responseConsumer.apply(result.getData());
- }
- // 拼接结果
- return SmsCommonResult.build(String.valueOf(result.getCode()), formatResultMsg(result), null, data, codeMapping);
- }
-
- private static String formatResultMsg(Result> sendResult) {
- if (StrUtil.isEmpty(sendResult.getDetail())) {
- return sendResult.getMsg();
- }
- return sendResult.getMsg() + " => " + sendResult.getDetail();
- }
-
- /**
- * 短信接收状态
- *
- * 参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档
- *
- * @author 芋道源码
- */
- @Data
- public static class SmsReceiveStatus {
-
- /**
- * 接收状态
- *
- * 目前仅有 SUCCESS / FAIL,所以使用 Boolean 接收
- */
- @JsonProperty("report_status")
- private String reportStatus;
- /**
- * 接收手机号
- */
- private String mobile;
- /**
- * 运营商返回的代码,如:"DB:0103"
- *
- * 由于不同运营商信息不同,此字段仅供参考;
- */
- @JsonProperty("error_msg")
- private String errorMsg;
- /**
- * 运营商反馈代码的中文解释
- *
- * 默认不推送此字段,如需推送,请联系客服
- */
- @JsonProperty("error_detail")
- private String errorDetail;
- /**
- * 短信编号
- */
- private Long sid;
- /**
- * 用户自定义 id
- *
- * 这里我们传递的是 SysSmsLogDO 的日志编号
- */
- private Long uid;
- /**
- * 用户接收时间
- */
- @JsonProperty("user_receive_time")
- @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
- private LocalDateTime userReceiveTime;
-
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMapping.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMapping.java
deleted file mode 100644
index f467ceb4f..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMapping.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian;
-
-import cn.iocoder.yudao.framework.common.exception.ErrorCode;
-import cn.iocoder.yudao.framework.sms.core.client.SmsCodeMapping;
-import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
-
-import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS;
-import static com.yunpian.sdk.constant.Code.*;
-
-/**
- * 云片的 SmsCodeMapping 实现类
- *
- * 参见 https://www.yunpian.com/official/document/sms/zh_CN/returnvalue_common 文档
- *
- * @author 芋道源码
- */
-public class YunpianSmsCodeMapping implements SmsCodeMapping {
-
- @Override
- public ErrorCode apply(String apiCode) {
- int code = Integer.parseInt(apiCode);
- switch (code) {
- case OK:
- return SUCCESS;
- case ARGUMENT_MISSING:
- return SmsFrameworkErrorCodeConstants.SMS_API_PARAM_ERROR;
- case BAD_ARGUMENT_FORMAT:
- return SmsFrameworkErrorCodeConstants.SMS_TEMPLATE_PARAM_ERROR;
- case TPL_NOT_FOUND:
- case TPL_NOT_VALID:
- return SmsFrameworkErrorCodeConstants.SMS_TEMPLATE_INVALID;
- case MONEY_NOT_ENOUGH:
- return SmsFrameworkErrorCodeConstants.SMS_ACCOUNT_MONEY_NOT_ENOUGH;
- case BLACK_WORD:
- return SmsFrameworkErrorCodeConstants.SMS_SEND_CONTENT_INVALID;
- case DUP_IN_SHORT_TIME:
- case TOO_MANY_TIME_IN_5:
- case DAY_LIMIT_PER_MOBILE:
- case HOUR_LIMIT_PER_MOBILE:
- return SmsFrameworkErrorCodeConstants.SMS_SEND_BUSINESS_LIMIT_CONTROL;
- case BLACK_PHONE_FILTER:
- return SmsFrameworkErrorCodeConstants.SMS_MOBILE_BLACK;
- case SIGN_NOT_MATCH:
- case BAD_SIGN_FORMAT:
- case SIGN_NOT_VALID:
- return SmsFrameworkErrorCodeConstants.SMS_SIGN_INVALID;
- case BAD_API_KEY:
- return SmsFrameworkErrorCodeConstants.SMS_ACCOUNT_INVALID;
- case API_NOT_ALLOWED:
- return SmsFrameworkErrorCodeConstants.SMS_PERMISSION_DENY;
- case IP_NOT_ALLOWED:
- return SmsFrameworkErrorCodeConstants.SMS_IP_DENY;
- default:
- break;
- }
- return SmsFrameworkErrorCodeConstants.SMS_UNKNOWN;
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsChannelEnum.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsChannelEnum.java
index b1b386b98..66410bd2c 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsChannelEnum.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsChannelEnum.java
@@ -15,7 +15,6 @@ import lombok.Getter;
public enum SmsChannelEnum {
DEBUG_DING_TALK("DEBUG_DING_TALK", "调试(钉钉)"),
- YUN_PIAN("YUN_PIAN", "云片"),
ALIYUN("ALIYUN", "阿里云"),
TENCENT("TENCENT", "腾讯云"),
// HUA_WEI("HUA_WEI", "华为云"),
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsFrameworkErrorCodeConstants.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsFrameworkErrorCodeConstants.java
index 7af1dd21c..852f4e29b 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsFrameworkErrorCodeConstants.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/main/java/cn/iocoder/yudao/framework/sms/core/enums/SmsFrameworkErrorCodeConstants.java
@@ -16,7 +16,6 @@ public interface SmsFrameworkErrorCodeConstants {
// ========== 权限 / 限流等相关 2001000100 ==========
ErrorCode SMS_PERMISSION_DENY = new ErrorCode(2001000100, "没有发送短信的权限");
- // 云片:可以配置 IP 白名单,只有在白名单中才可以发送短信
ErrorCode SMS_IP_DENY = new ErrorCode(2001000100, "IP 不允许发送短信");
// 阿里云:将短信发送频率限制在正常的业务限流范围内。默认短信验证码:使用同一签名,对同一个手机号验证码,支持 1 条 / 分钟,5 条 / 小时,累计 10 条 / 天。
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java
deleted file mode 100644
index a23094a88..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test-integration/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientIntegrationTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian;
-
-import cn.iocoder.yudao.framework.common.core.KeyValue;
-import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult;
-import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO;
-import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO;
-import cn.iocoder.yudao.framework.sms.core.client.impl.yunpian.YunpianSmsClient;
-import cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum;
-import cn.iocoder.yudao.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 YunpianSmsClient} 的集成测试
- */
-public class YunpianSmsClientIntegrationTest {
-
- private static YunpianSmsClient smsClient;
-
- @BeforeAll
- public static void init() {
- // 创建配置类
- SmsChannelProperties properties = new SmsChannelProperties();
- properties.setId(1L);
- properties.setSignature("芋道");
- properties.setCode(SmsChannelEnum.YUN_PIAN.getCode());
- properties.setApiKey("1555a14277cb8a608cf45a9e6a80d510");
- // 创建客户端
- smsClient = new YunpianSmsClient(properties);
- smsClient.init();
- }
-
- @Test
- public void testSendSms() {
- List> templateParams = new ArrayList<>();
- templateParams.add(new KeyValue<>("code", "1024"));
- templateParams.add(new KeyValue<>("operation", "嘿嘿"));
-// SmsResult result = smsClient.send(1L, "15601691399", "4372216", templateParams);
- SmsCommonResult result = smsClient.sendSms(1L, "15601691399", "4383920", templateParams);
- System.out.println(result);
- }
-
- @Test
- public void testGetSmsTemplate() {
- String apiTemplateId = "4383920";
- SmsCommonResult result = smsClient.getSmsTemplate(apiTemplateId);
- System.out.println(result);
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientTest.java
deleted file mode 100644
index 3fc05ce77..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsClientTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian;
-
-import cn.hutool.core.util.ReflectUtil;
-import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
-import cn.iocoder.yudao.framework.common.core.KeyValue;
-import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
-import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult;
-import cn.iocoder.yudao.framework.sms.core.client.dto.SmsReceiveRespDTO;
-import cn.iocoder.yudao.framework.sms.core.client.dto.SmsSendRespDTO;
-import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO;
-import cn.iocoder.yudao.framework.sms.core.enums.SmsTemplateAuditStatusEnum;
-import cn.iocoder.yudao.framework.sms.core.property.SmsChannelProperties;
-import com.google.common.collect.Lists;
-import com.yunpian.sdk.YunpianClient;
-import com.yunpian.sdk.api.SmsApi;
-import com.yunpian.sdk.api.TplApi;
-import com.yunpian.sdk.constant.YunpianConstant;
-import com.yunpian.sdk.model.Result;
-import com.yunpian.sdk.model.SmsSingleSend;
-import com.yunpian.sdk.model.Template;
-import org.junit.jupiter.api.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-
-import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
-import static com.yunpian.sdk.constant.Code.OK;
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.*;
-
-/**
- * 对 {@link YunpianSmsClient} 的单元测试
- *
- * @author 芋道源码
- */
-public class YunpianSmsClientTest extends BaseMockitoUnitTest {
-
- private final SmsChannelProperties properties = new SmsChannelProperties()
- .setApiKey(randomString()); // 随机一个 apiKey,避免构建报错
-
- @InjectMocks
- private final YunpianSmsClient smsClient = new YunpianSmsClient(properties);
-
- @Mock
- private YunpianClient client;
-
- @Test
- public void testDoInit() {
- // 准备参数
- // mock 方法
-
- // 调用
- smsClient.doInit();
- // 断言
- assertNotEquals(client, ReflectUtil.getFieldValue(smsClient, "client"));
- verify(client, times(1)).close();
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testDoSendSms() throws Throwable {
- // 准备参数
- Long sendLogId = randomLongId();
- String mobile = randomString();
- String apiTemplateId = randomString();
- List> templateParams = Lists.newArrayList(
- new KeyValue<>("code", 1234), new KeyValue<>("op", "login"));
- // mock sms 方法
- SmsApi smsApi = mock(SmsApi.class);
- when(client.sms()).thenReturn(smsApi);
- // mock tpl_single_send 方法
- Map request = new HashMap<>();
- request.put(YunpianConstant.MOBILE, mobile);
- request.put(YunpianConstant.TPL_ID, apiTemplateId);
- request.put(YunpianConstant.TPL_VALUE, "#code#=1234op#=login");
- request.put(YunpianConstant.UID, String.valueOf(sendLogId));
- request.put(YunpianConstant.CALLBACK_URL, properties.getCallbackUrl());
- Result responseResult = randomPojo(Result.class, SmsSingleSend.class,
- o -> o.setCode(OK)); // API 发送成功的 code
- when(smsApi.tpl_single_send(eq(request))).thenReturn(responseResult);
-
- // 调用
- SmsCommonResult result = smsClient.doSendSms(sendLogId, mobile,
- apiTemplateId, templateParams);
- // 断言
- assertEquals(String.valueOf(responseResult.getCode()), result.getApiCode());
- assertEquals(responseResult.getMsg() + " => " + responseResult.getDetail(), result.getApiMsg());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), result.getCode());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getMsg(), result.getMsg());
- assertNull(result.getApiRequestId());
- // 断言结果
- assertEquals(String.valueOf(responseResult.getData().getSid()), result.getData().getSerialNo());
- }
-
- @Test
- public void testDoParseSmsReceiveStatus() throws Throwable {
- // 准备参数
- String text = "[{\"sid\":9527,\"uid\":1024,\"user_receive_time\":\"2014-03-17 22:55:21\",\"error_msg\":\"\",\"mobile\":\"15205201314\",\"report_status\":\"SUCCESS\"}]";
- // mock 方法
-
- // 调用
-
- // 断言
- // 调用
- List statuses = smsClient.doParseSmsReceiveStatus(text);
- // 断言
- assertEquals(1, statuses.size());
- assertTrue(statuses.get(0).getSuccess());
- assertEquals("", statuses.get(0).getErrorCode());
- assertNull(statuses.get(0).getErrorMsg());
- assertEquals("15205201314", statuses.get(0).getMobile());
- assertEquals(LocalDateTime.of(2014, 3, 17, 22, 55, 21), statuses.get(0).getReceiveTime());
- assertEquals("9527", statuses.get(0).getSerialNo());
- assertEquals(1024L, statuses.get(0).getLogId());
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testDoGetSmsTemplate() throws Throwable {
- // 准备参数
- String apiTemplateId = String.valueOf(randomLongId());
- // mock tpl 方法
- TplApi tplApi = mock(TplApi.class);
- when(client.tpl()).thenReturn(tplApi);
- // mock get 方法
- Map request = new HashMap<>();
- request.put(YunpianConstant.APIKEY, properties.getApiKey());
- request.put(YunpianConstant.TPL_ID, apiTemplateId);
- Result> responseResult = randomPojo(Result.class, List.class, o -> {
- o.setCode(OK); // API 发送成功的 code
- o.setData(randomPojoList(Template.class, t -> t.setCheck_status("SUCCESS")));
- });
- when(tplApi.get(eq(request))).thenReturn(responseResult);
-
- // 调用
- SmsCommonResult result = smsClient.doGetSmsTemplate(apiTemplateId);
- // 断言
- assertEquals(String.valueOf(responseResult.getCode()), result.getApiCode());
- assertEquals(responseResult.getMsg() + " => " + responseResult.getDetail(), result.getApiMsg());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), result.getCode());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getMsg(), result.getMsg());
- assertNull(result.getApiRequestId());
- // 断言结果
- Template template = responseResult.getData().get(0);
- assertEquals(template.getTpl_id().toString(), result.getData().getId());
- assertEquals(template.getTpl_content(), result.getData().getContent());
- assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(), result.getData().getAuditStatus());
- assertEquals(template.getReason(), result.getData().getAuditReason());
- }
-
- @Test
- public void testConvertSmsTemplateAuditStatus() {
- assertEquals(SmsTemplateAuditStatusEnum.CHECKING.getStatus(),
- smsClient.convertSmsTemplateAuditStatus("CHECKING"));
- assertEquals(SmsTemplateAuditStatusEnum.SUCCESS.getStatus(),
- smsClient.convertSmsTemplateAuditStatus("SUCCESS"));
- assertEquals(SmsTemplateAuditStatusEnum.FAIL.getStatus(),
- smsClient.convertSmsTemplateAuditStatus("FAIL"));
- assertThrows(IllegalArgumentException.class, () -> smsClient.convertSmsTemplateAuditStatus("test"),
- "未知审核状态(test)");
- }
-
- @Test
- public void testInvoke_throwable() {
- // 准备参数
- Supplier> requestConsumer =
- () -> new Result<>().setThrowable(new NullPointerException());
- // mock 方法
-
- // 调用,并断言异常
- assertThrows(NullPointerException.class,
- () -> smsClient.invoke(requestConsumer, null));
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testInvoke_success() throws Throwable {
- // 准备参数
- Result responseResult = randomPojo(Result.class, SmsSingleSend.class, o -> o.setCode(OK));
- Supplier> requestConsumer = () -> responseResult;
- Function responseConsumer =
- smsSingleSend -> new SmsSendRespDTO().setSerialNo(String.valueOf(responseResult.getData().getSid()));
- // mock 方法
-
- // 调用
- SmsCommonResult result = smsClient.invoke(requestConsumer, responseConsumer);
- // 断言
- assertEquals(String.valueOf(responseResult.getCode()), result.getApiCode());
- assertEquals(responseResult.getMsg() + " => " + responseResult.getDetail(), result.getApiMsg());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getCode(), result.getCode());
- assertEquals(GlobalErrorCodeConstants.SUCCESS.getMsg(), result.getMsg());
- assertNull(result.getApiRequestId());
- assertEquals(String.valueOf(responseResult.getData().getSid()), result.getData().getSerialNo());
- }
-
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMappingTest.java b/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMappingTest.java
deleted file mode 100644
index 8a292e325..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-sms/src/test/java/cn/iocoder/yudao/framework/sms/core/client/impl/yunpian/YunpianSmsCodeMappingTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian;
-
-import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
-import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
-import cn.iocoder.yudao.framework.sms.core.enums.SmsFrameworkErrorCodeConstants;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.mockito.InjectMocks;
-
-import static com.yunpian.sdk.constant.Code.*;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/**
- * {@link YunpianSmsCodeMapping} 的单元测试
- *
- * @author 芋道源码
- */
-class YunpianSmsCodeMappingTest extends BaseMockitoUnitTest {
-
- @InjectMocks
- private YunpianSmsCodeMapping codeMapping;
-
- @Test
- public void testApply() {
- assertEquals(GlobalErrorCodeConstants.SUCCESS, codeMapping.apply(String.valueOf(OK)));
- Assertions.assertEquals(SmsFrameworkErrorCodeConstants.SMS_API_PARAM_ERROR, codeMapping.apply(String.valueOf(ARGUMENT_MISSING)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_TEMPLATE_PARAM_ERROR, codeMapping.apply(String.valueOf(BAD_ARGUMENT_FORMAT)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_ACCOUNT_MONEY_NOT_ENOUGH, codeMapping.apply(String.valueOf(MONEY_NOT_ENOUGH)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_TEMPLATE_INVALID, codeMapping.apply(String.valueOf(TPL_NOT_FOUND)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_TEMPLATE_INVALID, codeMapping.apply(String.valueOf(TPL_NOT_VALID)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SEND_BUSINESS_LIMIT_CONTROL, codeMapping.apply(String.valueOf(DUP_IN_SHORT_TIME)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SEND_BUSINESS_LIMIT_CONTROL, codeMapping.apply(String.valueOf(TOO_MANY_TIME_IN_5)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SEND_BUSINESS_LIMIT_CONTROL, codeMapping.apply(String.valueOf(DAY_LIMIT_PER_MOBILE)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SEND_BUSINESS_LIMIT_CONTROL, codeMapping.apply(String.valueOf(HOUR_LIMIT_PER_MOBILE)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_MOBILE_BLACK, codeMapping.apply(String.valueOf(BLACK_PHONE_FILTER)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SIGN_INVALID, codeMapping.apply(String.valueOf(SIGN_NOT_MATCH)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SIGN_INVALID, codeMapping.apply(String.valueOf(SIGN_NOT_VALID)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_SIGN_INVALID, codeMapping.apply(String.valueOf(BAD_SIGN_FORMAT)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_ACCOUNT_INVALID, codeMapping.apply(String.valueOf(BAD_API_KEY)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_PERMISSION_DENY, codeMapping.apply(String.valueOf(API_NOT_ALLOWED)));
- assertEquals(SmsFrameworkErrorCodeConstants.SMS_IP_DENY, codeMapping.apply(String.valueOf(IP_NOT_ALLOWED)));
- }
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsCallbackController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsCallbackController.java
index ed32e00cf..8a0767652 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsCallbackController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsCallbackController.java
@@ -1,17 +1,14 @@
package cn.iocoder.yudao.module.system.controller.admin.sms;
-import cn.hutool.core.util.URLUtil;
import cn.hutool.extra.servlet.ServletUtil;
-import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.framework.sms.core.enums.SmsChannelEnum;
+import cn.iocoder.yudao.module.system.service.sms.SmsSendService;
import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@@ -28,17 +25,6 @@ public class SmsCallbackController {
@Resource
private SmsSendService smsSendService;
- @PostMapping("/yunpian")
- @PermitAll
- @ApiOperation(value = "云片短信的回调", notes = "参见 https://www.yunpian.com/official/document/sms/zh_cn/domestic_push_report 文档")
- @ApiImplicitParam(name = "sms_status", value = "发送状态", required = true, example = "[{具体内容}]", dataTypeClass = String.class)
- @OperateLog(enable = false)
- public String receiveYunpianSmsStatus(@RequestParam("sms_status") String smsStatus) throws Throwable {
- String text = URLUtil.decode(smsStatus); // decode 解码参数,因为它被 encode
- smsSendService.receiveSmsStatus(SmsChannelEnum.YUN_PIAN.getCode(), text);
- return "SUCCESS"; // 约定返回 SUCCESS 为成功
- }
-
@PostMapping("/aliyun")
@PermitAll
@ApiOperation(value = "阿里云短信的回调", notes = "参见 https://help.aliyun.com/document_detail/120998.html 文档")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/DemoJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/DemoJob.java
new file mode 100644
index 000000000..fc205b53b
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/DemoJob.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.system.job;
+
+import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
+import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
+import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
+import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Component
+@TenantJob // 标记多租户
+public class DemoJob implements JobHandler {
+
+ @Resource
+ private AdminUserMapper adminUserMapper;
+
+ @Override
+ public String execute(String param) throws Exception {
+ System.out.println("当前租户:" + TenantContextHolder.getTenantId());
+ List users = adminUserMapper.selectList();
+ return "用户数量:" + users.size();
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java
index b3ae5cde4..a8e57ccb5 100644
--- a/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java
+++ b/yudao-module-system/yudao-module-system-biz/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java
@@ -30,22 +30,6 @@ public class SmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest {
@MockBean
private AdminUserService userService;
- @Test
- public void testSendSingleSms_yunpianSuccess() {
- // 参数准备
- String mobile = "15601691399";
- Long userId = 1L;
- Integer userType = UserTypeEnum.ADMIN.getValue();
- String templateCode = "test_01";
- Map templateParams = MapUtil.builder()
- .put("operation", "登录").put("code", "1234").build();
- // 调用
- smsService.sendSingleSms(mobile, userId, userType, templateCode, templateParams);
-
- // 等待 MQ 消费
- ThreadUtil.sleep(1, TimeUnit.HOURS);
- }
-
@Test
public void testSendSingleSms_aliyunSuccess() {
// 参数准备
diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml
index a0f09eff3..b654538f0 100644
--- a/yudao-server/src/main/resources/application-local.yaml
+++ b/yudao-server/src/main/resources/application-local.yaml
@@ -78,7 +78,7 @@ spring:
# Quartz 配置项,对应 QuartzProperties 配置类
spring:
quartz:
- auto-startup: false # 本地开发环境,尽量不要开启 Job
+ auto-startup: true # 本地开发环境,尽量不要开启 Job
scheduler-name: schedulerName # Scheduler 名字。默认为 schedulerName
job-store-type: jdbc # Job 存储器类型。默认为 memory 表示内存,可选 jdbc 使用数据库。
wait-for-jobs-to-complete-on-shutdown: true # 应用关闭时,是否等待定时任务执行完成。默认为 false ,建议设置为 true