package com.changhong.autoform.entity.sql.select;
|
|
import java.util.Map;
|
|
import com.changhong.autoform.entity.sql.Where;
|
|
public class SelectPage extends Select {
|
|
private String tableName;
|
private Integer dataRowNum;
|
private String[] fields;
|
|
private String orderName;
|
private String orderType;
|
private Where where;
|
private Integer startRow;
|
private Integer endRow;
|
|
public Integer getStartRow() {
|
return startRow;
|
}
|
|
public void setStartRow(Integer startRow) {
|
this.startRow = startRow;
|
}
|
|
public Integer getEndRow() {
|
return endRow;
|
}
|
|
public void setEndRow(Integer endRow) {
|
this.endRow = endRow;
|
}
|
|
public SelectPage(String tableName, Where where, String[] fields, Integer startRow, Integer endRow) {
|
super(tableName, where, fields);
|
this.tableName = tableName;
|
this.fields = fields;
|
this.where = where;
|
this.startRow = startRow;
|
this.endRow = endRow;
|
}
|
|
@Override
|
public String getSql() {
|
StringBuilder sql = new StringBuilder();
|
sql.append(" SELECT ");
|
boolean isOne = true;
|
for(String field: fields){
|
if(!isOne){
|
sql.append(',');
|
}
|
sql.append(field);
|
isOne = false;
|
}
|
sql.append(" FROM ").append(getTableName());
|
if(where != null)
|
sql.append(where.getSql());
|
if(getOrderName() != null && !"".equals(getOrderName())){
|
sql.append(" ORDER BY ").append(getOrderName()).append(
|
getOrderType() == null ? " DESC " : " "+getOrderType());
|
}
|
if(getStartRow()!=null && !getStartRow().equals("") && getEndRow()!=null && !getStartRow().equals("")){
|
sql.append(" limit ").append(""+getStartRow()).append(" , ").append(""+getEndRow());
|
}
|
return sql.toString();
|
}
|
|
public String getTableName() {
|
return tableName;
|
}
|
|
public void setTableName(String tableName) {
|
this.tableName = tableName;
|
}
|
|
public Integer getDataRowNum() {
|
return dataRowNum;
|
}
|
|
public void setDataRowNum(Integer dataRowNum) {
|
this.dataRowNum = dataRowNum;
|
}
|
|
public String[] getFields() {
|
return fields;
|
}
|
|
public void setFields(String[] fields) {
|
this.fields = fields;
|
}
|
|
public String getOrderName() {
|
return orderName;
|
}
|
|
public void setOrderName(String orderName) {
|
this.orderName = orderName;
|
}
|
|
public String getOrderType() {
|
return orderType;
|
}
|
|
public void setOrderType(String orderType) {
|
this.orderType = orderType;
|
}
|
|
public Where getWhere() {
|
return where;
|
}
|
|
public void setWhere(Where where) {
|
this.where = where;
|
}
|
|
}
|