| | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.sms.config.properties.SmsProperties; |
| | | import com.ruoyi.sms.core.SmsTemplate; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | * @version 4.2.0 |
| | | */ |
| | | @Validated |
| | | @Api(value = "短信演示案例", tags = {"短信演示案例"}) |
| | | @Tag(name ="短信演示案例", description = "短信演示案例") |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/demo/sms") |
| | |
| | | // private final SmsTemplate smsTemplate; // 可以使用spring注入 |
| | | // private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具 |
| | | |
| | | @ApiOperation("发送短信Aliyun") |
| | | @Operation(summary = "发送短信Aliyun") |
| | | @GetMapping("/sendAliyun") |
| | | public R<Object> sendAliyun(@ApiParam("电话号") String phones, |
| | | @ApiParam("模板ID") String templateId) { |
| | | public R<Object> sendAliyun(@Parameter(name = "电话号") String phones, |
| | | @Parameter(name = "模板ID") String templateId) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | |
| | | return R.ok(send); |
| | | } |
| | | |
| | | @ApiOperation("发送短信Tencent") |
| | | @Operation(summary = "发送短信Tencent") |
| | | @GetMapping("/sendTencent") |
| | | public R<Object> sendTencent(@ApiParam("电话号") String phones, |
| | | @ApiParam("模板ID") String templateId) { |
| | | public R<Object> sendTencent(@Parameter(name = "电话号") String phones, |
| | | @Parameter(name = "模板ID") String templateId) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |