package com.fengdu.gas.service;
|
|
import com.fengdu.gas.repository.po.AdminMenuPO;
|
import com.fengdu.gas.repository.impl.AdminMenuMapperImpl;
|
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;
|
import java.util.function.Function;
|
|
@Service
|
public class AdminMenuService {
|
@Autowired
|
private AdminMenuMapperImpl dao;
|
|
/**
|
* 获取所有菜单(缓存)
|
*/
|
//@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#id")
|
//@Cacheable(cacheManager = "json4RedisCacheManager",value = "userCache", key = "#user.id")
|
@Cacheable(cacheManager = "json4RedisCacheManager", value = "adminMenusCache")
|
public List<AdminMenuPO> listAllWithCache() {
|
return dao.getList();
|
}
|
|
// 删除菜单缓存
|
@CacheEvict(cacheNames = "adminMenusCache", allEntries = true)
|
public void removeListAllCache() {
|
}
|
|
|
/**
|
* 获取用户拥有的菜单(缓存)
|
*/
|
@Cacheable(cacheManager = "json4RedisCacheManager", value = "userMenusCache", key = "#id")
|
public List<AdminMenuPO> listUserAllWithCache(Long id, List<Long> listRoleId, Function<List<Long>, List<AdminMenuPO>> funcGetUserMenu) {
|
return funcGetUserMenu.apply(listRoleId);
|
}
|
// 删除指定用户拥有的菜单缓存
|
@CacheEvict(cacheNames = "userMenusCache", key = "#id")
|
public void removeUserMenuCache(Long id) {
|
}
|
// 删除所有用户拥有的菜单缓存
|
@CacheEvict(cacheNames = "userMenusCache", allEntries = true)
|
public void removeAllUserMenuCache() {
|
}
|
}
|