!187 修复luosimao对接手机号+86前缀报错问题

Merge pull request !187 from LiYaoheng/dev-3.0.x
This commit is contained in:
风如歌 2024-12-24 08:25:58 +00:00 committed by Gitee
commit ec501e441d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1,6 +1,5 @@
package org.dromara.sms4j.luosimao.utils; package org.dromara.sms4j.luosimao.utils;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.sms4j.comm.constant.Constant; import org.dromara.sms4j.comm.constant.Constant;
import org.dromara.sms4j.comm.utils.SmsDateUtils; import org.dromara.sms4j.comm.utils.SmsDateUtils;
@ -13,24 +12,24 @@ import java.util.List;
@Slf4j @Slf4j
public class LuoSiMaoUtils { public class LuoSiMaoUtils {
public static LinkedHashMap<String, String> buildHeaders(){ public static LinkedHashMap<String, String> buildHeaders() {
LinkedHashMap<String, String> headers = new LinkedHashMap<>(1); LinkedHashMap<String, String> headers = new LinkedHashMap<>(1);
headers.put(Constant.CONTENT_TYPE, Constant.APPLICATION_FROM_URLENCODED); headers.put(Constant.CONTENT_TYPE, Constant.APPLICATION_FROM_URLENCODED);
return headers; return headers;
} }
public static LinkedHashMap<String, Object> buildBody(String phone, String message){ public static LinkedHashMap<String, Object> buildBody(String phone, String message) {
LinkedHashMap<String, Object> body = new LinkedHashMap<>(2); LinkedHashMap<String, Object> body = new LinkedHashMap<>(2);
body.put("mobile", StrUtil.addPrefixIfNot(phone, "+86")); body.put("mobile", phone);
body.put("message", message); body.put("message", message);
return body; return body;
} }
public static LinkedHashMap<String, Object> buildBody(List<String> phones, String message, Date date){ public static LinkedHashMap<String, Object> buildBody(List<String> phones, String message, Date date) {
LinkedHashMap<String, Object> body = new LinkedHashMap<>(2); LinkedHashMap<String, Object> body = new LinkedHashMap<>(2);
body.put("mobile", SmsUtils.addCodePrefixIfNot(phones)); body.put("mobile", SmsUtils.joinComma(phones));
body.put("message", message); body.put("message", message);
if (date != null){ if (date != null) {
body.put("time", SmsDateUtils.normDatetimeGmt8(date)); body.put("time", SmsDateUtils.normDatetimeGmt8(date));
} }
return body; return body;