From 6ab72070d4fda51b790a0f3489c5c1b8d4865f48 Mon Sep 17 00:00:00 2001 From: smallchill Date: Mon, 16 Aug 2021 14:24:28 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E7=9F=AD=E4=BF=A1=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0=E8=B5=84=E6=BA=90=E7=BC=96?= =?UTF-8?q?=E5=8F=B7=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/endpoint/SmsEndpoint.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java index 9dbcb37f..ddf0ef51 100644 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java +++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/SmsEndpoint.java @@ -91,9 +91,9 @@ public class SmsEndpoint { */ @SneakyThrows @PostMapping("/send-message") - public R sendMessage(@RequestParam String params, @RequestParam String phones) { + public R sendMessage(@RequestParam String code, @RequestParam String params, @RequestParam String phones) { SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class)); - return send(smsData, phones); + return send(code, smsData, phones); } //========== 指定短信服务发送(可根据各种场景自定拓展定制, 损失灵活性增加安全性, 推荐用于生产环境) ========== @@ -160,4 +160,17 @@ public class SmsEndpoint { return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL); } + /** + * 通用短信发送接口 + * + * @param code 资源编号 + * @param smsData 短信内容 + * @param phones 手机号列表 + * @return 是否发送成功 + */ + private R send(String code, SmsData smsData, String phones) { + SmsResponse response = smsBuilder.template(code).sendMessage(smsData, Func.toStrList(phones)); + return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL); + } + }