com.github.chengyuxing.sql.page.impl.MysqlPageHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rabbit-sql Show documentation
Show all versions of rabbit-sql Show documentation
Light wrapper of JDBC, support ddl, dml, query, plsql/procedure/function, transaction and manage sql
file.
package com.github.chengyuxing.sql.page.impl;
import com.github.chengyuxing.sql.Args;
import com.github.chengyuxing.sql.page.PageHelper;
/**
* Mysql/MariaDB page helper,
* e.g.
*
* select * from ... limit :{@link #START_NUM_KEY}, :{@link #END_NUM_KEY};
*
*
* @see #pagedArgs()
*/
public class MysqlPageHelper extends PageHelper {
public int start() {
return (pageNumber - 1) * pageSize;
}
public int size() {
if (recordCount == 0) {
return 0;
}
return pageSize;
}
@Override
public String pagedSql(String sql) {
return sql + " limit " + start() + ", " + size();
}
@Override
public Args pagedArgs() {
return Args.of(START_NUM_KEY, start()).add(END_NUM_KEY, size());
}
}