feat: 删除部分Redis缓存

This commit is contained in:
bunny 2024-10-25 10:46:34 +08:00
parent 77334e3357
commit adc1d89a91
2 changed files with 0 additions and 13 deletions

View File

@ -20,8 +20,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -74,7 +72,6 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
* @return 所有权限列表
*/
@Override
@Cacheable(cacheNames = "power", key = "'allPower'", cacheManager = "cacheManagerWithMouth")
public List<PowerVo> getAllPowers() {
List<Power> powerList = list();
return powerList.stream().map(power -> {
@ -90,7 +87,6 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
* @param dto 权限添加
*/
@Override
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
public void addPower(@Valid PowerAddDto dto) {
// 添加权限时确保权限码和请求地址是唯一的
LambdaQueryWrapper<Power> wrapper = new LambdaQueryWrapper<>();
@ -112,7 +108,6 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
* @param dto 权限更新
*/
@Override
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
public void updatePower(@Valid PowerUpdateDto dto) {
Long id = dto.getId();
List<Power> powerList = list(Wrappers.<Power>lambdaQuery().eq(Power::getId, id));
@ -131,7 +126,6 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
* @param ids 删除id列表
*/
@Override
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
public void deletePower(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
@ -149,7 +143,6 @@ public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements
* @param dto 批量修改权限表单
*/
@Override
@CacheEvict(cacheNames = "power", key = "'allPower'", beforeInvocation = true)
public void updateBatchByPowerWithParentId(PowerUpdateBatchByParentIdDto dto) {
List<Power> powerList = dto.getIds().stream().map(id -> {
Power power = new Power();

View File

@ -20,8 +20,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
@ -79,7 +77,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
* @return 所有角色列表
*/
@Override
@Cacheable(cacheNames = "role", key = "'allRole'", cacheManager = "cacheManagerWithMouth")
public List<RoleVo> getAllRoles() {
return list().stream().map(role -> {
RoleVo roleVo = new RoleVo();
@ -94,7 +91,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
* @param dto 角色添加
*/
@Override
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
public void addRole(@Valid RoleAddDto dto) {
// 判断角色码是否被添加过
List<Role> roleList = list(Wrappers.<Role>lambdaQuery().eq(Role::getRoleCode, dto.getRoleCode()));
@ -112,7 +108,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
* @param dto 角色更新
*/
@Override
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
public void updateRole(@Valid RoleUpdateDto dto) {
// 查询更新的角色是否存在
List<Role> roleList = list(Wrappers.<Role>lambdaQuery().eq(Role::getId, dto.getId()));
@ -130,7 +125,6 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
* @param ids 删除id列表
*/
@Override
@CacheEvict(cacheNames = "role", key = "'allRole'", beforeInvocation = true)
public void deleteRole(List<Long> ids) {
// 判断数据请求是否为空
if (ids.isEmpty()) throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);