Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sample-form-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
sample-form-platform
Commits
57b54c6f
Commit
57b54c6f
authored
Sep 25, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加排除事项
parent
470adad7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
42 deletions
+1
-42
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
+1
-42
No files found.
sample-form-manager/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
View file @
57b54c6f
package
com.mortals.xhx.daemon.task
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
/**
* 同步用户,唯一标识为用户名。
*/
@Slf4j
@Service
(
"SyncUserTask"
)
@ConditionalOnExpression
(
"'${platform.type:null}'=='cloud'"
)
public
class
SyncUserTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
IUserFeign
userFeign
;
@Autowired
private
UserService
userService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"同步用户任务"
);
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setPage
(
1
);
userPdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
UserPdu
>>>
resp
=
userFeign
.
list
(
userPdu
);
if
(
resp
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
//同步更新用户,以loginname为唯一标识,密码默认与用户相同
resp
.
getData
().
getData
().
forEach
(
user
->
{
log
.
info
(
"loginName:{}"
,
user
.
getLoginName
());
UserEntity
tempEntity
=
userService
.
selectOne
(
new
UserQuery
().
loginName
(
user
.
getLoginName
()));
if
(
ObjectUtils
.
isEmpty
(
tempEntity
))
{
UserEntity
userEntity
=
new
UserEntity
();
BeanUtils
.
copyProperties
(
user
,
userEntity
,
new
String
[]{
"id"
,
"lastLoginTime"
,
"lastLoginAddress"
});
log
.
info
(
"新增:{}"
,
JSON
.
toJSONString
(
userEntity
));
userService
.
getUserDao
().
insert
(
userEntity
);
}
else
{
//更新基本信息
UserEntity
userEntity
=
new
UserEntity
();
BeanUtils
.
copyProperties
(
user
,
userEntity
,
new
String
[]{
"loginPwd"
,
"userType"
,
"status"
,
"lastLoginTime"
,
"lastLoginAddress"
});
log
.
info
(
"更新:{}"
,
JSON
.
toJSONString
(
userEntity
));
userService
.
getUserDao
().
update
(
userEntity
);
}
});
}
// log.info("syncUserResp:{}", JSON.toJSONString(resp));
userService
.
refreshUser
();
}
...
...
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