Browse Source

🚨 CacheUtil底层增加租户隔离,@CacheEvict注解需统一替换为CacheUtil.clear方法

test
smallchill 5 years ago
parent
commit
b6eee6d2a9
  1. 14
      blade-ops/blade-resource/src/main/java/org/springblade/resource/controller/OssController.java
  2. 12
      blade-ops/blade-resource/src/main/java/org/springblade/resource/controller/SmsController.java
  3. 12
      blade-service/blade-system/src/main/java/org/springblade/system/controller/ApiScopeController.java
  4. 12
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java
  5. 5
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java
  6. 5
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java
  7. 5
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java
  8. 6
      blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java
  9. 6
      blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java
  10. 8
      blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java
  11. 7
      blade-service/blade-system/src/main/java/org/springblade/system/controller/TenantController.java
  12. 6
      blade-service/blade-system/src/main/java/org/springblade/system/controller/TopMenuController.java
  13. 3
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java
  14. 4
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java
  15. 10
      blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

14
blade-ops/blade-resource/src/main/java/org/springblade/resource/controller/OssController.java

@ -23,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.annotation.PreAuth;
@ -30,10 +31,9 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.resource.entity.Oss;
import org.springblade.resource.vo.OssVO;
import org.springblade.resource.service.IOssService;
import org.springblade.resource.vo.OssVO;
import org.springblade.resource.wrapper.OssWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -96,8 +96,8 @@ public class OssController extends BladeController {
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入oss")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R save(@Valid @RequestBody Oss oss) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(ossService.save(oss));
}
@ -107,8 +107,8 @@ public class OssController extends BladeController {
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入oss")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R update(@Valid @RequestBody Oss oss) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(ossService.updateById(oss));
}
@ -118,8 +118,8 @@ public class OssController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入oss")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Oss oss) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(ossService.submit(oss));
}
@ -130,8 +130,8 @@ public class OssController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(ossService.deleteLogic(Func.toLongList(ids)));
}
@ -142,8 +142,8 @@ public class OssController extends BladeController {
@PostMapping("/enable")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "配置启用", notes = "传入id")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R enable(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(ossService.enable(id));
}

12
blade-ops/blade-resource/src/main/java/org/springblade/resource/controller/SmsController.java

@ -23,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.annotation.PreAuth;
@ -33,7 +34,6 @@ import org.springblade.resource.entity.Sms;
import org.springblade.resource.service.ISmsService;
import org.springblade.resource.vo.SmsVO;
import org.springblade.resource.wrapper.SmsWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -97,8 +97,8 @@ public class SmsController extends BladeController {
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入sms")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R save(@Valid @RequestBody Sms sms) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(smsService.save(sms));
}
@ -108,8 +108,8 @@ public class SmsController extends BladeController {
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入sms")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R update(@Valid @RequestBody Sms sms) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(smsService.updateById(sms));
}
@ -119,8 +119,8 @@ public class SmsController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入sms")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Sms sms) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(smsService.submit(sms));
}
@ -131,8 +131,8 @@ public class SmsController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(smsService.deleteLogic(Func.toLongList(ids)));
}
@ -142,8 +142,8 @@ public class SmsController extends BladeController {
@PostMapping("/enable")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "配置启用", notes = "传入id")
@CacheEvict(cacheNames = {RESOURCE_CACHE}, allEntries = true)
public R enable(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
CacheUtil.clear(RESOURCE_CACHE);
return R.status(smsService.enable(id));
}

12
blade-service/blade-system/src/main/java/org/springblade/system/controller/ApiScopeController.java

@ -17,12 +17,13 @@
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
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.tool.api.R;
@ -31,7 +32,6 @@ import org.springblade.system.entity.ApiScope;
import org.springblade.system.service.IApiScopeService;
import org.springblade.system.vo.ApiScopeVO;
import org.springblade.system.wrapper.ApiScopeWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@ -78,9 +78,9 @@ public class ApiScopeController extends BladeController {
*/
@PostMapping("/save")
@ApiOperationSupport(order = 3)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "新增", notes = "传入dataScope")
public R save(@Valid @RequestBody ApiScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(apiScopeService.save(dataScope));
}
@ -89,9 +89,9 @@ public class ApiScopeController extends BladeController {
*/
@PostMapping("/update")
@ApiOperationSupport(order = 4)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "修改", notes = "传入dataScope")
public R update(@Valid @RequestBody ApiScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(apiScopeService.updateById(dataScope));
}
@ -100,9 +100,9 @@ public class ApiScopeController extends BladeController {
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "新增或修改", notes = "传入dataScope")
public R submit(@Valid @RequestBody ApiScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(apiScopeService.saveOrUpdate(dataScope));
}
@ -112,9 +112,9 @@ public class ApiScopeController extends BladeController {
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(apiScopeService.deleteLogic(Func.toLongList(ids)));
}

12
blade-service/blade-system/src/main/java/org/springblade/system/controller/DataScopeController.java

@ -17,12 +17,13 @@
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
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.tool.api.R;
@ -31,7 +32,6 @@ import org.springblade.system.entity.DataScope;
import org.springblade.system.service.IDataScopeService;
import org.springblade.system.vo.DataScopeVO;
import org.springblade.system.wrapper.DataScopeWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@ -78,9 +78,9 @@ public class DataScopeController extends BladeController {
*/
@PostMapping("/save")
@ApiOperationSupport(order = 3)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "新增", notes = "传入dataScope")
public R save(@Valid @RequestBody DataScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(dataScopeService.save(dataScope));
}
@ -89,9 +89,9 @@ public class DataScopeController extends BladeController {
*/
@PostMapping("/update")
@ApiOperationSupport(order = 4)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "修改", notes = "传入dataScope")
public R update(@Valid @RequestBody DataScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(dataScopeService.updateById(dataScope));
}
@ -100,9 +100,9 @@ public class DataScopeController extends BladeController {
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 5)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "新增或修改", notes = "传入dataScope")
public R submit(@Valid @RequestBody DataScope dataScope) {
CacheUtil.clear(SYS_CACHE);
return R.status(dataScopeService.saveOrUpdate(dataScope));
}
@ -112,9 +112,9 @@ public class DataScopeController extends BladeController {
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 6)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(dataScopeService.deleteLogic(Func.toLongList(ids)));
}

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

@ -21,6 +21,7 @@ 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.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
@ -129,8 +130,8 @@ public class DeptController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入dept")
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Dept dept) {
CacheUtil.clear(SYS_CACHE);
return R.status(deptService.submit(dept));
}
@ -140,8 +141,8 @@ public class DeptController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "删除", notes = "传入ids")
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(deptService.removeDept(ids));
}

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

@ -21,6 +21,7 @@ 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.tool.api.R;
@ -139,8 +140,8 @@ public class DictBizController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入dict")
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody DictBiz dict) {
CacheUtil.clear(DICT_CACHE);
return R.status(dictService.submit(dict));
}
@ -151,8 +152,8 @@ public class DictBizController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "删除", notes = "传入ids")
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(DICT_CACHE);
return R.status(dictService.removeDict(ids));
}

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

@ -21,6 +21,7 @@ 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.tool.api.R;
@ -141,8 +142,8 @@ public class DictController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入dict")
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Dict dict) {
CacheUtil.clear(DICT_CACHE);
return R.status(dictService.submit(dict));
}
@ -152,9 +153,9 @@ public class DictController extends BladeController {
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(DICT_CACHE);
return R.status(dictService.removeDict(ids));
}

6
blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java

@ -20,6 +20,7 @@ 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.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
@ -44,6 +45,7 @@ import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
/**
@ -140,11 +142,11 @@ public class MenuController extends BladeController {
* 新增或修改
*/
@PostMapping("/submit")
@CacheEvict(cacheNames = {MENU_CACHE}, allEntries = true)
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入menu")
public R submit(@Valid @RequestBody Menu menu) {
CacheUtil.clear(MENU_CACHE);
return R.status(menuService.submit(menu));
}
@ -153,11 +155,11 @@ public class MenuController extends BladeController {
* 删除
*/
@PostMapping("/remove")
@CacheEvict(cacheNames = {MENU_CACHE}, allEntries = true)
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@ApiOperationSupport(order = 7)
@ApiOperation(value = "删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(MENU_CACHE);
return R.status(menuService.removeMenu(ids));
}

6
blade-service/blade-system/src/main/java/org/springblade/system/controller/ParamController.java

@ -21,13 +21,13 @@ 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.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.entity.Param;
import org.springblade.system.service.IParamService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -82,8 +82,8 @@ public class ParamController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "新增或修改", notes = "传入param")
@CacheEvict(cacheNames = {PARAM_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Param param) {
CacheUtil.clear(PARAM_CACHE);
return R.status(paramService.saveOrUpdate(param));
}
@ -94,8 +94,8 @@ public class ParamController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@CacheEvict(cacheNames = {PARAM_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(PARAM_CACHE);
return R.status(paramService.deleteLogic(Func.toLongList(ids)));
}

8
blade-service/blade-system/src/main/java/org/springblade/system/controller/RoleController.java

@ -21,6 +21,7 @@ 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.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
@ -34,7 +35,6 @@ import org.springblade.system.service.IRoleService;
import org.springblade.system.vo.GrantVO;
import org.springblade.system.vo.RoleVO;
import org.springblade.system.wrapper.RoleWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -102,8 +102,8 @@ public class RoleController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增或修改", notes = "传入role")
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Role role) {
CacheUtil.clear(SYS_CACHE);
return R.status(roleService.submit(role));
}
@ -114,8 +114,8 @@ public class RoleController extends BladeController {
@PostMapping("/remove")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "删除", notes = "传入ids")
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(roleService.removeByIds(Func.toLongList(ids)));
}
@ -125,8 +125,8 @@ public class RoleController extends BladeController {
@PostMapping("/grant")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合")
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R grant(@RequestBody GrantVO grantVO) {
CacheUtil.clear(SYS_CACHE);
boolean temp = roleService.grant(grantVO.getRoleIds(), grantVO.getMenuIds(), grantVO.getDataScopeIds(), grantVO.getApiScopeIds());
return R.status(temp);
}

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

@ -23,6 +23,7 @@ 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;
@ -121,8 +122,8 @@ public class TenantController extends BladeController {
@ApiOperationSupport(order = 5)
@ApiOperation(value = "新增或修改", notes = "传入tenant")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody Tenant tenant) {
CacheUtil.clear(SYS_CACHE);
return R.status(tenantService.saveTenant(tenant));
}
@ -134,8 +135,8 @@ public class TenantController extends BladeController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
CacheUtil.clear(SYS_CACHE);
return R.status(tenantService.removeTenant(Func.toLongList(ids)));
}
@ -146,8 +147,8 @@ public class TenantController extends BladeController {
@ApiOperationSupport(order = 7)
@ApiOperation(value = "授权配置", notes = "传入ids,accountNumber,expireTime")
@PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@CacheEvict(cacheNames = {SYS_CACHE}, allEntries = true)
public R setting(@ApiParam(value = "主键集合", required = true) @RequestParam String ids, @ApiParam(value = "账号额度") Integer accountNumber, @ApiParam(value = "过期时间") Date expireTime) {
CacheUtil.clear(SYS_CACHE);
boolean temp = tenantService.update(
Wrappers.<Tenant>update().lambda()
.set(Tenant::getAccountNumber, accountNumber)

6
blade-service/blade-system/src/main/java/org/springblade/system/controller/TopMenuController.java

@ -17,12 +17,13 @@
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
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.annotation.PreAuth;
@ -123,9 +124,10 @@ public class TopMenuController extends BladeController {
@PostMapping("/grant")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "顶部菜单配置", notes = "传入topMenuId集合以及menuId集合")
@CacheEvict(cacheNames = {SYS_CACHE, MENU_CACHE}, allEntries = true)
public R grant(@ApiParam(value = "topMenuId集合", required = true) @RequestParam String topMenuIds,
@ApiParam(value = "menuId集合", required = true) @RequestParam String menuIds) {
CacheUtil.clear(SYS_CACHE);
CacheUtil.clear(MENU_CACHE);
boolean temp = topMenuService.grant(Func.toLongList(topMenuIds), Func.toLongList(menuIds));
return R.status(temp);
}

3
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -70,7 +71,6 @@ public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBiz> impl
}
@Override
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
public boolean submit(DictBiz dict) {
LambdaQueryWrapper<DictBiz> lqw = Wrappers.<DictBiz>query().lambda().eq(DictBiz::getCode, dict.getCode()).eq(DictBiz::getDictKey, dict.getDictKey());
Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(DictBiz::getId, dict.getId()));
@ -81,6 +81,7 @@ public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBiz> impl
dict.setParentId(BladeConstant.TOP_PARENT_ID);
}
dict.setIsDeleted(BladeConstant.DB_NOT_DELETED);
CacheUtil.clear(DICT_CACHE);
return saveOrUpdate(dict);
}

4
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -40,6 +41,7 @@ import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
@ -76,7 +78,6 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
}
@Override
@CacheEvict(cacheNames = {DICT_CACHE}, allEntries = true)
public boolean submit(Dict dict) {
LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey());
Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId()));
@ -87,6 +88,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
dict.setParentId(BladeConstant.TOP_PARENT_ID);
}
dict.setIsDeleted(BladeConstant.DB_NOT_DELETED);
CacheUtil.clear(DICT_CACHE);
return saveOrUpdate(dict);
}

10
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@ -25,6 +25,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -42,7 +43,6 @@ import org.springblade.system.user.excel.UserImporter;
import org.springblade.system.user.service.IUserService;
import org.springblade.system.user.vo.UserVO;
import org.springblade.system.user.wrapper.UserWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;
@ -130,8 +130,8 @@ public class UserController {
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增或修改", notes = "传入User")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
@CacheEvict(cacheNames = {USER_CACHE}, allEntries = true)
public R submit(@Valid @RequestBody User user) {
CacheUtil.clear(USER_CACHE);
return R.status(userService.submit(user));
}
@ -141,8 +141,8 @@ public class UserController {
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入User")
@CacheEvict(cacheNames = {USER_CACHE}, allEntries = true)
public R update(@Valid @RequestBody User user) {
CacheUtil.clear(USER_CACHE);
return R.status(userService.updateUser(user));
}
@ -153,8 +153,8 @@ public class UserController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "删除", notes = "传入id集合")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
@CacheEvict(cacheNames = {USER_CACHE}, allEntries = true)
public R remove(@RequestParam String ids) {
CacheUtil.clear(USER_CACHE);
return R.status(userService.removeUser(ids));
}
@ -199,8 +199,8 @@ public class UserController {
@PostMapping("/update-info")
@ApiOperationSupport(order = 10)
@ApiOperation(value = "修改基本信息", notes = "传入User")
@CacheEvict(cacheNames = {USER_CACHE}, allEntries = true)
public R updateInfo(@Valid @RequestBody User user) {
CacheUtil.clear(USER_CACHE);
return R.status(userService.updateUserInfo(user));
}

Loading…
Cancel
Save