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

样式

parent 584a7aae
...@@ -7,23 +7,22 @@ import org.springframework.stereotype.Service; ...@@ -7,23 +7,22 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import pwc.taxtech.atms.common.CommonConstants; import pwc.taxtech.atms.common.CommonConstants;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dao.MenuMapper; import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dao.PermissionMapper;
import pwc.taxtech.atms.dao.RolePermissionMapper;
import pwc.taxtech.atms.dao.UserRoleMapper;
import pwc.taxtech.atms.dto.MenuDisplayDto; import pwc.taxtech.atms.dto.MenuDisplayDto;
import pwc.taxtech.atms.dto.MenuDto; import pwc.taxtech.atms.dto.MenuDto;
import pwc.taxtech.atms.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.ApplicationException; import pwc.taxtech.atms.exception.ApplicationException;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
*/ */
@Service @Service
public class MenuServiceImpl { public class MenuServiceImpl extends BaseService{
private static final Logger logger = LoggerFactory.getLogger(MenuServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(MenuServiceImpl.class);
...@@ -38,6 +37,8 @@ public class MenuServiceImpl { ...@@ -38,6 +37,8 @@ public class MenuServiceImpl {
@Autowired @Autowired
private PermissionMapper permissionMapper; private PermissionMapper permissionMapper;
@Resource
private UserMapper userMapper;
public List<MenuDisplayDto> getMenusForDisplay(Integer moduleId, String userId) { public List<MenuDisplayDto> getMenusForDisplay(Integer moduleId, String userId) {
logger.debug("Start to get menus for display"); logger.debug("Start to get menus for display");
...@@ -108,7 +109,21 @@ public class MenuServiceImpl { ...@@ -108,7 +109,21 @@ public class MenuServiceImpl {
} }
private List<String> getMenuIds(Integer moduleId,String userId){ 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 userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId); userRoleExample.createCriteria().andUserIdEqualTo(userId);
List<String> userRoleIdList = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getRoleId).collect(Collectors.toList()); List<String> userRoleIdList = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getRoleId).collect(Collectors.toList());
...@@ -120,7 +135,7 @@ public class MenuServiceImpl { ...@@ -120,7 +135,7 @@ public class MenuServiceImpl {
.stream().map(Permission::getMenuId).collect(Collectors.toList()); .stream().map(Permission::getMenuId).collect(Collectors.toList());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList()); // List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return menuIds; return menuIds;
}
} }
public List<MenuDto> getMenus(Integer moduleId) { 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