| | |
| | | package org.dromara.demo.controller; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.sms.config.properties.SmsProperties; |
| | | import org.dromara.common.sms.core.SmsTemplate; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.sms4j.api.entity.SmsResponse; |
| | | import org.dromara.sms4j.core.factory.SmsFactory; |
| | | import org.dromara.sms4j.provider.enumerate.SupplierType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * 短信演示案例 |
| | |
| | | if (!SpringUtils.containsBean("aliyunSmsTemplate")) { |
| | | return R.fail("阿里云依赖未引入!"); |
| | | } |
| | | SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class); |
| | | Map<String, String> map = new HashMap<>(1); |
| | | LinkedHashMap<String, String> map = new LinkedHashMap<>(1); |
| | | map.put("code", "1234"); |
| | | Object send = smsTemplate.send(phones, templateId, map); |
| | | return R.ok(send); |
| | | SmsResponse smsResponse = SmsFactory.createSmsBlend(SupplierType.ALIBABA).sendMessage(phones, templateId, map); |
| | | return R.ok(smsResponse); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!SpringUtils.containsBean("tencentSmsTemplate")) { |
| | | return R.fail("腾讯云依赖未引入!"); |
| | | } |
| | | SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class); |
| | | Map<String, String> map = new HashMap<>(1); |
| | | LinkedHashMap<String, String> map = new LinkedHashMap<>(1); |
| | | // map.put("2", "测试测试"); |
| | | map.put("1", "1234"); |
| | | Object send = smsTemplate.send(phones, templateId, map); |
| | | return R.ok(send); |
| | | SmsResponse smsResponse = SmsFactory.createSmsBlend(SupplierType.TENCENT).sendMessage(phones, templateId, map); |
| | | return R.ok(smsResponse); |
| | | } |
| | | |
| | | } |