Commit 94cf000f authored by yanzg's avatar yanzg

修改实例化关系

parent d3ed698b
......@@ -502,42 +502,51 @@ public abstract class BaseDaoSql {
* @return 查询的结果
*/
public <T extends Object> PageSizeData<T> queryPage(Class<T> cls, PageSizeReqVo pageSize, String sqlName, Object model, QueryPara queryPara) {
// 获取需要执行的SQL语句
SqlData from = this.getSql(sqlName);
// 设置基本参数值
PageSizeData<T> data = new PageSizeData<T>();
data.setPageIndex(pageSize.getPageIndex());
data.setPageSize(pageSize.getPageSize());
// 对SQL语句进行分页处理
SqlData to = from.copy();
to = getSqlQueryPara(to, queryPara, false);
to.addCode("{LIMIT}", " LIMIT " + pageSize.getPageStart() + "," + pageSize.getPageSize());
// 按照分页查询数据
List<Object> paras = new ArrayList<Object>();
String sql = this.getQueryPara(paras, to, model);
// 查询实体数据
List<T> list = this.queryWithCache(cls, sqlName, sql, paras.toArray());
data.setList(list);
// 设置基本参数值
{
// 获取需要执行的SQL语句
SqlData from = this.getSql(sqlName);
// 对SQL语句进行分页处理
SqlData to = from.copy();
to = getSqlQueryPara(to, queryPara, false);
to.addCode("{LIMIT}", " LIMIT " + pageSize.getPageStart() + "," + pageSize.getPageSize());
// 按照分页查询数据
List<Object> baseParas = new ArrayList<Object>();
String sql = this.getQueryPara(baseParas, to, model);
// 查询实体数据
List<T> list = this.queryWithCache(cls, sqlName, sql, baseParas.toArray());
data.setList(list);
}
// 查询分页总条数的SQL语句
String sqlTo = sql;
// 获取分页查询的SQL语句
SqlData fromPageSize = getSql(sqlName + TableSqlCache.PAGE_SIZE_TAG, false);
if (fromPageSize != null) {
sqlTo = getQueryPara(new ArrayList<>(), fromPageSize, model);
{
SqlData fromPageSize = getSql(sqlName + TableSqlCache.PAGE_SIZE_TAG, false);
if (fromPageSize == null) {
// 获取需要执行的SQL语句
fromPageSize = this.getSql(sqlName);
}
fromPageSize = fromPageSize.copy();
// 按照分页查询数据
List<Object> baseParas = new ArrayList<Object>();
String sql = this.getQueryPara(baseParas, fromPageSize, model);
sql = sql.trim();
// 查询总数据量
String sqlSize = "SELECT COUNT(1) FROM (" +
// 去掉最后一个order by
sql.replaceAll("(?i)(ORDER\\s+BY\\s+[^)]+){0,1}(limit\\s+\\d+,\\d+\\s*){0,1}$", "")
// 去掉第一个 SELECT a.*
.replaceAll("(^SELECT)\\s+a\\.\\*", "$1 1 AS __id")
+ ") t";
data.setPageTotal(StringHelper.toInt(queryCellWithCache(String.format("%s.Size", sqlName), sqlSize, baseParas.toArray())));
}
sqlTo = sqlTo.trim();
// 查询总数据量
String sqlSize = "SELECT COUNT(1) FROM (" +
// 去掉最后一个order by
sqlTo.replaceAll("(?i)(ORDER\\s+BY\\s+[^)]+){0,1}(limit\\s+\\d+,\\d+\\s*){0,1}$", "")
// 去掉第一个 SELECT a.*
.replaceAll("(^SELECT)\\s+a\\.\\*", "$1 1 AS __id")
+ ") t";
data.setPageTotal(StringHelper.toInt(queryCellWithCache(String.format("%s.Size", sqlName), sqlSize, paras.toArray())));
return data;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment