Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
4861ed0c
Commit
4861ed0c
authored
Jul 13, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add user attached migration.
parent
fa5c49d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
UserAttachedMigrationJobHandler.java
...antgroup/xyqb/xxlJob/UserAttachedMigrationJobHandler.java
+52
-0
No files found.
src/main/java/cn/quantgroup/xyqb/xxlJob/UserAttachedMigrationJobHandler.java
0 → 100644
View file @
4861ed0c
package
cn
.
quantgroup
.
xyqb
.
xxlJob
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.entity.UserAttached
;
import
cn.quantgroup.xyqb.entity.UserInfoEntity
;
import
cn.quantgroup.xyqb.repository.IUserAttachedRepository
;
import
cn.quantgroup.xyqb.repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
com.xxl.job.core.biz.model.ReturnT
;
import
com.xxl.job.core.handler.annotation.XxlJob
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Component
;
/**
* 第一次上线对历史数据清理程序
*/
@Component
public
class
UserAttachedMigrationJobHandler
{
@Autowired
private
IUserAttachedRepository
userAttachedRepository
;
@Autowired
private
IUserInfoRepository
userInfoRepository
;
@XxlJob
(
value
=
"userTagCleanJobHandler"
)
public
ReturnT
<
String
>
execute
()
{
Pageable
pageable
=
new
PageRequest
(
0
,
500
);
Page
<
UserAttached
>
userAttachedPage
=
userAttachedRepository
.
findAll
(
pageable
);
while
(
CollectionUtils
.
isNotEmpty
(
userAttachedPage
.
getContent
()))
{
userAttachedPage
.
getContent
().
forEach
(
i
->
{
UserInfoEntity
userInfoEntity
=
userInfoRepository
.
findByUserIdAndTenantId
(
i
.
getUserId
(),
UserConstant
.
defaultTenantId
);
if
(
userInfoEntity
==
null
)
{
userInfoEntity
=
new
UserInfoEntity
();
userInfoEntity
.
setUserId
(
i
.
getUserId
());
userInfoEntity
.
setTenantId
(
UserConstant
.
defaultTenantId
);
}
userInfoEntity
.
setPhoto
(
i
.
getAvatar
());
userInfoEntity
.
setNickName
(
i
.
getNick
());
userInfoRepository
.
save
(
userInfoEntity
);
});
pageable
=
new
PageRequest
(
pageable
.
getPageNumber
()
+
1
,
pageable
.
getPageSize
());
userAttachedPage
=
userAttachedRepository
.
findAll
(
pageable
);
}
return
ReturnT
.
SUCCESS
;
}
}
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