mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-07 01:18:33 +08:00
发送短信返回值增加非空判断
This commit is contained in:
parent
4ad4058a4a
commit
2d18f0832a
@ -112,6 +112,11 @@ public class AlibabaSmsImpl implements SmsBlend {
|
|||||||
|
|
||||||
private static SmsResponse getResponse(Map map) {
|
private static SmsResponse getResponse(Map map) {
|
||||||
SmsResponse smsResponse = new SmsResponse();
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
|
if (map == null){
|
||||||
|
smsResponse.setErrorCode("500");
|
||||||
|
smsResponse.setErrMessage("aliyun send sms response is null.check param");
|
||||||
|
return smsResponse;
|
||||||
|
}
|
||||||
smsResponse.setCode((String) map.get("Code"));
|
smsResponse.setCode((String) map.get("Code"));
|
||||||
smsResponse.setMessage((String) map.get("Message"));
|
smsResponse.setMessage((String) map.get("Message"));
|
||||||
if ("OK".equals(smsResponse.getCode())){
|
if ("OK".equals(smsResponse.getCode())){
|
||||||
|
|||||||
@ -179,6 +179,11 @@ public class EmaySmsImpl implements SmsBlend {
|
|||||||
|
|
||||||
private static SmsResponse getSmsResponse(JSONObject execute) {
|
private static SmsResponse getSmsResponse(JSONObject execute) {
|
||||||
SmsResponse smsResponse = new SmsResponse();
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
|
if (execute == null ){
|
||||||
|
smsResponse.setErrorCode("500");
|
||||||
|
smsResponse.setErrMessage("emay send sms response is null.check param");
|
||||||
|
return smsResponse;
|
||||||
|
}
|
||||||
String code = execute.getString("code");
|
String code = execute.getString("code");
|
||||||
if (StringUtils.isEmpty(code)) {
|
if (StringUtils.isEmpty(code)) {
|
||||||
smsResponse.setErrorCode("emay response code is null");
|
smsResponse.setErrorCode("emay response code is null");
|
||||||
|
|||||||
@ -72,9 +72,13 @@ public class HuaweiSmsImpl implements SmsBlend {
|
|||||||
}))
|
}))
|
||||||
.onError((ex, req, res) -> {
|
.onError((ex, req, res) -> {
|
||||||
HuaweiResponse huaweiResponse = res.get(HuaweiResponse.class);
|
HuaweiResponse huaweiResponse = res.get(HuaweiResponse.class);
|
||||||
|
if (huaweiResponse == null) {
|
||||||
|
smsResponse.setErrorCode("500");
|
||||||
|
smsResponse.setErrMessage("huawei send sms response is null.check param");
|
||||||
|
} else {
|
||||||
smsResponse.setErrMessage(huaweiResponse.getDescription());
|
smsResponse.setErrMessage(huaweiResponse.getDescription());
|
||||||
smsResponse.setErrorCode(huaweiResponse.getCode());
|
smsResponse.setErrorCode(huaweiResponse.getCode());
|
||||||
log.debug(huaweiResponse.getDescription());
|
}
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
return smsResponse;
|
return smsResponse;
|
||||||
|
|||||||
@ -108,10 +108,15 @@ public class TencentSmsImpl implements SmsBlend {
|
|||||||
}))
|
}))
|
||||||
.onError((ex, req, res) -> {
|
.onError((ex, req, res) -> {
|
||||||
JSONObject jsonBody = res.get(JSONObject.class);
|
JSONObject jsonBody = res.get(JSONObject.class);
|
||||||
|
if (jsonBody == null) {
|
||||||
|
smsResponse.setErrorCode("500");
|
||||||
|
smsResponse.setErrMessage("tencent send sms response is null.check param");
|
||||||
|
} else {
|
||||||
JSONObject response = jsonBody.getJSONObject("Response");
|
JSONObject response = jsonBody.getJSONObject("Response");
|
||||||
JSONArray sendStatusSet = response.getJSONArray("SendStatusSet");
|
JSONArray sendStatusSet = response.getJSONArray("SendStatusSet");
|
||||||
smsResponse.setErrMessage(sendStatusSet.getJSONObject(0).getString("Message"));
|
smsResponse.setErrMessage(sendStatusSet.getJSONObject(0).getString("Message"));
|
||||||
smsResponse.setErrorCode(sendStatusSet.getJSONObject(0).getString("Code"));
|
smsResponse.setErrorCode(sendStatusSet.getJSONObject(0).getString("Code"));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
return smsResponse;
|
return smsResponse;
|
||||||
|
|||||||
@ -37,6 +37,11 @@ public class YunPianSmsImpl implements SmsBlend {
|
|||||||
|
|
||||||
private static SmsResponse getSmsResponse(JSONObject execute) {
|
private static SmsResponse getSmsResponse(JSONObject execute) {
|
||||||
SmsResponse smsResponse = new SmsResponse();
|
SmsResponse smsResponse = new SmsResponse();
|
||||||
|
if (execute == null){
|
||||||
|
smsResponse.setErrorCode("500");
|
||||||
|
smsResponse.setErrMessage("yunpian send sms response is null.check param");
|
||||||
|
return smsResponse;
|
||||||
|
}
|
||||||
smsResponse.setCode(execute.getString("code"));
|
smsResponse.setCode(execute.getString("code"));
|
||||||
smsResponse.setMessage(execute.getString("msg"));
|
smsResponse.setMessage(execute.getString("msg"));
|
||||||
smsResponse.setBizId(execute.getString("sid"));
|
smsResponse.setBizId(execute.getString("sid"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user