SpringBoot 之 接口暴露(Redis)

一、生成

dependencies选择
  spring web
  redis reactive

二、目录

三、代码

application.yml

 service/SalesOrderService

@Service
public class SalesOrderService {
    @Autowired
    private StringRedisTemplate srt;

    public List<String> getPage(int page){
        int begin = (page-1)*10;
        int end = begin+9;
        return srt.opsForList().range("salesorder",begin,end);
    }
}

controller/InitCtrl

@RestController
@RequestMapping("/users")
public class InitCtrl {
    @Autowired
    private SalesOrderService sos;

    @RequestMapping("/pages")
    public List<String> init(int page){
        return sos.getPage(page);
    }
}

四、接口访问

localhost:8080/users/pages?page=10

 

posted @ 2020-12-08 23:10  PEAR2020  阅读(1118)  评论(0编辑  收藏  举报