SpringBoot Case - Employee Management - Paging Query - Analysis

Basic syntax of paging query in MySQL

  • You need to use the limit keyword to implement pagination query operations
    • which contains two parameters
    • Parameter 1: Starting index (starting from 0)
    • Parameter 2: The number of records returned by the query
  • The specific sql statement is as follows
    • select *
      from emp
      limit 0,5;
    • The result of the operation is as follows

Query the data on the nth page, and display m pieces of data on each page

  • Concrete SQL statement
  • select *
    from emp 
    limit (n-1)*m ,m;

Specific page analysis

  •  SQL statement to get the total number of records
  • select count(*) from emp;

Parameters to be passed for front-end and back-end interactions

  • Front end: the number of pages to obtain data pages , the amount of data displayed on each page pagesize
  • Backend: data list (List collection rows), total number of records (total), this data is specified in the interface document
    • The backend responds to the frontend with two different types of data (rows and total), and an entity class (PageBean) needs to be created for encapsulation

The interface document describes the interface

  • Links to interface documentation:
    • [Tencent Documents] Documents required for SpringBoot cases
      https://docs.qq.com/doc/DUkRiTWVaUmFVck9N

The functions implemented by each layer of code in the three-tier architecture

control layer

  • The control layer receives paging parameters page (page number), pageSIze (data volume per page)
  • Call the Service to perform pagination query, and encapsulate the query result into the PageBean object
  • The control layer encapsulates the returned result into the unified response result Reault class and returns it to the front end

persistence layer

  • Obtain the total number of records (total) and data information per page (rows) respectively through two SQL statements

Business Layer

  • Call the methods in the Mapper interface to query the total number of records (total) and the data list (rows)
  • Encapsulate the total and rows of the query in the PageBean object and return it to the control layer

Guess you like

Origin blog.csdn.net/weixin_64939936/article/details/132254947