|
@@ -1,5 +1,7 @@
|
|
|
package cn.cslg.permission.common.core.business;
|
|
|
|
|
|
+import cn.cslg.permission.exception.ExceptionEnum;
|
|
|
+import cn.cslg.permission.exception.XiaoShiException;
|
|
|
import com.aliyuncs.DefaultAcsClient;
|
|
|
import com.aliyuncs.IAcsClient;
|
|
|
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
|
|
@@ -7,6 +9,7 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
|
|
|
import com.aliyuncs.exceptions.ClientException;
|
|
|
import com.aliyuncs.profile.DefaultProfile;
|
|
|
import com.google.gson.Gson;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -35,6 +38,9 @@ public class SmsService {
|
|
|
request.setTemplateParam(templateParam);//短信模板变量对应的实际值
|
|
|
try {
|
|
|
SendSmsResponse response = client.getAcsResponse(request);
|
|
|
+ if (!StringUtils.equals(response.getCode(), "OK")) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "短信发送过于频繁,请一小时后重试");
|
|
|
+ }
|
|
|
System.out.println(new Gson().toJson(response));
|
|
|
} catch (ClientException e) {
|
|
|
System.out.println("ErrCode:" + e.getErrCode());
|