From 6d673ecd26ad9fb903f54750318616eee18d3e22 Mon Sep 17 00:00:00 2001 From: zyyang Date: Sat, 14 Nov 2020 14:25:48 +0800 Subject: [PATCH] change --- tests/examples/JDBC/mybatisplus-demo/pom.xml | 5 ++- .../controller/WeatherController.java | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/controller/WeatherController.java diff --git a/tests/examples/JDBC/mybatisplus-demo/pom.xml b/tests/examples/JDBC/mybatisplus-demo/pom.xml index fc1d229330..54d4d82439 100644 --- a/tests/examples/JDBC/mybatisplus-demo/pom.xml +++ b/tests/examples/JDBC/mybatisplus-demo/pom.xml @@ -51,7 +51,10 @@ mysql-connector-java 5.1.47 - + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-devtools diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/controller/WeatherController.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/controller/WeatherController.java new file mode 100644 index 0000000000..24200c088d --- /dev/null +++ b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/controller/WeatherController.java @@ -0,0 +1,35 @@ +package com.taosdata.example.mybatisplusdemo.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.taosdata.example.mybatisplusdemo.domain.Weather; +import com.taosdata.example.mybatisplusdemo.mapper.WeatherMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/weathers") +public class WeatherController { + + @Autowired + private WeatherMapper mapper; + + @GetMapping + public List findAll() { + Integer total = mapper.selectCount(null); + final int pageSize = 3; + Page page = new Page<>(1, pageSize); + Page currentPage = mapper.selectPage(page, null); + System.out.println("total : " + currentPage.getTotal()); + System.out.println("pages : " + currentPage.getPages()); + System.out.println("countId : " + currentPage.getCountId()); + System.out.println("maxLimit: " + currentPage.getMaxLimit()); + + return currentPage.getRecords(); + } + + +} -- GitLab