This is the 11th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021

Following our study of code generation tools in the Compliance management system a few days ago, we found that there is much more to be learned in the compliance system. Today we are going to learn about paging in the Joy management system.

If the management system is front-to-back (to be precise, if there is a front-to-back version).

The front end

Pagination = pageNum = pageSize = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination = Pagination

<! --> <pagination :total="total" :page.sync=" queryparams.pagenum ":limit. Sync =" queryparams.pagesize" @pagination="fetchData" /> query: { keyword: undefined, // otherquery..... PageNum: 1, pageSize: 10}, result: {// request result total: 0, rows: []} // return the result API (this.queryParams). Then (response => {this.result = response; });Copy the code

The back-end paging

Backend paging is interesting, so let’s first look at the paging code in the backend interface.

We grab the front end: system management -> Log management -> operation log interface, after browser F12 debugging, we can find its interface address is:

/monitor/operlog/list? pageNum=1&pageSize=10Copy the code

We find the corresponding interface found in com in the background. Ruoyi. Web. Controller. The monitor. The SysOperlogController list methods. The method code is as follows:

    @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysOperLog operLog)
    {
        startPage();
        List<SysOperLog> list = operLogService.selectOperLogList(operLog);
        return getDataTable(list);
    }
Copy the code

Oddly, we don’t see paging parameters getting and parsing, so how does the back end actually implement paging?

This interface has three characteristics: first, the return value type is TableDataInfo; second, the first line of interface code startPage(); third, the last line of interface :getDataTable(list).

First, let’s look at the data structure of TableDataInfo.

/** * Table paging data object **@author ruoyi
 */
public class TableDataInfo implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** Total records */
    private long total;

    /** List data */
    privateList<? > rows;/** Message status code */
    private int code;

    /** Message content */
    private String msg;
    
    // The rest of the constructor and setter and getter methods are not attached
    
}
Copy the code

As you can see, the data type matches the front-end, so how is this data constructed in the interface?

What happens when the key code startPage()? How does genDataTable(List) convert a list to TableDataInfo?