Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ec929c7c
authored
Sep 27, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改参数
1 parent
a98cb12d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
ec929c7
...
...
@@ -17,6 +17,8 @@ import com.dituhui.pea.user.entity.*;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.hibernate.query.internal.NativeQueryImpl
;
import
org.hibernate.transform.Transformers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -679,11 +681,15 @@ public class UserService {
if
(
null
!=
search
.
getSource
())
{
querySql
.
append
(
"(su.engineer_code LIKE '%"
+
search
.
getQueryString
()
+
"%' or su.nickname like '%"
+
search
.
getQueryString
()
+
"%' or su.phone like '%"
+
search
.
getQueryString
()
+
"%' or su.email like '%"
+
search
.
getQueryString
()
+
"%' )"
);
}
Long
countNum
=
(
Long
)
entityManager
.
createNativeQuery
(
count
+
querySql
.
toString
()).
getSingleResult
();
BigInteger
countNum
=
(
BigInteger
)
entityManager
.
createNativeQuery
(
count
+
querySql
.
toString
()).
getSingleResult
();
if
(
countNum
.
intValue
()
==
0
)
{
return
pageResult
;
}
List
<
Map
<
String
,
Object
>>
resultList
=
entityManager
.
createNativeQuery
(
select
+
querySql
.
toString
()
+
limit
).
getResultList
();
Query
query
=
entityManager
.
createNativeQuery
(
select
+
querySql
.
toString
()
+
limit
);
//将结果转换为Map,返回后的map中的key是数据库表字段,如果用实体接收,使用@JsonAlias设置一下在反序列化时进行映射
query
.
unwrap
(
NativeQueryImpl
.
class
).
setResultTransformer
(
Transformers
.
ALIAS_TO_ENTITY_MAP
);
List
<
Map
<
String
,
Object
>>
resultList
=
query
.
getResultList
();
List
<
UserInfoSearch
>
list
=
resultList
.
stream
().
map
(
a
->
mapConvertToObject
(
a
,
UserInfoSearch
.
class
)).
collect
(
Collectors
.
toList
());
Integer
pageInt
=
countNum
.
intValue
()
/
search
.
getSize
();
pageResult
.
setDataList
(
list
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment