refactor(工作台): 测试计划概览卡片默认显示以及测试计划关联接口的条件修改

This commit is contained in:
guoyuqi 2024-12-09 17:38:05 +08:00 committed by Craftsman
parent 1b83e223e6
commit 29b84693cd
3 changed files with 25 additions and 18 deletions

View File

@ -491,13 +491,7 @@ public class DashboardService {
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
checkHasPermissionProject(layoutDTO, hasReadProjectIds);
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_PLAN_VIEW.toString())) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(layoutDTO.getPlanId());
if (testPlan == null || StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
TestPlan latestPlan = extTestPlanMapper.getLatestPlan(layoutDTO.getProjectIds().getFirst());
if (latestPlan != null) {
layoutDTO.setPlanId(latestPlan.getId());
}
}
setPlanId(layoutDTO);
}
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_COUNT.toString())
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.CREATE_BUG_BY_ME.toString())
@ -513,6 +507,16 @@ public class DashboardService {
}
}
private void setPlanId(LayoutDTO layoutDTO) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(layoutDTO.getPlanId());
if (testPlan == null || StringUtils.equalsIgnoreCase(testPlan.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
TestPlan latestPlan = extTestPlanMapper.getLatestPlan(layoutDTO.getProjectIds().getFirst());
if (latestPlan != null) {
layoutDTO.setPlanId(latestPlan.getId());
}
}
}
private void checkHasPermissionProject(LayoutDTO layoutDTO, Set<String> hasReadProjectIds) {
if (CollectionUtils.isEmpty(hasReadProjectIds)) {
return;
@ -531,7 +535,7 @@ public class DashboardService {
* @param projectId 项目ID
* @return List<LayoutDTO>
*/
private static List<LayoutDTO> getDefaultLayoutDTOS(String projectId, List<String> userIds) {
private List<LayoutDTO> getDefaultLayoutDTOS(String projectId, List<String> userIds) {
List<LayoutDTO> layoutDTOS = new ArrayList<>();
LayoutDTO projectLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_VIEW, "workbench.homePage.projectOverview", 0, new ArrayList<>(), new ArrayList<>());
layoutDTOS.add(projectLayoutDTO);
@ -539,6 +543,9 @@ public class DashboardService {
layoutDTOS.add(createByMeLayoutDTO);
LayoutDTO projectMemberLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW, "workbench.homePage.staffOverview", 2, List.of(projectId), userIds);
layoutDTOS.add(projectMemberLayoutDTO);
LayoutDTO planLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_PLAN_VIEW, "workbench.homePage.testPlanOverview", 3, List.of(projectId), userIds);
setPlanId(planLayoutDTO);
layoutDTOS.add(planLayoutDTO);
return layoutDTOS;
}

View File

@ -246,7 +246,7 @@ public class DashboardFrontPageControllerTests extends BaseTest {
String defaultString = defaultResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder defaultHolder = JSON.parseObject(defaultString, ResultHolder.class);
List<LayoutDTO>defaultDTOS = JSON.parseArray(JSON.toJSONString(defaultHolder.getData()), LayoutDTO.class);
Assertions.assertEquals(3, defaultDTOS.size());
Assertions.assertEquals(4, defaultDTOS.size());
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID);
List<Project> projects = projectMapper.selectByExample(projectExample);

View File

@ -88,7 +88,7 @@
a.project_id, a.module_id, a.latest, a.version_id, a.ref_id, a.description,
a.create_time, a.create_user, a.update_time, a.update_user, a.delete_user, a.delete_time, a.deleted,
project_version.name as version_name
from api_definition a left join project_version on project_version.id = a.version_id
from api_definition a left join project_version on project_version.id = a.version_id
where a.deleted = false
<include refid="queryWhereApiDefinitionCondition"/>
and exists (
@ -116,7 +116,7 @@
</if>
<if test="request.keyword != null and request.keyword != ''">
and (
a.name like concat('%', #{request.keyword},'%')
a.name like concat('%', #{request.keyword},'%')
or a.num like concat('%', #{request.keyword},'%')
or a.path like concat('%', #{request.keyword},'%')
or a.tags like concat('%', #{request.keyword},'%')
@ -152,27 +152,27 @@
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='status'">
and api_definition.status in
and a.status in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key=='method'">
and api_definition.method in
and a.method in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key=='createUser'">
and api_definition.create_user in
and a.create_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key=='versionId'">
and api_definition.version_id in
and a.version_id in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key=='deleteUser'">
and api_definition.delete_user in
and a.delete_user in
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
</when>
<when test="key.startsWith('custom_single')">
and api_definition.id in (
and a.id in (
select api_id from api_definition_custom_field where concat('custom_single_', field_id) =
#{key}
and trim(both '"' from `value`) in
@ -180,7 +180,7 @@
)
</when>
<when test="key.startsWith('custom_multiple')">
and api_definition.id in (
and a.id in (
select api_id from api_definition_custom_field where concat('custom_multiple_', field_id) =
#{key}
and JSON_CONTAINS(`value`, json_array(#{value}))