io.github.biezhi.anima.dialect.MySQLDialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anima Show documentation
Show all versions of anima Show documentation
Operate the database like a stream
package io.github.biezhi.anima.dialect;
import io.github.biezhi.anima.core.SQLParams;
import io.github.biezhi.anima.page.PageRow;
/**
* MySQL dialect
*
* @author biezhi
* @date 2018/3/17
*/
public class MySQLDialect implements Dialect {
@Override
public String paginate(SQLParams sqlParams) {
PageRow pageRow = sqlParams.getPageRow();
int limit = pageRow.getPageSize();
int offset = limit * (pageRow.getPageNum() - 1);
String limitSQL = " LIMIT " + offset + "," + limit;
StringBuilder sql = new StringBuilder();
sql.append(select(sqlParams)).append(limitSQL);
return sql.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy