@Configuration public
class Mybatisconfig {
@Bean public
pagehelper pagehelper () {
pagehelper Pagehelper = new Pagehelper ();
Properties Properties = new properties ();
Properties.setproperty ("Offsetaspagenum", "true");
Properties.setproperty ("Rowboundswithcount", "true");
Properties.setproperty ("reasonable", "true");
Properties.setproperty ("Supportmethodsarguments", "true");
Properties.setproperty ("Returnpageinfo", "check");
Properties.setproperty ("params", "Count=countsql");
Pagehelper.setproperties (properties);
Return Pagehelper
}
}
@Getter
@Setter Public
class Pagingparam implements serializable{
@Min (value = 1, message = "parameter [Pagenum] Wrong ")
private int pagenum = 1;
@Min (value = 1, message = "parameter [pageSize] incorrect")
private int pageSize =;
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactid>pagehelper </artifactId>
<version>4.2.1</version>
</dependency>
int pagenum = Pagingparam.getpagenum ();
int pageSize = Pagingparam.getpagesize ();
Pagehelper.startpage (Pagenum, pageSize);
pageinfo<userdto> PageInfo = new pageinfo<> (list<t> List); Your data source
pageinfo.settotal (new pageinfo<> (userinformations). Gettotal ());
**return new Result (200, "Successful acquisition of all members", Result.constructdata (PageInfo));
public static <T> map<string, object> constructdata (pageinfo<t> PageInfo)
{map<string, object> data = new treemap<> ();
Data.put ("Total", pageinfo.gettotal ());
Data.put ("Pagenum", Pageinfo.getpagenum ());
if (pageinfo.getlist () = null | | pageinfo.getlist (). Size () = = 0) {data.put ("list", new arraylist<> ());
}else {data.put ("list", Pageinfo.getlist ());
} return data; }
public result selectallpaging (Pagingparam Pagingparam, httpservletrequest res) {int PA
Genum = Pagingparam.getpagenum ();
int pageSize = Pagingparam.getpagesize ();
String organization = "";
Pagehelper.startpage (Pagenum, pageSize);
List<userinformation> userinformations;
try{userinformations = userinformationmapper.selectbyorganization (organization);
}catch (Exception e) {e.printstacktrace ();
Return to new result (400, "unknown error"); } pageinfo<userdto> PageInfo = new Pageinfo<> (Copyfromuserinformationtosuserdto (userinformations, RES)
);
Pageinfo.settotal (New pageinfo<> (userinformations). Gettotal ());
Return to new result (200, "Successful acquisition of all members", Result.constructdata (PageInfo)); }