|
@@ -1,10 +1,11 @@
|
|
|
package com.izouma.nineth.service.sms;
|
|
package com.izouma.nineth.service.sms;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyuncs.CommonRequest;
|
|
import com.aliyuncs.CommonRequest;
|
|
|
import com.aliyuncs.CommonResponse;
|
|
import com.aliyuncs.CommonResponse;
|
|
|
import com.aliyuncs.DefaultAcsClient;
|
|
import com.aliyuncs.DefaultAcsClient;
|
|
|
import com.aliyuncs.IAcsClient;
|
|
import com.aliyuncs.IAcsClient;
|
|
|
-import com.aliyuncs.exceptions.ClientException;
|
|
|
|
|
import com.aliyuncs.http.MethodType;
|
|
import com.aliyuncs.http.MethodType;
|
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.izouma.nineth.config.Constants;
|
|
import com.izouma.nineth.config.Constants;
|
|
@@ -17,8 +18,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.boot.configurationprocessor.json.JSONException;
|
|
|
|
|
-import org.springframework.boot.configurationprocessor.json.JSONObject;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -85,7 +84,7 @@ public class AliSmsService implements SmsService {
|
|
|
throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
|
|
throw new BusinessException("发送失败,请稍后再试", response.getHttpStatus() + "," + response.getData());
|
|
|
}
|
|
}
|
|
|
log.info("send sms response {}", response.getData());
|
|
log.info("send sms response {}", response.getData());
|
|
|
- JSONObject jsonObject = new JSONObject(response.getData());
|
|
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(response.getData());
|
|
|
if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
|
|
if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
|
|
|
throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
|
|
throw new BusinessException("发送失败,请稍后再试", jsonObject.getString("Message"));
|
|
|
}
|
|
}
|
|
@@ -99,7 +98,7 @@ public class AliSmsService implements SmsService {
|
|
|
.expired(false)
|
|
.expired(false)
|
|
|
.build());
|
|
.build());
|
|
|
return sessionId;
|
|
return sessionId;
|
|
|
- } catch (ClientException | JSONException e) {
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
throw new BusinessException("发送失败,请稍后再试", e.getMessage());
|
|
throw new BusinessException("发送失败,请稍后再试", e.getMessage());
|
|
|
}
|
|
}
|
|
@@ -149,12 +148,12 @@ public class AliSmsService implements SmsService {
|
|
|
log.error("发送失败," + response.getHttpStatus() + "," + response.getData());
|
|
log.error("发送失败," + response.getHttpStatus() + "," + response.getData());
|
|
|
}
|
|
}
|
|
|
log.info("send sms response {}", response.getData());
|
|
log.info("send sms response {}", response.getData());
|
|
|
- JSONObject jsonObject = new JSONObject(response.getData());
|
|
|
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(response.getData());
|
|
|
if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
|
|
if (!"ok".equalsIgnoreCase(jsonObject.getString("Code"))) {
|
|
|
log.error("发送失败," + jsonObject.getString("Message"));
|
|
log.error("发送失败," + jsonObject.getString("Message"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- } catch (ClientException | JSONException e) {
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
log.error("发送失败," + e.getMessage());
|
|
log.error("发送失败," + e.getMessage());
|
|
|
}
|
|
}
|