Commit 2e1ee2a6 authored by eddie.woo's avatar eddie.woo

样式

parent 584a7aae
......@@ -7,23 +7,22 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dao.MenuMapper;
import pwc.taxtech.atms.dao.PermissionMapper;
import pwc.taxtech.atms.dao.RolePermissionMapper;
import pwc.taxtech.atms.dao.UserRoleMapper;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dto.MenuDisplayDto;
import pwc.taxtech.atms.dto.MenuDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.ApplicationException;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
*/
@Service
public class MenuServiceImpl {
public class MenuServiceImpl extends BaseService{
private static final Logger logger = LoggerFactory.getLogger(MenuServiceImpl.class);
......@@ -38,6 +37,8 @@ public class MenuServiceImpl {
@Autowired
private PermissionMapper permissionMapper;
@Resource
private UserMapper userMapper;
public List<MenuDisplayDto> getMenusForDisplay(Integer moduleId, String userId) {
logger.debug("Start to get menus for display");
......@@ -108,19 +109,33 @@ public class MenuServiceImpl {
}
private List<String> getMenuIds(Integer moduleId,String userId){
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<String> userRoleIdList = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getRoleId).collect(Collectors.toList());
List<String> permissionIds = rolePermissionMapper.selectByRoleId(userRoleIdList.get(0))
.stream().map(RolePermission::getPermissionId).collect(Collectors.toList());
PermissionExample permissionExample = new PermissionExample();
permissionExample.createCriteria().andIdIn(permissionIds);
List<String> menuIds = permissionMapper.selectByExample(permissionExample)
.stream().map(Permission::getMenuId).collect(Collectors.toList());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return menuIds;
private List<String> getMenuIds(Integer moduleId, String userId) {
//fix superAdmin 返回所有权限
userId = authUserHelper.getCurrentUserId();
if (!StringUtils.hasText(userId)) {
return Collections.emptyList();
}
User user = userMapper.selectByPrimaryKey(userId);
if (user == null) {
return Collections.emptyList();
}
if (user.getIsSuperAdmin()) {
return permissionMapper.selectByExample(null).stream().map(Permission::getMenuId)
.collect(Collectors.toList());
} else {
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<String> userRoleIdList = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getRoleId).collect(Collectors.toList());
List<String> permissionIds = rolePermissionMapper.selectByRoleId(userRoleIdList.get(0))
.stream().map(RolePermission::getPermissionId).collect(Collectors.toList());
PermissionExample permissionExample = new PermissionExample();
permissionExample.createCriteria().andIdIn(permissionIds);
List<String> menuIds = permissionMapper.selectByExample(permissionExample)
.stream().map(Permission::getMenuId).collect(Collectors.toList());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return menuIds;
}
}
public List<MenuDto> getMenus(Integer moduleId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment