From 0e45c50f80879d2b556b91664b7ca914971f4d59 Mon Sep 17 00:00:00 2001 From: Parker Date: Tue, 15 Sep 2020 20:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95Redis=20-=20=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opsli-modulars/opsli-modulars-test/pom.xml | 1 + .../modulars/test/web/TestRestController.java | 46 +++++++++++++++++-- opsli-modulars/pom.xml | 7 +++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/opsli-modulars/opsli-modulars-test/pom.xml b/opsli-modulars/opsli-modulars-test/pom.xml index 945261e..be302c7 100644 --- a/opsli-modulars/opsli-modulars-test/pom.xml +++ b/opsli-modulars/opsli-modulars-test/pom.xml @@ -19,5 +19,6 @@ org.opsliframework.boot opsli-plugins-mail + \ No newline at end of file diff --git a/opsli-modulars/opsli-modulars-test/src/main/java/org/opsli/modulars/test/web/TestRestController.java b/opsli-modulars/opsli-modulars-test/src/main/java/org/opsli/modulars/test/web/TestRestController.java index eeed467..3c7da63 100644 --- a/opsli-modulars/opsli-modulars-test/src/main/java/org/opsli/modulars/test/web/TestRestController.java +++ b/opsli-modulars/opsli-modulars-test/src/main/java/org/opsli/modulars/test/web/TestRestController.java @@ -2,8 +2,11 @@ package org.opsli.modulars.test.web; import org.opsli.common.api.ResultVo; import org.opsli.common.base.concroller.BaseController; -import org.opsli.plugins.mail.MailHandler; +import org.opsli.core.cache.pushsub.msgs.DictMsgFactory; +import org.opsli.plugins.mail.MailPlugin; import org.opsli.plugins.mail.model.MailModel; +import org.opsli.plugins.redis.RedisPlugin; +import org.opsli.plugins.redis.pushsub.entity.BaseSubMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -21,7 +24,10 @@ import org.springframework.web.bind.annotation.RestController; public class TestRestController extends BaseController { @Autowired - private MailHandler mailHandler; + private MailPlugin mailPlugin; + + @Autowired + private RedisPlugin redisPlugin; @GetMapping("/sendMail") public ResultVo sendMail(){ @@ -29,8 +35,42 @@ public class TestRestController extends BaseController { mailModel.setTo("meet.carina@foxmail.com"); mailModel.setSubject("测试邮件功能"); mailModel.setContent("

这是哪里呢?


lalalalalalallalalalalal!!!!"); - mailHandler.send(mailModel); + mailPlugin.send(mailModel); return ResultVo.success("发送邮件成功!!!!!!"); } + + /** + * 发送 Redis 订阅消息 + * @return + */ + @GetMapping("/sendMsg") + public ResultVo sendMsg(){ + + BaseSubMessage msg = DictMsgFactory.createMsg("test", "aaa", 123213); + + boolean ret = redisPlugin.sendMessage(msg); + if(ret){ + return ResultVo.success("发送订阅消息成功!!!!!!"); + } + return ResultVo.error("发送订阅消息失败!!!!!!"); + } + + + /** + * 发送 Redis 订阅消息 + * @return + */ + @GetMapping("/redisTest") + public ResultVo redisTest(){ + boolean ret = redisPlugin.put("opsli:test", "12315"); + if(ret){ + Object o = redisPlugin.get("opsli:test"); + ResultVo resultVo = new ResultVo(); + resultVo.put("data",o); + return resultVo; + } + return ResultVo.error("发送订阅消息失败!!!!!!"); + } + } diff --git a/opsli-modulars/pom.xml b/opsli-modulars/pom.xml index 32b32f2..ac97ea7 100644 --- a/opsli-modulars/pom.xml +++ b/opsli-modulars/pom.xml @@ -53,6 +53,13 @@ opsli-core ${project.parent.version} + + + + + + + \ No newline at end of file