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
7127b465
Commit
7127b465
authored
Sep 07, 2023
by
施翔轲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时批量禁用所有过期租户,6h/次
parent
652a71df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
0 deletions
+56
-0
DskOperateSysApplication.java
...admin/src/main/java/com/dsk/DskOperateSysApplication.java
+2
-0
TenantTimerTask.java
...n/src/main/java/com/dsk/web/schedule/TenantTimerTask.java
+31
-0
ISysTenantService.java
...c/main/java/com/dsk/system/service/ISysTenantService.java
+6
-0
ISysTenantServiceImpl.java
...va/com/dsk/system/service/impl/ISysTenantServiceImpl.java
+17
-0
No files found.
dsk-admin/src/main/java/com/dsk/DskOperateSysApplication.java
View file @
7127b465
...
...
@@ -3,6 +3,7 @@ package com.dsk;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
/**
* 启动程序
...
...
@@ -11,6 +12,7 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
*/
@SpringBootApplication
@EnableScheduling
public
class
DskOperateSysApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
dsk-admin/src/main/java/com/dsk/web/schedule/TenantTimerTask.java
0 → 100644
View file @
7127b465
package
com
.
dsk
.
web
.
schedule
;
import
com.dsk.common.tenant.helper.TenantHelper
;
import
com.dsk.system.service.ISysTenantService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
/**
* 租户相关定时任务类
*
* @author sxk
* @date 2023.09.06
*/
@Component
@RequiredArgsConstructor
@Slf4j
public
class
TenantTimerTask
{
private
final
ISysTenantService
tenantService
;
//@Value("${schedule.cronExpression}")
//private String cronExpression;
@Scheduled
(
cron
=
"0 0 0/6 * * *"
)
public
void
handleExpiredTenant
()
{
TenantHelper
.
ignore
(
tenantService:
:
handleExpiredTenant
);
}
}
\ No newline at end of file
dsk-system/src/main/java/com/dsk/system/service/ISysTenantService.java
View file @
7127b465
...
...
@@ -24,6 +24,11 @@ public interface ISysTenantService {
// */
// List<SysTenantVo> queryList(SysTenantBo bo);
/**
* 禁用所有已过期租户
*/
void
handleExpiredTenant
();
/**
* 查询租户
*/
...
...
@@ -70,4 +75,5 @@ public interface ISysTenantService {
* 基于租户ID查询租户
*/
SysTenantVo
queryByTenantId
(
String
tenantId
);
}
dsk-system/src/main/java/com/dsk/system/service/impl/ISysTenantServiceImpl.java
View file @
7127b465
...
...
@@ -32,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -72,6 +73,22 @@ public class ISysTenantServiceImpl implements ISysTenantService {
return
TableDataInfo
.
build
(
result
);
}
/**
* 查询所有已过期租户
*/
@Override
public
void
handleExpiredTenant
()
{
Date
now
=
new
Date
();
//查询所有已过期租户
List
<
SysTenant
>
tenantList
=
baseMapper
.
selectList
(
new
LambdaQueryWrapper
<
SysTenant
>()
.
gt
(
SysTenant:
:
getStartTime
,
now
)
.
or
()
.
lt
(
SysTenant:
:
getExpireTime
,
now
));
//批量禁用已过期租户
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