Browse Source

优化租户缓存刷新逻辑

test
smallchill 5 years ago
parent
commit
7e93899b07
  1. 5
      blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java
  2. 2
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java

5
blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java

@ -23,7 +23,6 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
@ -43,8 +42,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
* 控制器
*
@ -122,7 +119,6 @@ public class TenantController extends BladeController {
@ApiOperation(value = "新增或修改", notes = "传入tenant")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
public R submit(@Valid @RequestBody Tenant tenant) {
CacheUtil.clear(SYS_CACHE);
return R.status(tenantService.submitTenant(tenant));
}
@ -135,7 +131,6 @@ public class TenantController extends BladeController {
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(tenantService.removeTenant(Func.toLongList(ids)));
}

2
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.java

@ -79,6 +79,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submitTenant(Tenant tenant) {
CacheUtil.clear(SYS_CACHE);
if (Func.isEmpty(tenant.getId())) {
List<Tenant> tenants = baseMapper.selectList(Wrappers.<Tenant>query().lambda().eq(Tenant::getIsDeleted, BladeConstant.DB_NOT_DELETED));
List<String> codes = tenants.stream().map(Tenant::getTenantId).collect(Collectors.toList());
@ -164,6 +165,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
@Override
@Transactional(rollbackFor = Exception.class)
public boolean removeTenant(List<Long> ids) {
CacheUtil.clear(SYS_CACHE);
List<Tenant> tenantList = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids));
List<String> tenantIds = tenantList.stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList());
if (tenantIds.contains(BladeConstant.ADMIN_TENANT_ID)) {

Loading…
Cancel
Save