Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
94cf000f
Commit
94cf000f
authored
Sep 15, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
d3ed698b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
28 deletions
+37
-28
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+37
-28
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
94cf000f
...
@@ -502,42 +502,51 @@ public abstract class BaseDaoSql {
...
@@ -502,42 +502,51 @@ public abstract class BaseDaoSql {
* @return 查询的结果
* @return 查询的结果
*/
*/
public
<
T
extends
Object
>
PageSizeData
<
T
>
queryPage
(
Class
<
T
>
cls
,
PageSizeReqVo
pageSize
,
String
sqlName
,
Object
model
,
QueryPara
queryPara
)
{
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
>();
PageSizeData
<
T
>
data
=
new
PageSizeData
<
T
>();
data
.
setPageIndex
(
pageSize
.
getPageIndex
());
data
.
setPageIndex
(
pageSize
.
getPageIndex
());
data
.
setPageSize
(
pageSize
.
getPageSize
());
data
.
setPageSize
(
pageSize
.
getPageSize
());
// 对SQL语句进行分页处理
// 设置基本参数值
SqlData
to
=
from
.
copy
();
{
to
=
getSqlQueryPara
(
to
,
queryPara
,
false
);
// 获取需要执行的SQL语句
to
.
addCode
(
"{LIMIT}"
,
" LIMIT "
+
pageSize
.
getPageStart
()
+
","
+
pageSize
.
getPageSize
());
SqlData
from
=
this
.
getSql
(
sqlName
);
// 对SQL语句进行分页处理
// 按照分页查询数据
SqlData
to
=
from
.
copy
();
List
<
Object
>
paras
=
new
ArrayList
<
Object
>();
to
=
getSqlQueryPara
(
to
,
queryPara
,
false
);
String
sql
=
this
.
getQueryPara
(
paras
,
to
,
model
);
to
.
addCode
(
"{LIMIT}"
,
" LIMIT "
+
pageSize
.
getPageStart
()
+
","
+
pageSize
.
getPageSize
());
// 查询实体数据
List
<
T
>
list
=
this
.
queryWithCache
(
cls
,
sqlName
,
sql
,
paras
.
toArray
());
// 按照分页查询数据
data
.
setList
(
list
);
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语句
// 获取分页查询的SQL语句
SqlData
fromPageSize
=
getSql
(
sqlName
+
TableSqlCache
.
PAGE_SIZE_TAG
,
false
);
{
if
(
fromPageSize
!=
null
)
{
SqlData
fromPageSize
=
getSql
(
sqlName
+
TableSqlCache
.
PAGE_SIZE_TAG
,
false
);
sqlTo
=
getQueryPara
(
new
ArrayList
<>(),
fromPageSize
,
model
);
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
;
return
data
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment