♻️ Refactoring code. 重构@Cacheable unless 条件

This commit is contained in:
冷冷 committed 2020-04-16 10:23:58 +08:00
1 parent f96ddc9827
commit 0d343fed34
3 files changed
+9 -5

No files matched your search

@@ -20,16 +20,20 @@ package com.pig4cloud.pigx.common.security.service;
import lombok.Getter;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.User;
import java.util.Collection;
/**
* @author lengleng
* @date 2018/8/20
* @date 2020/4/16
* 扩展用户信息
*/
public class PigxUser extends User {
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
/**
* 用户ID
*/
@@ -84,7 +84,7 @@ public class SysDictController {
* @return 同类型字典
*/
@GetMapping("/type/{type}")
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.size() == 0")
@Cacheable(value = CacheConstants.DICT_DETAILS, key = "#type", unless = "#result.data.isEmpty()")
public R getDictByType(@PathVariable String type) {
return R.ok(sysDictItemService.list(Wrappers
.<SysDictItem>query().lambda()
@@ -60,7 +60,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
private final SysRoleMenuMapper sysRoleMenuMapper;
@Override
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'")
@Cacheable(value = CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result.isEmpty()")
public List<MenuVO> findMenuByRoleId(Integer roleId) {
return baseMapper.listMenusByRoleId(roleId);
}
@@ -114,8 +114,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
/**
* 查询菜单
*
* @param all 全部菜单
* @param type 类型
* @param all 全部菜单
* @param type 类型
* @param parentId 父节点ID
* @return
*/