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
Show 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 {
* @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
from
=
this
.
getSql
(
sqlName
);
// 对SQL语句进行分页处理
SqlData
to
=
from
.
copy
();
to
=
getSqlQueryPara
(
to
,
queryPara
,
false
);
to
.
addCode
(
"{LIMIT}"
,
" LIMIT "
+
pageSize
.
getPageStart
()
+
","
+
pageSize
.
getPageSize
());
// 按照分页查询数据
List
<
Object
>
p
aras
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getQueryPara
(
p
aras
,
to
,
model
);
List
<
Object
>
baseP
aras
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getQueryPara
(
baseP
aras
,
to
,
model
);
// 查询实体数据
List
<
T
>
list
=
this
.
queryWithCache
(
cls
,
sqlName
,
sql
,
p
aras
.
toArray
());
List
<
T
>
list
=
this
.
queryWithCache
(
cls
,
sqlName
,
sql
,
baseP
aras
.
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
);
if
(
fromPageSize
==
null
)
{
// 获取需要执行的SQL语句
fromPageSize
=
this
.
getSql
(
sqlName
);
}
sqlTo
=
sqlTo
.
trim
();
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
sqlTo
.
replaceAll
(
"(?i)(ORDER\\s+BY\\s+[^)]+){0,1}(limit\\s+\\d+,\\d+\\s*){0,1}$"
,
""
)
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
,
paras
.
toArray
())));
data
.
setPageTotal
(
StringHelper
.
toInt
(
queryCellWithCache
(
String
.
format
(
"%s.Size"
,
sqlName
),
sqlSize
,
baseParas
.
toArray
())));
}
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