From 416088a2ded29ab7782b213e98c5f914852febce Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 06 五月 2022 18:07:43 +0800 Subject: [PATCH] add 增加 demo 短信演示案例 --- ruoyi-demo/pom.xml | 16 ++++++++ ruoyi-demo/src/main/java/com/ruoyi/demo/controller/SmsController.java | 53 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 0 deletions(-) diff --git a/ruoyi-demo/pom.xml b/ruoyi-demo/pom.xml index 2fe2c18..ca5d965 100644 --- a/ruoyi-demo/pom.xml +++ b/ruoyi-demo/pom.xml @@ -23,6 +23,22 @@ <artifactId>ruoyi-common</artifactId> </dependency> + <dependency> + <groupId>com.ruoyi</groupId> + <artifactId>ruoyi-sms</artifactId> + </dependency> + + <!-- 鐭俊 鐢ㄥ摢涓鍏ュ摢涓緷璧� --> +<!-- <dependency>--> +<!-- <groupId>com.aliyun</groupId>--> +<!-- <artifactId>dysmsapi20170525</artifactId>--> +<!-- </dependency>--> + + <dependency> + <groupId>com.tencentcloudapi</groupId> + <artifactId>tencentcloud-sdk-java</artifactId> + </dependency> + </dependencies> </project> diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/SmsController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/SmsController.java new file mode 100644 index 0000000..de8f212 --- /dev/null +++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/SmsController.java @@ -0,0 +1,53 @@ +package com.ruoyi.demo.controller; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.sms.core.SmsTemplate; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; +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; + +/** + * 鐭俊婕旂ず妗堜緥 + * + * @author Lion Li + * @version 4.2.0 + */ +@Validated +@Api(value = "鐭俊婕旂ず妗堜緥", tags = {"鐭俊婕旂ず妗堜緥"}) +@RequiredArgsConstructor +@RestController +@RequestMapping("/demo/sms") +public class SmsController { + + private final SmsTemplate smsTemplate; + + @ApiOperation("鍙戦�佺煭淇liyun") + @GetMapping("/sendAliyun") + public R<Object> sendSimpleMessage(@ApiParam("鐢佃瘽鍙�") String phones, + @ApiParam("妯℃澘ID") String templateId) { + Map<String, String> map = new HashMap<>(1); + map.put("code", "1234"); + Object send = smsTemplate.send(phones, templateId, map); + return R.ok(send); + } + + @ApiOperation("鍙戦�佺煭淇encent") + @GetMapping("/sendTencent") + public R<Object> sendMessageWithAttachment(@ApiParam("鐢佃瘽鍙�") String phones, + @ApiParam("妯℃澘ID") String templateId) { + Map<String, String> map = new HashMap<>(1); +// map.put("2", "娴嬭瘯娴嬭瘯"); + map.put("1", "1234"); + Object send = smsTemplate.send(phones, templateId, map); + return R.ok(send); + } + +} -- Gitblit v1.9.3