Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Administrator
dsk-cr20g
Commits
13322653
Commit
13322653
authored
Sep 07, 2023
by
施翔轲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化定时批量禁用所有过期租户
parent
b679eb19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
TenantTimerTask.java
...n/src/main/java/com/dsk/web/schedule/TenantTimerTask.java
+5
-4
ISysTenantServiceImpl.java
...va/com/dsk/system/service/impl/ISysTenantServiceImpl.java
+6
-3
No files found.
dsk-admin/src/main/java/com/dsk/web/schedule/TenantTimerTask.java
View file @
13322653
...
...
@@ -20,11 +20,12 @@ public class TenantTimerTask {
private
final
ISysTenantService
tenantService
;
/
/@Value("${schedule.cronExpression}")
//private String cronExpression;
/
**
* 每6小时扫描并禁用已过期租户账号
*/
@Scheduled
(
cron
=
"0 0 0/6 * * *"
)
public
void
handleExpiredTenant
()
{
public
void
updateExpiredTenantStatus
()
{
log
.
info
(
"执行定时禁用已过期租户账号(6h/次)"
);
TenantHelper
.
ignore
(
tenantService:
:
handleExpiredTenant
);
}
...
...
dsk-system/src/main/java/com/dsk/system/service/impl/ISysTenantServiceImpl.java
View file @
13322653
...
...
@@ -74,19 +74,22 @@ public class ISysTenantServiceImpl implements ISysTenantService {
}
/**
*
查询
所有已过期租户
*
禁用
所有已过期租户
*/
@Override
public
void
handleExpiredTenant
()
{
Date
now
=
new
Date
();
//查询所有已过期租户
List
<
SysTenant
>
tenantList
=
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
SysTenant
>()
.
eq
(
SysTenant:
:
getStatus
,
TenantConstants
.
NORMAL
)
.
gt
(
SysTenant:
:
getStartTime
,
now
)
.
or
()
.
lt
(
SysTenant:
:
getExpireTime
,
now
));
//批量禁用已过期租户
tenantList
.
forEach
(
sysTenant
->
sysTenant
.
setStatus
(
TenantConstants
.
DISABLE
));
baseMapper
.
updateBatchById
(
tenantList
);
if
(!
tenantList
.
isEmpty
())
{
tenantList
.
forEach
(
sysTenant
->
sysTenant
.
setStatus
(
TenantConstants
.
DISABLE
));
baseMapper
.
updateBatchById
(
tenantList
);
}
}
// /**
...
...
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