zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    php详解和优化
    接口
    抽象类
    对象转型
    面向对象2
    Super关键字
    Object类介绍
    有效处理java异常的三个原则
    this关键字
    equals方法
  • 原文地址:https://www.cnblogs.com/sabertobih/p/14106243.html
Copyright © 2011-2022 走看看