【功能新增】IoT:实现 IotRuleSceneDataBridgeAction 的 http 部分的逻辑

This commit is contained in:
YunaiV
2025-02-03 18:33:43 +08:00
parent 5e71d1fc85
commit 7168e60fdd
12 changed files with 229 additions and 21 deletions

View File

@@ -184,7 +184,7 @@ public class AliyunSmsClient extends AbstractSmsClient {
@SneakyThrows
private static String percentCode(String str) {
Assert.notNull(str, "str 不能为空");
return URLEncoder.encode(str, StandardCharsets.UTF_8.name())
return HttpUtils.encodeUtf8(str)
.replace("+", "%20") // 加号 "+" 被替换为 "%20"
.replace("*", "%2A") // 星号 "*" 被替换为 "%2A"
.replace("%7E", "~"); // 波浪号 "%7E" 被替换为 "~"

View File

@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.framework.sms.core.client.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.format.FastDateFormat;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
@@ -19,8 +18,6 @@ import cn.iocoder.yudao.module.system.framework.sms.core.enums.SmsTemplateAuditS
import cn.iocoder.yudao.module.system.framework.sms.core.property.SmsChannelProperties;
import lombok.extern.slf4j.Slf4j;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -156,10 +153,9 @@ public class HuaweiSmsClient extends AbstractSmsClient {
.setAuditStatus(SmsTemplateAuditStatusEnum.SUCCESS.getStatus()).setAuditReason(null);
}
@SuppressWarnings("CharsetObjectCanBeUsed")
private static void appendToBody(StringBuilder body, String key, String value) throws UnsupportedEncodingException {
private static void appendToBody(StringBuilder body, String key, String value) {
if (StrUtil.isNotEmpty(value)) {
body.append(key).append(URLEncoder.encode(value, CharsetUtil.CHARSET_UTF_8.name()));
body.append(key).append(HttpUtils.encodeUtf8(value));
}
}