...
|
...
|
@@ -3,6 +3,9 @@ package com.tianbo.warehouse.service.imp; |
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheDelTarget;
|
|
|
import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheEvict;
|
|
|
import com.tianbo.warehouse.annotation.cache.annotation.RedisCacheable;
|
|
|
import com.tianbo.warehouse.dao.PERMISSIONMapper;
|
|
|
import com.tianbo.warehouse.model.PERMISSION;
|
|
|
import com.tianbo.warehouse.service.PermissionService;
|
...
|
...
|
@@ -21,19 +24,23 @@ public class PermissionServiceImp implements PermissionService { |
|
|
PERMISSIONMapper permissionMapper;
|
|
|
|
|
|
@Override
|
|
|
@RedisCacheable(cacheKey = "findAllMenus")
|
|
|
public PageInfo<PERMISSION> findAll(int pageNum, int pageSize, String name) {
|
|
|
Page<PERMISSION> page = PageHelper.startPage(pageNum, 0,true,true,true);
|
|
|
List<PERMISSION> list = permissionMapper.findAll(name);
|
|
|
PageInfo<PERMISSION> result = new PageInfo<>(getPermissionList(list, 0));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@RedisCacheable(cacheKey = "findByRoleId")
|
|
|
public List<PERMISSION> findByRoleId(Integer roleId) {
|
|
|
List<PERMISSION> list = getPermissionList(permissionMapper.findByRoleId(roleId), 0);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp")
|
|
|
public int insertSelective(PERMISSION record) {
|
|
|
return permissionMapper.insertSelective(record);
|
|
|
}
|
...
|
...
|
@@ -50,7 +57,25 @@ public class PermissionServiceImp implements PermissionService { |
|
|
return permissionList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 登录验证成功后获取用户权限列表非树形结构,代表用户所能访问的所有权限。
|
|
|
* 最终存储redis,由gateway读取进行权限判定
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@RedisCacheable(cacheKey = "findByUserIdWithLogin")
|
|
|
public List<PERMISSION> findByUserIdWithLogin(Integer userId){
|
|
|
return permissionMapper.findByUserIdWithLogin(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回用户权限的树形列表
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@RedisCacheable(cacheKey = "getUserMenusTree")//添加缓存
|
|
|
public Map<String, Object> getUserMenus(Integer userId) {
|
|
|
Map<String, Object> data = new HashMap<String, Object>();
|
|
|
try {
|
...
|
...
|
@@ -117,11 +142,18 @@ public class PermissionServiceImp implements PermissionService { |
|
|
|
|
|
|
|
|
@Override
|
|
|
@RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp")
|
|
|
public int updateByPrimaryKeySelective(PERMISSION permission) {
|
|
|
return permissionMapper.updateByPrimaryKeySelective(permission);
|
|
|
}
|
|
|
|
|
|
/** 批量删除
|
|
|
*
|
|
|
* @param permissionId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp")
|
|
|
public int deleteByPrimaryKey(String permissionId) {
|
|
|
if (permissionId.contains(",")) {
|
|
|
try {
|
...
|
...
|
@@ -140,4 +172,10 @@ public class PermissionServiceImp implements PermissionService { |
|
|
}
|
|
|
}
|
|
|
|
|
|
@RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp")
|
|
|
@Override
|
|
|
public void flushCache(){
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|