Commit 19805785 authored by hezhen's avatar hezhen

修改发送短信

parent 9b6c262c
...@@ -21,6 +21,7 @@ import com.github.wxiaoqi.security.common.util.RandomUtil; ...@@ -21,6 +21,7 @@ import com.github.wxiaoqi.security.common.util.RandomUtil;
import com.github.wxiaoqi.security.common.util.process.SystemConfig; import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil; import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -45,6 +46,9 @@ public class SmsService { ...@@ -45,6 +46,9 @@ public class SmsService {
public JSONObject smsCode(String mobile){ public JSONObject smsCode(String mobile){
String code = RandomUtil.getRandomStr(6);// 6位短信验证码 String code = RandomUtil.getRandomStr(6);// 6位短信验证码
try { try {
if(StringUtils.isNotBlank(mobile)){
mobile=mobile.replace(" ", "");
}
code=sendSms(mobile,code); code=sendSms(mobile,code);
return JsonResultUtil.createSuccessResultWithObj(code); return JsonResultUtil.createSuccessResultWithObj(code);
} catch (ClientException e) { } catch (ClientException e) {
...@@ -83,7 +87,7 @@ public class SmsService { ...@@ -83,7 +87,7 @@ public class SmsService {
//request.setOutId("yourOutId"); //request.setOutId("yourOutId");
//hint 此处可能会抛出异常,注意catch //hint 此处可能会抛出异常,注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
log.info("短信接口返回的数据----------------"); log.info("短信接口返回的数据----------------mobile======"+mobile+"----code===="+code);
log.info("Code=" + sendSmsResponse.getCode()); log.info("Code=" + sendSmsResponse.getCode());
log.info("Message=" + sendSmsResponse.getMessage()); log.info("Message=" + sendSmsResponse.getMessage());
log.info("RequestId=" + sendSmsResponse.getRequestId()); log.info("RequestId=" + sendSmsResponse.getRequestId());
...@@ -131,7 +135,7 @@ public class SmsService { ...@@ -131,7 +135,7 @@ public class SmsService {
public static void main(String[] args) throws ClientException, InterruptedException { public static void main(String[] args) throws ClientException, InterruptedException {
SmsService SmsService=new SmsService(); SmsService SmsService=new SmsService();
//发短信 //发短信
String response = SmsService.sendSms("13612688539","123456"); String response = SmsService.sendSms("15521075918","123456");
/*System.out.println("短信接口返回的数据----------------"); /*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode()); System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage()); System.out.println("Message=" + response.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment