cn.jiangzeyin.database.run.read.SelectPage Maven / Gradle / Ivy
package cn.jiangzeyin.database.run.read;
import cn.jiangzeyin.database.Page;
import cn.jiangzeyin.database.base.ReadBase;
import cn.jiangzeyin.database.config.DatabaseContextHolder;
import cn.jiangzeyin.database.util.SqlUtil;
import cn.jiangzeyin.database.util.Util;
import cn.jiangzeyin.system.SystemDbLog;
import cn.jiangzeyin.util.Assert;
import cn.jiangzeyin.util.EntityInfo;
import com.alibaba.druid.util.JdbcUtils;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import javax.sql.DataSource;
import java.util.List;
import java.util.Map;
/**
* 分页查询
*
* @author jiangzeyin
*/
public class SelectPage extends ReadBase {
private Page page;
public static final int PageResultType = -2;
/**
*
*/
public SelectPage(Page page) {
// TODO Auto-generated constructor stub
this.page = page;
}
/**
* @param page page
* @param resultType 返回类型
*/
public SelectPage(Page page, int resultType) {
this.page = page;
setResultType(resultType);
}
public Page getPage() {
return page;
}
public void setPage(Page page) {
this.page = page;
}
/**
* @return 结果
* @author jiangzeyin
*/
@SuppressWarnings({"hiding", "unchecked"})
@Override
public T run() {
// TODO Auto-generated method stub
Assert.notNull(page, "page");
try {
String tag = getTag();
if (StringUtils.isEmpty(tag)) {
tag = EntityInfo.getDatabaseName(getTclass());
setTag(tag);
}
String[] pageSql;
if (StringUtils.isEmpty(page.getSql()))
pageSql = SqlUtil.getSelectPageSql(this);
else
pageSql = SqlUtil.getSelectPageSql(page);
DataSource dataSource = DatabaseContextHolder.getReadDataSource(tag);
//setConnection(connection);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy