|
|
@@ -1,5 +1,6 @@
|
|
|
package com.usoftchina.bi.server.service.dashboard;
|
|
|
|
|
|
+import com.usoftchina.bi.core.base.BaseContextHolder;
|
|
|
import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
import com.usoftchina.bi.core.exception.MyException;
|
|
|
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -26,16 +28,21 @@ public class DashBoardMenuService {
|
|
|
private DashBoardMenuMapper dashBoardMenuMapper;
|
|
|
|
|
|
public List<DashboardMenuRespDTO> list(String token){
|
|
|
- int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
|
|
|
- return getData(userId, 0);
|
|
|
+ String role = BaseContextHolder.getRole();
|
|
|
+ return getData(BaseContextHolder.getUserId(), 0, role);
|
|
|
}
|
|
|
|
|
|
- private List<DashboardMenuRespDTO> getData(int userId, int id){
|
|
|
- List<DashboardMenuRespDTO> dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuById(userId, id);
|
|
|
+ private List<DashboardMenuRespDTO> getData(int userId, int id, String role){
|
|
|
+ List<DashboardMenuRespDTO> dashboardMenuRespDTOList = new ArrayList<>();
|
|
|
+ if (!"superAdmin".equals(role)) {
|
|
|
+ dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuById(userId, id);
|
|
|
+ }else {
|
|
|
+ dashboardMenuRespDTOList = dashBoardMenuMapper.getMenuWithNoLimit(id);
|
|
|
+ }
|
|
|
if (!CollectionUtils.isEmpty(dashboardMenuRespDTOList)) {
|
|
|
for (DashboardMenuRespDTO dashboardMenuRespDTO : dashboardMenuRespDTOList) {
|
|
|
if ("menu".equals(dashboardMenuRespDTO.getType())) {
|
|
|
- dashboardMenuRespDTO.setChildren(getData(userId, dashboardMenuRespDTO.getId()));
|
|
|
+ dashboardMenuRespDTO.setChildren(getData(userId, dashboardMenuRespDTO.getId(), role));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -65,8 +72,13 @@ public class DashBoardMenuService {
|
|
|
}
|
|
|
|
|
|
public RepEntity getDashBoardByMenuId(String token, int menuId){
|
|
|
- int userId = Integer.parseInt(GetTokenDataUtil.getTokenData(token).get("id"));
|
|
|
- return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuId(userId, menuId));
|
|
|
+ int userId = BaseContextHolder.getUserId();
|
|
|
+ String role = BaseContextHolder.getRole();
|
|
|
+ if (!"superAdmin".equals(role)) {
|
|
|
+ return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuId(userId, menuId));
|
|
|
+ }else {
|
|
|
+ return new RepEntity(RepCode.success, dashBoardMenuMapper.getDashBoardByMenuIdWithoutLimit(menuId));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|