Browse Source

新增sendMessage接口及SmsResponse响应类

test
smallchill 5 years ago
parent
commit
c589c2a56c
  1. 3
      blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/feign/ISmsClient.java
  2. 7
      blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/utils/SmsUtil.java
  3. 5
      blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java
  4. 7
      blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/SmsClient.java

3
blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/feign/ISmsClient.java

@ -17,6 +17,7 @@
package org.springblade.resource.feign;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.sms.model.SmsResponse;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@ -46,7 +47,7 @@ public interface ISmsClient {
* @return R
*/
@PostMapping(SEND_MESSAGE)
R sendMessage(@RequestParam("code") String code, @RequestParam("params") String params, @RequestParam("phones") String phones);
R<SmsResponse> sendMessage(@RequestParam("code") String code, @RequestParam("params") String params, @RequestParam("phones") String phones);
/**
* 短信验证码发送

7
blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/utils/SmsUtil.java

@ -17,6 +17,7 @@
package org.springblade.resource.utils;
import org.springblade.core.sms.model.SmsCode;
import org.springblade.core.sms.model.SmsResponse;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.RandomType;
@ -73,9 +74,9 @@ public class SmsUtil {
* @param phones 手机号集合
* @return 发送结果
*/
public static boolean sendMessage(String code, Map<String, String> params, String phones) {
R result = getSmsClient().sendMessage(code, JsonUtil.toJson(params), phones);
return result.isSuccess();
public static SmsResponse sendMessage(String code, Map<String, String> params, String phones) {
R<SmsResponse> result = getSmsClient().sendMessage(code, JsonUtil.toJson(params), phones);
return result.getData();
}
/**

5
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java

@ -21,6 +21,7 @@ import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.core.sms.model.SmsCode;
import org.springblade.core.sms.model.SmsData;
import org.springblade.core.sms.model.SmsResponse;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
@ -153,8 +154,8 @@ public class SmsEndpoint {
* @return 是否发送成功
*/
private R send(SmsData smsData, String phones) {
boolean temp = smsBuilder.template().sendMulti(smsData, Func.toStrList(phones));
return temp ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL);
SmsResponse response = smsBuilder.template().sendMessage(smsData, Func.toStrList(phones));
return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL);
}
}

7
blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/SmsClient.java

@ -19,6 +19,7 @@ package org.springblade.resource.feign;
import lombok.AllArgsConstructor;
import org.springblade.core.sms.model.SmsCode;
import org.springblade.core.sms.model.SmsData;
import org.springblade.core.sms.model.SmsResponse;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func;
@ -43,10 +44,10 @@ public class SmsClient implements ISmsClient {
@Override
@PostMapping(SEND_MESSAGE)
public R sendMessage(String code, String params, String phones) {
public R<SmsResponse> sendMessage(String code, String params, String phones) {
SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class));
boolean temp = smsBuilder.template(code).sendMulti(smsData, Func.toStrList(phones));
return temp ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL);
SmsResponse response = smsBuilder.template(code).sendMessage(smsData, Func.toStrList(phones));
return R.data(response);
}
@Override

Loading…
Cancel
Save