短信验证码

This commit is contained in:
2025-07-07 15:34:02 +08:00
parent 26cba479e2
commit d301e9da3c
5 changed files with 350 additions and 5 deletions

View File

@ -0,0 +1,24 @@
package com.fuyuanshen.common.sms.controller;
import org.dromara.sms4j.api.SmsBlend;
import org.dromara.sms4j.api.entity.SmsResponse;
import org.dromara.sms4j.core.factory.SmsFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author: 默苍璃
* @date: 2025-07-0714:02
*/
@RestController
public class TestSMSController {
@GetMapping("/test")
public void testSend() {
// 在创建完SmsBlend实例后再未手动调用注销的情况下框架会持有该实例可以直接通过指定configId来获取想要的配置如果你想使用
// 负载均衡形式获取实例只要使用getSmsBlend的无参重载方法即可如果你仅有一个配置也可以使用该方法
SmsBlend smsBlend = SmsFactory.getSmsBlend("alibaba");
SmsResponse smsResponse = smsBlend.sendMessage("18656573389", "123");
}
}