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 a2430fb5
authored
Sep 27, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改参数
1 parent
dea8d434
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfoSearch.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfoSearch.java
View file @
a2430fb
...
...
@@ -75,6 +75,10 @@ public class UserInfoSearch extends PageRequest implements Serializable {
*/
private
String
roleId
;
/**
* 角色id
*/
private
String
roleName
;
/**
* 用户来源:0:bean 1:新建
*/
private
Integer
source
;
...
...
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
a2430fb
...
...
@@ -689,12 +689,12 @@ public class UserService {
Query
query
=
entityManager
.
createNativeQuery
(
select
+
querySql
.
toString
()
+
limit
);
List
<
Map
<
String
,
Object
>>
resultList1
=
query
.
getResultList
();
log
.
info
(
"resultList1:"
+
JSONObject
.
toJSONString
(
resultList1
));
//
log.info("resultList1:" + JSONObject.toJSONString(resultList1));
//将结果转换为Map,返回后的map中的key是数据库表字段,如果用实体接收,使用@JsonAlias设置一下在反序列化时进行映射
query
.
unwrap
(
NativeQueryImpl
.
class
).
setResultTransformer
(
Transformers
.
ALIAS_TO_ENTITY_MAP
);
List
<
Map
<
String
,
Object
>>
resultList
=
query
.
getResultList
();
log
.
info
(
"resultList:"
+
JSONObject
.
toJSONString
(
resultList
));
List
<
UserInfoSearch
>
list
=
resultList
.
stream
().
map
(
a
->
mapConvertToObject
(
a
,
UserInfoSearch
.
class
)).
collect
(
Collectors
.
toList
());
//
log.info("resultList:" + JSONObject.toJSONString(resultList));
List
<
UserInfoSearch
>
list
=
resultList
.
stream
().
map
(
a
->
mapConvertToObject
(
a
)).
collect
(
Collectors
.
toList
());
Integer
pageInt
=
countNum
.
intValue
()
/
search
.
getSize
();
pageResult
.
setDataList
(
list
);
pageResult
.
setCurrPage
(
search
.
getPage
());
...
...
@@ -708,19 +708,20 @@ public class UserService {
* 将map转换为POJO对象
*
* @param map map
* @param beanClass class
* @return r
*/
public
static
<
T
>
T
mapConvertToObject
(
Map
<
String
,
Object
>
map
,
Class
<
T
>
beanClass
)
{
map
.
remove
(
"password"
);
map
.
remove
(
"CREATED_BY"
);
map
.
remove
(
"LAST_LOGIN_TIME"
);
map
.
remove
(
"wechat_mini_program"
);
map
.
remove
(
"CREATED_TIME"
);
map
.
remove
(
"UPDATED_BY"
);
map
.
remove
(
"UPDATED_TIME"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
return
mapper
.
convertValue
(
map
,
beanClass
);
public
static
UserInfoSearch
mapConvertToObject
(
Map
<
String
,
Object
>
map
)
{
UserInfoSearch
search
=
new
UserInfoSearch
();
search
.
setId
(
map
.
containsKey
(
"id"
)
?
map
.
get
(
"id"
).
toString
()
:
null
);
search
.
setAccount
(
map
.
containsKey
(
"account"
)
?
map
.
get
(
"account"
).
toString
()
:
null
);
search
.
setNickname
(
map
.
containsKey
(
"nickname"
)
?
map
.
get
(
"nickname"
).
toString
()
:
null
);
search
.
setBan
(
map
.
containsKey
(
"ban"
)
?
Integer
.
parseInt
(
map
.
get
(
"ban"
).
toString
())
:
null
);
search
.
setSource
(
map
.
containsKey
(
"source"
)
?
Integer
.
parseInt
(
map
.
get
(
"source"
).
toString
())
:
null
);
search
.
setEmail
(
map
.
containsKey
(
"email"
)
?
map
.
get
(
"email"
).
toString
()
:
null
);
search
.
setPhone
(
map
.
containsKey
(
"phone"
)
?
map
.
get
(
"phone"
).
toString
()
:
null
);
search
.
setEngineerCode
(
map
.
containsKey
(
"engineer_code"
)
?
map
.
get
(
"engineer_code"
).
toString
()
:
null
);
search
.
setRoleName
(
map
.
containsKey
(
"roleName"
)
?
map
.
get
(
"roleName"
).
toString
()
:
null
);
return
search
;
}
/**
...
...
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