提交 2a46b084 编写于 作者: MaxKey单点登录官方's avatar MaxKey单点登录官方

GA

上级 d6651d03
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
......
package org.apache.mybatis.jpa;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.URL;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.ibatis.io.VFS;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
/**
* @author Hans Westerbeek
* @author Eddú Meléndez
* @author Kazuki Shimizu
*/
public class SpringBootVFS extends VFS {
private final ResourcePatternResolver resourceResolver;
public SpringBootVFS() {
this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader());
}
@Override
public boolean isValid() {
return true;
}
@Override
protected List<String> list(URL url, String path) throws IOException {
String urlString = url.toString();
String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/");
Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class");
return Stream.of(resources).map(resource -> preserveSubpackageName(baseUrlString, resource, path))
.collect(Collectors.toList());
}
private static String preserveSubpackageName(final String baseUrlString, final Resource resource,
final String rootPath) {
try {
return rootPath + (rootPath.endsWith("/") ? "" : "/")
+ resource.getURL().toString().substring(baseUrlString.length());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
\ No newline at end of file
...@@ -21,7 +21,7 @@ public class DB2Dialect extends Dialect { ...@@ -21,7 +21,7 @@ public class DB2Dialect extends Dialect {
@Override @Override
public String getLimitString(String sql, JpaPagination pagination) { public String getLimitString(String sql, JpaPagination pagination) {
if ( pagination.getPageResults() == 0 ) { if ( pagination.getPageSize() == 0 ) {
return sql + " fetch first " + pagination.getStartRow() + " rows only"; return sql + " fetch first " + pagination.getStartRow() + " rows only";
} }
StringBuilder pagingSelectSql = new StringBuilder( sql.length() + 200 ) StringBuilder pagingSelectSql = new StringBuilder( sql.length() + 200 )
...@@ -30,7 +30,7 @@ public class DB2Dialect extends Dialect { ...@@ -30,7 +30,7 @@ public class DB2Dialect extends Dialect {
) )
.append( sql ) //nest the main query in an outer select .append( sql ) //nest the main query in an outer select
.append(" fetch first ") .append(" fetch first ")
.append(pagination.getPageResults()) .append(pagination.getPageSize())
.append(" rows only ) as inner2_ ) as inner1_ where rownumber_ > " ) .append(" rows only ) as inner2_ ) as inner1_ where rownumber_ > " )
.append(pagination.getStartRow()) .append(pagination.getStartRow())
.append(" order by rownumber_"); .append(" order by rownumber_");
...@@ -40,9 +40,9 @@ public class DB2Dialect extends Dialect { ...@@ -40,9 +40,9 @@ public class DB2Dialect extends Dialect {
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -53,11 +53,11 @@ public class DB2Dialect extends Dialect { ...@@ -53,11 +53,11 @@ public class DB2Dialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -31,7 +31,7 @@ public class DerbyDialect extends Dialect { ...@@ -31,7 +31,7 @@ public class DerbyDialect extends Dialect {
pagingSelectSql.append( " offset " ).append( pagination.getStartRow() ).append( " rows fetch next " ); pagingSelectSql.append( " offset " ).append( pagination.getStartRow() ).append( " rows fetch next " );
} }
pagingSelectSql.append( pagination.getPageResults() ).append( " rows only" ); pagingSelectSql.append( pagination.getPageSize() ).append( " rows only" );
return pagingSelectSql.toString(); return pagingSelectSql.toString();
...@@ -40,9 +40,9 @@ public class DerbyDialect extends Dialect { ...@@ -40,9 +40,9 @@ public class DerbyDialect extends Dialect {
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -53,11 +53,11 @@ public class DerbyDialect extends Dialect { ...@@ -53,11 +53,11 @@ public class DerbyDialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -28,21 +28,21 @@ public class MySQLDialect extends Dialect { ...@@ -28,21 +28,21 @@ public class MySQLDialect extends Dialect {
public String getLimitString(String sql, JpaPagination pagination) { public String getLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
pagination.calculate(); pagination.calculate();
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT "+pagination.getStartRow()+" , " +pagination.getPageResults(); return sql + " LIMIT "+pagination.getStartRow()+" , " +pagination.getPageSize();
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT "+pagination.getPageResults(); return sql + " LIMIT "+pagination.getPageSize();
}else{ }else{
return sql + " LIMIT "+pagination.getPageResults(); return sql + " LIMIT "+pagination.getPageSize();
} }
} }
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -53,11 +53,11 @@ public class MySQLDialect extends Dialect { ...@@ -53,11 +53,11 @@ public class MySQLDialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -21,7 +21,7 @@ public class OracleDialect extends Dialect { ...@@ -21,7 +21,7 @@ public class OracleDialect extends Dialect {
@Override @Override
public String getLimitString(String sql, JpaPagination pagination) { public String getLimitString(String sql, JpaPagination pagination) {
if ( pagination.getPageResults() == 0 ) { if ( pagination.getPageSize() == 0 ) {
return sql + " fetch first " + pagination.getStartRow() + " rows only"; return sql + " fetch first " + pagination.getStartRow() + " rows only";
} }
StringBuilder pagingSelect = new StringBuilder( sql.length() + 200 ) StringBuilder pagingSelect = new StringBuilder( sql.length() + 200 )
...@@ -40,9 +40,9 @@ public class OracleDialect extends Dialect { ...@@ -40,9 +40,9 @@ public class OracleDialect extends Dialect {
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -53,11 +53,11 @@ public class OracleDialect extends Dialect { ...@@ -53,11 +53,11 @@ public class OracleDialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -21,10 +21,10 @@ public class PostgreSQLDialect extends Dialect { ...@@ -21,10 +21,10 @@ public class PostgreSQLDialect extends Dialect {
@Override @Override
public String getLimitString(String sql, JpaPagination pagination) { public String getLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT " + pagination.getPageResults()+" , "+pagination.getStartRow() ; return sql + " LIMIT " + pagination.getPageSize()+" , "+pagination.getStartRow() ;
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT " + pagination.getPageResults(); return sql + " LIMIT " + pagination.getPageSize();
}else{ }else{
return sql + " LIMIT 1000"; return sql + " LIMIT 1000";
} }
...@@ -33,9 +33,9 @@ public class PostgreSQLDialect extends Dialect { ...@@ -33,9 +33,9 @@ public class PostgreSQLDialect extends Dialect {
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -46,11 +46,11 @@ public class PostgreSQLDialect extends Dialect { ...@@ -46,11 +46,11 @@ public class PostgreSQLDialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -23,9 +23,9 @@ public class SQLServerDialect extends Dialect { ...@@ -23,9 +23,9 @@ public class SQLServerDialect extends Dialect {
@Override @Override
public String getLimitString(String sql, JpaPagination pagination) { public String getLimitString(String sql, JpaPagination pagination) {
StringBuilder pagingSelectSql = new StringBuilder( "" ); StringBuilder pagingSelectSql = new StringBuilder( "" );
if(pagination.getPageResults()>0){ if(pagination.getPageSize()>0){
pagingSelectSql.append("SELECT TOP "+pagination.getPageResults()+" * FROM ( "); pagingSelectSql.append("SELECT TOP "+pagination.getPageSize()+" * FROM ( ");
pagingSelectSql.append("SELECT ROW_NUMBER() OVER() AS ROWNUMBER,MYBATIS_QUERY_TEMP_TABLE.* FROM ( "); pagingSelectSql.append("SELECT ROW_NUMBER() OVER() AS ROWNUMBER,MYBATIS_QUERY_TEMP_TABLE.* FROM ( ");
pagingSelectSql.append("MYBATIS_QUERY_TEMP_TABLE ) MYBATIS_QUERY_TEMP_PAGE "); pagingSelectSql.append("MYBATIS_QUERY_TEMP_TABLE ) MYBATIS_QUERY_TEMP_PAGE ");
if(pagination.getStartRow()>0){ if(pagination.getStartRow()>0){
...@@ -40,9 +40,9 @@ public class SQLServerDialect extends Dialect { ...@@ -40,9 +40,9 @@ public class SQLServerDialect extends Dialect {
@Override @Override
public String getPreparedStatementLimitString(String sql, JpaPagination pagination) { public String getPreparedStatementLimitString(String sql, JpaPagination pagination) {
//LIMIT #{pageResults} OFFSET #{startRow} //LIMIT #{pageResults} OFFSET #{startRow}
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
return sql + " LIMIT ? , ?"; return sql + " LIMIT ? , ?";
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
return sql + " LIMIT ? "; return sql + " LIMIT ? ";
}else{ }else{
return sql + " LIMIT ?"; return sql + " LIMIT ?";
...@@ -53,11 +53,11 @@ public class SQLServerDialect extends Dialect { ...@@ -53,11 +53,11 @@ public class SQLServerDialect extends Dialect {
public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) { public void setLimitParamters(PreparedStatement preparedStatement,int parameterSize,JpaPagination pagination) {
try { try {
if(pagination.getPageResults()>0&&pagination.getStartRow()>0){ if(pagination.getPageSize()>0&&pagination.getStartRow()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else if(pagination.getPageResults()>0){ }else if(pagination.getPageSize()>0){
preparedStatement.setInt(++parameterSize, pagination.getPageResults()); preparedStatement.setInt(++parameterSize, pagination.getPageSize());
}else{ }else{
preparedStatement.setInt(++parameterSize, 1000); preparedStatement.setInt(++parameterSize, 1000);
} }
......
...@@ -110,7 +110,7 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -110,7 +110,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
*/ */
public JpaPageResults<T> queryPageResults(T entity) { public JpaPageResults<T> queryPageResults(T entity) {
entity.setPageResultSelectUUID(entity.generateId()); entity.setPageResultSelectUUID(entity.generateId());
entity.setStartRow(calculateStartRow(entity.getPage() ,entity.getPageResults())); entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
entity.setPageable(true); entity.setPageable(true);
List<T> resultslist=getMapper().queryPageResults(entity); List<T> resultslist=getMapper().queryPageResults(entity);
...@@ -118,13 +118,13 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -118,13 +118,13 @@ public class JpaBaseService <T extends JpaBaseDomain> {
Integer totalPage=resultslist.size(); Integer totalPage=resultslist.size();
Integer totalCount = 0; Integer totalCount = 0;
if(entity.getPage()==1&&totalPage<entity.getPageResults()) { if(entity.getPageNumber()==1&&totalPage<entity.getPageSize()) {
totalCount=totalPage; totalCount=totalPage;
}else { }else {
totalCount=parseCount(getMapper().queryPageResultsCount(entity)); totalCount=parseCount(getMapper().queryPageResultsCount(entity));
} }
return new JpaPageResults<T>(entity.getPage(),entity.getPageResults(),totalPage,totalCount,resultslist); return new JpaPageResults<T>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
} }
...@@ -138,7 +138,7 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -138,7 +138,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public JpaPageResults<T> queryPageResults(String mapperId,T entity) { public JpaPageResults<T> queryPageResults(String mapperId,T entity) {
entity.setPageResultSelectUUID(entity.generateId()); entity.setPageResultSelectUUID(entity.generateId());
entity.setStartRow(calculateStartRow(entity.getPage() ,entity.getPageResults())); entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
entity.setPageable(true); entity.setPageable(true);
List<T> resultslist=null; List<T> resultslist=null;
...@@ -152,13 +152,13 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -152,13 +152,13 @@ public class JpaBaseService <T extends JpaBaseDomain> {
Integer totalPage=resultslist.size(); Integer totalPage=resultslist.size();
Integer totalCount = 0; Integer totalCount = 0;
if(entity.getPage()==1&&totalPage<entity.getPageResults()) { if(entity.getPageNumber()==1&&totalPage<entity.getPageSize()) {
totalCount=totalPage; totalCount=totalPage;
}else { }else {
totalCount=parseCount(getMapper().queryPageResultsCount(entity)); totalCount=parseCount(getMapper().queryPageResultsCount(entity));
} }
return new JpaPageResults<T>(entity.getPage(),entity.getPageResults(),totalPage,totalCount,resultslist); return new JpaPageResults<T>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
} }
/** /**
...@@ -373,7 +373,7 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -373,7 +373,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
* @return * @return
*/ */
public Integer calculateTotalPage(JpaBaseDomain entity,Integer totalCount){ public Integer calculateTotalPage(JpaBaseDomain entity,Integer totalCount){
return (totalCount + entity.getPageResults() - 1) / entity.getPageResults(); return (totalCount + entity.getPageSize() - 1) / entity.getPageSize();
} }
/** /**
...@@ -382,7 +382,7 @@ public class JpaBaseService <T extends JpaBaseDomain> { ...@@ -382,7 +382,7 @@ public class JpaBaseService <T extends JpaBaseDomain> {
* @param pageResults * @param pageResults
* @return * @return
*/ */
public Integer calculateStartRow(Integer page,Integer pageResults){ public Integer calculateStartRow(Integer page,Integer pageSize){
return (page - 1) * pageResults; return (page - 1) * pageSize;
} }
} }
...@@ -18,12 +18,12 @@ public class JpaPagination { ...@@ -18,12 +18,12 @@ public class JpaPagination {
* *
*/ */
@JsonIgnore @JsonIgnore
protected int pageResults = 20; protected int pageSize = 20;
/** /**
* *
*/ */
@JsonIgnore @JsonIgnore
protected int page=1; protected int pageNumber=1;
/** /**
* *
*/ */
...@@ -41,7 +41,7 @@ public class JpaPagination { ...@@ -41,7 +41,7 @@ public class JpaPagination {
* *
*/ */
@JsonIgnore @JsonIgnore
protected String sord; protected String sortOrder;
/** /**
* *
*/ */
...@@ -67,16 +67,16 @@ public class JpaPagination { ...@@ -67,16 +67,16 @@ public class JpaPagination {
public void setRows(int rows) { public void setRows(int rows) {
this.rows = rows; this.rows = rows;
this.pageResults = rows; this.pageSize = rows;
calculate(); calculate();
} }
@JsonIgnore @JsonIgnore
public int getPage() { public int getPageNumber() {
return page; return pageNumber;
} }
public void setPage(int page) { public void setPageNumber(int pageNumber) {
this.page = page; this.pageNumber = pageNumber;
calculate(); calculate();
} }
@JsonIgnore @JsonIgnore
...@@ -89,12 +89,12 @@ public class JpaPagination { ...@@ -89,12 +89,12 @@ public class JpaPagination {
setSortKey(); setSortKey();
} }
@JsonIgnore @JsonIgnore
public String getSord() { public String getSortOrder() {
return sord; return sortOrder;
} }
public void setSord(String sord) { public void setSortOrder(String sortOrder) {
this.sord = sord; this.sortOrder = sortOrder;
setSortKey(); setSortKey();
} }
...@@ -116,18 +116,18 @@ public class JpaPagination { ...@@ -116,18 +116,18 @@ public class JpaPagination {
} }
public void calculate() { public void calculate() {
if (this.page >= 1 && this.pageResults > 0){ if (this.pageNumber >= 1 && this.pageSize > 0){
startRow = (this.page - 1) * this.pageResults; startRow = (this.pageNumber - 1) * this.pageSize;
endRow = startRow + this.pageResults; endRow = startRow + this.pageSize;
} }
} }
@JsonIgnore @JsonIgnore
public int getPageResults() { public int getPageSize() {
return pageResults; return pageSize;
} }
public void setPageResults(int pageResults) { public void setPageSize(int pageSize) {
this.pageResults = pageResults; this.pageSize = pageSize;
} }
@JsonIgnore @JsonIgnore
public String getSortKey() { public String getSortKey() {
...@@ -138,8 +138,8 @@ public class JpaPagination { ...@@ -138,8 +138,8 @@ public class JpaPagination {
* create sortKey from sidx & sord,eg order by name asc * create sortKey from sidx & sord,eg order by name asc
*/ */
public void setSortKey() { public void setSortKey() {
if(sidx!=null && sord!=null && !sidx.equals("") && !sord.equals("")){ if(sidx!=null && sortOrder!=null && !sidx.equals("") && !sortOrder.equals("")){
sortKey=" "+sidx+" "+sord+" "; sortKey=" "+sidx+" "+sortOrder+" ";
setOrderBy(); setOrderBy();
} }
...@@ -158,7 +158,7 @@ public class JpaPagination { ...@@ -158,7 +158,7 @@ public class JpaPagination {
*/ */
public void setOrderBy() { public void setOrderBy() {
if(sortKey!=null && !sortKey.equals("")){ if(sortKey!=null && !sortKey.equals("")){
orderBy=" ORDER BY "+sidx+" "+sord+" "; orderBy=" ORDER BY "+sidx+" "+sortOrder+" ";
} }
} }
...@@ -192,9 +192,9 @@ public class JpaPagination { ...@@ -192,9 +192,9 @@ public class JpaPagination {
*/ */
@Override @Override
public String toString() { public String toString() {
return "Pagination [rows=" + rows + ", pageResults=" + pageResults return "Pagination [rows=" + rows + ", pageResults=" + pageSize
+ ", page=" + page + ", startRow=" + startRow + ", endRow=" + ", page=" + pageNumber + ", startRow=" + startRow + ", endRow="
+ endRow + ", sidx=" + sidx + ", sord=" + sord + ", sortKey=" + endRow + ", sidx=" + sidx + ", sord=" + sortOrder + ", sortKey="
+ sortKey + ", orderBy=" + orderBy + ", pageable=" + pageable + sortKey + ", orderBy=" + orderBy + ", pageable=" + pageable
+ "]"; + "]";
} }
......
...@@ -80,8 +80,8 @@ public class MyBatisTestRunner { ...@@ -80,8 +80,8 @@ public class MyBatisTestRunner {
//student.setId("af04d610-6092-481e-9558-30bd63ef783c"); //student.setId("af04d610-6092-481e-9558-30bd63ef783c");
student.setStdGender("M"); student.setStdGender("M");
//student.setStdMajor(政治"); //student.setStdMajor(政治");
student.setPageResults(10); student.setPageSize(10);
student.setPage(2); student.setPageNumber(2);
_logger.info("queryPageResults "+service.queryPageResults(student)); _logger.info("queryPageResults "+service.queryPageResults(student));
} }
...@@ -92,8 +92,8 @@ public class MyBatisTestRunner { ...@@ -92,8 +92,8 @@ public class MyBatisTestRunner {
Students student=new Students(); Students student=new Students();
student.setStdGender("M"); student.setStdGender("M");
//student.setStdMajor(政治"); //student.setStdMajor(政治");
student.setPageResults(10); student.setPageSize(10);
student.setPage(2); student.setPageNumber(2);
_logger.info("queryPageResults by mapperId "+service.queryPageResults("queryPageResults1",student)); _logger.info("queryPageResults by mapperId "+service.queryPageResults("queryPageResults1",student));
......
...@@ -39,8 +39,6 @@ public class DemoDomain extends JpaBaseDomain{ ...@@ -39,8 +39,6 @@ public class DemoDomain extends JpaBaseDomain{
protected int status; protected int status;
protected int sortOrder;
protected String createdBy; protected String createdBy;
@JsonSerialize(using=JsonDateTimeSerializer.class) @JsonSerialize(using=JsonDateTimeSerializer.class)
...@@ -101,23 +99,6 @@ public class DemoDomain extends JpaBaseDomain{ ...@@ -101,23 +99,6 @@ public class DemoDomain extends JpaBaseDomain{
/**
* @return the sortOrder
*/
public int getSortOrder() {
return sortOrder;
}
/**
* @param sortOrder the sortOrder to set
*/
public void setSortOrder(int sortOrder) {
this.sortOrder = sortOrder;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册