fix(工作台): 首页项目多选清空项目显示无数据
This commit is contained in:
parent
e95b31da74
commit
dff9290030
|
@ -23,4 +23,7 @@ public class OverViewCountDTO {
|
||||||
@Schema(description = "项目模块数量DTO")
|
@Schema(description = "项目模块数量DTO")
|
||||||
private List<NameArrayDTO> projectCountList;
|
private List<NameArrayDTO> projectCountList;
|
||||||
|
|
||||||
|
@Schema(description = "错误码")
|
||||||
|
private int errorCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -143,9 +144,8 @@ public class DashboardService {
|
||||||
|
|
||||||
|
|
||||||
public OverViewCountDTO createByMeCount(DashboardFrontPageRequest request, String userId) {
|
public OverViewCountDTO createByMeCount(DashboardFrontPageRequest request, String userId) {
|
||||||
if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) {
|
OverViewCountDTO map = getNoProjectData(request);
|
||||||
return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>());
|
if (map != null) return map;
|
||||||
}
|
|
||||||
List<Project> projects;
|
List<Project> projects;
|
||||||
if (CollectionUtils.isNotEmpty(request.getProjectIds())) {
|
if (CollectionUtils.isNotEmpty(request.getProjectIds())) {
|
||||||
projects = extProjectMapper.getProjectNameModule(null, request.getProjectIds());
|
projects = extProjectMapper.getProjectNameModule(null, request.getProjectIds());
|
||||||
|
@ -158,6 +158,22 @@ public class DashboardService {
|
||||||
return getModuleCountMap(permissionModuleProjectIdMap, projects, toStartTime, toEndTime, userId);
|
return getModuleCountMap(permissionModuleProjectIdMap, projects, toStartTime, toEndTime, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static OverViewCountDTO getNoProjectData(DashboardFrontPageRequest request) {
|
||||||
|
if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) {
|
||||||
|
Map<String, Integer> map = new HashMap<>();
|
||||||
|
map.put(FUNCTIONAL, 0);
|
||||||
|
map.put(CASE_REVIEW, 0);
|
||||||
|
map.put(API, 0);
|
||||||
|
map.put(API_CASE, 0);
|
||||||
|
map.put(API_SCENARIO, 0);
|
||||||
|
map.put(TEST_PLAN, 0);
|
||||||
|
map.put(BUG_COUNT, 0);
|
||||||
|
return new OverViewCountDTO(map, new ArrayList<>(), new ArrayList<>(), 0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private OverViewCountDTO getModuleCountMap(Map<String, Set<String>> permissionModuleProjectIdMap, List<Project> projects, Long toStartTime, Long toEndTime, String userId) {
|
private OverViewCountDTO getModuleCountMap(Map<String, Set<String>> permissionModuleProjectIdMap, List<Project> projects, Long toStartTime, Long toEndTime, String userId) {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
|
@ -295,13 +311,15 @@ public class DashboardService {
|
||||||
overViewCountDTO.setCaseCountMap(map);
|
overViewCountDTO.setCaseCountMap(map);
|
||||||
overViewCountDTO.setXAxis(xaxis);
|
overViewCountDTO.setXAxis(xaxis);
|
||||||
overViewCountDTO.setProjectCountList(nameArrayDTOList);
|
overViewCountDTO.setProjectCountList(nameArrayDTOList);
|
||||||
|
if (CollectionUtils.isEmpty(xaxis)) {
|
||||||
|
overViewCountDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
|
||||||
|
}
|
||||||
return overViewCountDTO;
|
return overViewCountDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OverViewCountDTO projectViewCount(DashboardFrontPageRequest request, String userId) {
|
public OverViewCountDTO projectViewCount(DashboardFrontPageRequest request, String userId) {
|
||||||
if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) {
|
OverViewCountDTO map = getNoProjectData(request);
|
||||||
return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>());
|
if (map != null) return map;
|
||||||
}
|
|
||||||
List<Project> collect = getHasPermissionProjects(request, userId);
|
List<Project> collect = getHasPermissionProjects(request, userId);
|
||||||
Map<String, Set<String>> permissionModuleProjectIdMap = dashboardProjectService.getModuleProjectIds(collect);
|
Map<String, Set<String>> permissionModuleProjectIdMap = dashboardProjectService.getModuleProjectIds(collect);
|
||||||
Long toStartTime = request.getToStartTime();
|
Long toStartTime = request.getToStartTime();
|
||||||
|
@ -379,12 +397,16 @@ public class DashboardService {
|
||||||
private void rebuildLayouts(List<LayoutDTO> layoutDTOS, List<Project> allPermissionProjects, List<ProjectUserMemberDTO> orgProjectMemberList, Map<String, Set<String>> permissionModuleProjectIdMap) {
|
private void rebuildLayouts(List<LayoutDTO> layoutDTOS, List<Project> allPermissionProjects, List<ProjectUserMemberDTO> orgProjectMemberList, Map<String, Set<String>> permissionModuleProjectIdMap) {
|
||||||
for (LayoutDTO layoutDTO : layoutDTOS) {
|
for (LayoutDTO layoutDTO : layoutDTOS) {
|
||||||
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_VIEW.toString()) || StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.CREATE_BY_ME.toString())) {
|
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_VIEW.toString()) || StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.CREATE_BY_ME.toString())) {
|
||||||
|
if (CollectionUtils.isEmpty(layoutDTO.getProjectIds())) {
|
||||||
|
layoutDTO.setProjectIds(new ArrayList<>());
|
||||||
|
} else {
|
||||||
List<Project> list = allPermissionProjects.stream().filter(t -> layoutDTO.getProjectIds().contains(t.getId())).toList();
|
List<Project> list = allPermissionProjects.stream().filter(t -> layoutDTO.getProjectIds().contains(t.getId())).toList();
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
layoutDTO.setProjectIds(list.stream().map(Project::getId).toList());
|
layoutDTO.setProjectIds(list.stream().map(Project::getId).toList());
|
||||||
} else {
|
} else {
|
||||||
layoutDTO.setProjectIds(allPermissionProjects.stream().map(Project::getId).toList());
|
layoutDTO.setProjectIds(allPermissionProjects.stream().map(Project::getId).toList());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW.toString())) {
|
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW.toString())) {
|
||||||
List<ProjectUserMemberDTO> list = orgProjectMemberList.stream().filter(t -> layoutDTO.getHandleUsers().contains(t.getId())).toList();
|
List<ProjectUserMemberDTO> list = orgProjectMemberList.stream().filter(t -> layoutDTO.getHandleUsers().contains(t.getId())).toList();
|
||||||
layoutDTO.setHandleUsers(list.stream().map(ProjectUserMemberDTO::getId).toList());
|
layoutDTO.setHandleUsers(list.stream().map(ProjectUserMemberDTO::getId).toList());
|
||||||
|
@ -610,6 +632,9 @@ public class DashboardService {
|
||||||
OverViewCountDTO overViewCountDTO = new OverViewCountDTO();
|
OverViewCountDTO overViewCountDTO = new OverViewCountDTO();
|
||||||
overViewCountDTO.setXAxis(xaxis);
|
overViewCountDTO.setXAxis(xaxis);
|
||||||
overViewCountDTO.setProjectCountList(nameArrayDTOList);
|
overViewCountDTO.setProjectCountList(nameArrayDTOList);
|
||||||
|
if (CollectionUtils.isEmpty(xaxis)) {
|
||||||
|
overViewCountDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
|
||||||
|
}
|
||||||
return overViewCountDTO;
|
return overViewCountDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,7 +763,7 @@ public class DashboardService {
|
||||||
public OverViewCountDTO projectBugHandleUser(DashboardFrontPageRequest request, String userId) {
|
public OverViewCountDTO projectBugHandleUser(DashboardFrontPageRequest request, String userId) {
|
||||||
String projectId = request.getProjectIds().getFirst();
|
String projectId = request.getProjectIds().getFirst();
|
||||||
if (Boolean.FALSE.equals(permissionCheckService.checkModule(projectId, BUG_MODULE, userId, PermissionConstants.PROJECT_BUG_READ)))
|
if (Boolean.FALSE.equals(permissionCheckService.checkModule(projectId, BUG_MODULE, userId, PermissionConstants.PROJECT_BUG_READ)))
|
||||||
return new OverViewCountDTO(null, new ArrayList<>(), new ArrayList<>());
|
return new OverViewCountDTO(null, new ArrayList<>(), new ArrayList<>(), NO_PROJECT_PERMISSION.getCode());
|
||||||
Long toStartTime = request.getToStartTime();
|
Long toStartTime = request.getToStartTime();
|
||||||
Long toEndTime = request.getToEndTime();
|
Long toEndTime = request.getToEndTime();
|
||||||
List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId);
|
List<SelectOption> headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId);
|
||||||
|
|
Loading…
Reference in New Issue