Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
3a10c116
Commit
3a10c116
authored
Aug 05, 2021
by
Zheng Jie
Browse files
[Bug修复](master):代码生成页面分页功能BUG
close
https://github.com/elunez/eladmin/issues/667
parent
6c75df55
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java
View file @
3a10c116
...
...
@@ -42,6 +42,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -75,19 +77,22 @@ public class GeneratorServiceImpl implements GeneratorService {
// 使用预编译防止sql注入
String
sql
=
"select table_name ,create_time , engine, table_collation, table_comment from information_schema.tables "
+
"where table_schema = (select database()) "
+
"and table_name like
?
order by create_time desc"
;
"and table_name like
:table
order by create_time desc"
;
Query
query
=
em
.
createNativeQuery
(
sql
);
query
.
setFirstResult
(
startEnd
[
0
]);
query
.
setMaxResults
(
startEnd
[
1
]
-
startEnd
[
0
]);
query
.
setParameter
(
1
,
StringUtils
.
isNotBlank
(
name
)
?
(
"%"
+
name
+
"%"
)
:
"%%"
);
query
.
setParameter
(
"table"
,
StringUtils
.
isNotBlank
(
name
)
?
(
"%"
+
name
+
"%"
)
:
"%%"
);
List
result
=
query
.
getResultList
();
List
<
TableInfo
>
tableInfos
=
new
ArrayList
<>();
for
(
Object
obj
:
result
)
{
Object
[]
arr
=
(
Object
[])
obj
;
tableInfos
.
add
(
new
TableInfo
(
arr
[
0
],
arr
[
1
],
arr
[
2
],
arr
[
3
],
ObjectUtil
.
isNotEmpty
(
arr
[
4
])
?
arr
[
4
]
:
"-"
));
}
Query
query1
=
em
.
createNativeQuery
(
"SELECT COUNT(*) from information_schema.tables where table_schema = (select database())"
);
Object
totalElements
=
query1
.
getSingleResult
();
String
countSql
=
"select count(1) from information_schema.tables "
+
"where table_schema = (select database()) and table_name like :table"
;
Query
queryCount
=
em
.
createNativeQuery
(
countSql
);
queryCount
.
setParameter
(
"table"
,
StringUtils
.
isNotBlank
(
name
)
?
(
"%"
+
name
+
"%"
)
:
"%%"
);
Object
totalElements
=
queryCount
.
getSingleResult
();
return
PageUtil
.
toPage
(
tableInfos
,
totalElements
);
}
...
...
Write
Preview
Supports
Markdown
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