【优化】修改短信模板的渠道为云片时,校验 API 模板编号为整数

This commit is contained in:
YunaiV 2022-11-12 11:02:08 +08:00
parent 4b92663b5e
commit c33db3e60c

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.sms.core.client.impl.yunpian;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.NumberUtil;
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.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.core.KeyValue;
@ -105,6 +106,9 @@ public class YunpianSmsClient extends AbstractSmsClient {
@Override @Override
protected SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) throws Throwable { protected SmsCommonResult<SmsTemplateRespDTO> doGetSmsTemplate(String apiTemplateId) throws Throwable {
return invoke(() -> { return invoke(() -> {
if (!NumberUtil.isNumber(apiTemplateId)) {
throw new IllegalArgumentException("云片的 API 模板编号必须为整数");
}
Map<String, String> request = new HashMap<>(); Map<String, String> request = new HashMap<>();
request.put(YunpianConstant.APIKEY, properties.getApiKey()); request.put(YunpianConstant.APIKEY, properties.getApiKey());
request.put(YunpianConstant.TPL_ID, apiTemplateId); request.put(YunpianConstant.TPL_ID, apiTemplateId);