This commit is contained in:
zyyang 2020-11-14 14:25:48 +08:00
parent 3ae555de41
commit 6d673ecd26
2 changed files with 39 additions and 1 deletions

View File

@ -51,7 +51,10 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

View File

@ -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<Weather> findAll() {
Integer total = mapper.selectCount(null);
final int pageSize = 3;
Page<Weather> page = new Page<>(1, pageSize);
Page<Weather> 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();
}
}