测试Redis - 消息订阅

v1.4.1
Parker 4 years ago
parent bc2295f435
commit 0e45c50f80

@ -19,5 +19,6 @@
<groupId>org.opsliframework.boot</groupId> <groupId>org.opsliframework.boot</groupId>
<artifactId>opsli-plugins-mail</artifactId> <artifactId>opsli-plugins-mail</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -2,8 +2,11 @@ package org.opsli.modulars.test.web;
import org.opsli.common.api.ResultVo; import org.opsli.common.api.ResultVo;
import org.opsli.common.base.concroller.BaseController; 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.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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -21,7 +24,10 @@ import org.springframework.web.bind.annotation.RestController;
public class TestRestController extends BaseController { public class TestRestController extends BaseController {
@Autowired @Autowired
private MailHandler mailHandler; private MailPlugin mailPlugin;
@Autowired
private RedisPlugin redisPlugin;
@GetMapping("/sendMail") @GetMapping("/sendMail")
public ResultVo sendMail(){ public ResultVo sendMail(){
@ -29,8 +35,42 @@ public class TestRestController extends BaseController {
mailModel.setTo("meet.carina@foxmail.com"); mailModel.setTo("meet.carina@foxmail.com");
mailModel.setSubject("测试邮件功能"); mailModel.setSubject("测试邮件功能");
mailModel.setContent("<h1>这是哪里呢?</h1><br><font color='red'>lalalalalalallalalalalal!!!!</font>"); mailModel.setContent("<h1>这是哪里呢?</h1><br><font color='red'>lalalalalalallalalalalal!!!!</font>");
mailHandler.send(mailModel); mailPlugin.send(mailModel);
return ResultVo.success("发送邮件成功!!!!!!"); 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("发送订阅消息失败!!!!!!");
}
} }

@ -53,6 +53,13 @@
<artifactId>opsli-core</artifactId> <artifactId>opsli-core</artifactId>
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<!-- 引入Redis模块 -->
<!-- <dependency>-->
<!-- <groupId>org.opsliframework.boot</groupId>-->
<!-- <artifactId>opsli-plugins-redis</artifactId>-->
<!-- <version>${plugins.version}</version>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>
Loading…
Cancel
Save