|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|