refactor(工作台): 首页卡片增加项目全选清空判断逻辑

This commit is contained in:
guoyuqi 2024-11-18 14:28:14 +08:00 committed by Craftsman
parent eeda5334ce
commit 989c29d010
5 changed files with 24 additions and 4 deletions

View File

@ -41,8 +41,6 @@ public class TestCasePageProviderRequest extends BaseCondition implements Serial
private String apiDefinitionId;
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{api_definition.project_id.not_blank}")
@Size(min = 1, max = 50, message = "{api_definition.project_id.length_range}")
private String projectId;
@Schema(description = "接口协议", requiredMode = Schema.RequiredMode.REQUIRED)

View File

@ -23,6 +23,8 @@ public class LayoutDTO {
private Boolean fullScreen;
@Schema(description = "选中的项目ID")
private List<String> projectIds;
@Schema(description = "是否全选")
private boolean selectAll;
@Schema(description = "人员集合")
private List<String> handleUsers;

View File

@ -12,6 +12,9 @@ import java.util.List;
@Data
public class DashboardFrontPageRequest extends DashboardBaseRequest{
@Schema(description = "是否全选")
private boolean selectAll;
@Schema(description = "固定时间天数")
private Integer dayNumber;

View File

@ -142,6 +142,9 @@ public class DashboardService {
public OverViewCountDTO createByMeCount(DashboardFrontPageRequest request, String userId) {
if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) {
return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>());
}
List<Project> projects;
if (CollectionUtils.isNotEmpty(request.getProjectIds())) {
projects = extProjectMapper.getProjectNameModule(null, request.getProjectIds());
@ -295,6 +298,9 @@ public class DashboardService {
}
public OverViewCountDTO projectViewCount(DashboardFrontPageRequest request, String userId) {
if (!request.isSelectAll() && CollectionUtils.isEmpty(request.getProjectIds())) {
return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>());
}
List<Project> collect = getHasPermissionProjects(request, userId);
Map<String, Set<String>> permissionModuleProjectIdMap = dashboardProjectService.getModuleProjectIds(collect);
Long toStartTime = request.getToStartTime();
@ -457,6 +463,7 @@ public class DashboardService {
layoutDTO.setKey(layoutKey.toString());
layoutDTO.setLabel(label);
layoutDTO.setPos(pos);
layoutDTO.setSelectAll(true);
layoutDTO.setFullScreen(true);
layoutDTO.setProjectIds(projectIds);
layoutDTO.setHandleUsers(new ArrayList<>());
@ -1011,7 +1018,7 @@ public class DashboardService {
public Pager<List<CaseReviewDTO>> getFunctionalCasePage(DashboardFrontPageRequest request) {
CaseReviewPageRequest reviewRequest = getCaseReviewPageRequest(request);
Page<Object> page = PageHelper.startPage(reviewRequest.getCurrent(), reviewRequest.getPageSize(),
com.alibaba.excel.util.StringUtils.isNotBlank(reviewRequest.getSortString()) ? reviewRequest.getSortString() : "pos desc");
StringUtils.isNotBlank(reviewRequest.getSortString()) ? reviewRequest.getSortString() : "pos desc");
return PageUtils.setPageInfo(page, caseReviewService.getCaseReviewPage(reviewRequest));
}

View File

@ -124,10 +124,20 @@ public class DashboardFrontPageControllerTests extends BaseTest {
MvcResult mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_VIEW, dashboardFrontPageRequest);
OverViewCountDTO moduleCountAll = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResultAll).get("data")), OverViewCountDTO.class);
Assertions.assertNotNull(moduleCountAll);
dashboardFrontPageRequest.setProjectIds(new ArrayList<>());
dashboardFrontPageRequest.setSelectAll(false);
mvcResult = this.requestPostWithOkAndReturn(CREATE_BY_ME, dashboardFrontPageRequest);
contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
moduleCount = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), OverViewCountDTO.class);
Assertions.assertNotNull(moduleCount);
mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_VIEW, dashboardFrontPageRequest);
moduleCountAll = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResultAll).get("data")), OverViewCountDTO.class);
Assertions.assertNotNull(moduleCountAll);
dashboardFrontPageRequest.setDayNumber(null);
dashboardFrontPageRequest.setStartTime(1716185577387L);
dashboardFrontPageRequest.setEndTime(1730181702699L);
dashboardFrontPageRequest.setProjectIds(new ArrayList<>());
mvcResult = this.requestPostWithOkAndReturn(CREATE_BY_ME, dashboardFrontPageRequest);
moduleCount = JSON.parseObject(JSON.toJSONString(
JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),