| | |
| | | package com.ruoyi.demo.controller; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.service.ConfigService; |
| | | import com.ruoyi.common.core.utils.SpringUtils; |
| | | import com.ruoyi.common.sms.config.properties.SmsProperties; |
| | | import com.ruoyi.common.sms.core.SmsTemplate; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | @RequestMapping("/demo/sms") |
| | | public class SmsController { |
| | | |
| | | private final ConfigService configService; |
| | | private final SmsProperties smsProperties; |
| | | // private final SmsTemplate smsTemplate; // 可以使用spring注入 |
| | | // private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具 |
| | | |
| | |
| | | */ |
| | | @GetMapping("/sendAliyun") |
| | | public R<Object> sendAliyun(String phones, String templateId) { |
| | | if (!Convert.toBool(configService.getConfigValue("sys.account.smsEnabled"))) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | | if (!SpringUtils.containsBean("aliyunSmsTemplate")) { |
| | |
| | | */ |
| | | @GetMapping("/sendTencent") |
| | | public R<Object> sendTencent(String phones, String templateId) { |
| | | if (!Convert.toBool(configService.getConfigValue("sys.account.smsEnabled"))) { |
| | | if (!smsProperties.getEnabled()) { |
| | | return R.fail("当前系统没有开启短信功能!"); |
| | | } |
| | | if (!SpringUtils.containsBean("tencentSmsTemplate")) { |