refactor(工作台): 测试计划概览卡片默认显示以及测试计划关联接口的条件修改
This commit is contained in:
parent
1b83e223e6
commit
29b84693cd
|
@ -491,13 +491,7 @@ public class DashboardService {
|
||||||
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
|
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
|
||||||
checkHasPermissionProject(layoutDTO, hasReadProjectIds);
|
checkHasPermissionProject(layoutDTO, hasReadProjectIds);
|
||||||
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_PLAN_VIEW.toString())) {
|
if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PROJECT_PLAN_VIEW.toString())) {
|
||||||
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(layoutDTO.getPlanId());
|
setPlanId(layoutDTO);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_COUNT.toString())
|
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.BUG_COUNT.toString())
|
||||||
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.CREATE_BUG_BY_ME.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) {
|
private void checkHasPermissionProject(LayoutDTO layoutDTO, Set<String> hasReadProjectIds) {
|
||||||
if (CollectionUtils.isEmpty(hasReadProjectIds)) {
|
if (CollectionUtils.isEmpty(hasReadProjectIds)) {
|
||||||
return;
|
return;
|
||||||
|
@ -531,7 +535,7 @@ public class DashboardService {
|
||||||
* @param projectId 项目ID
|
* @param projectId 项目ID
|
||||||
* @return List<LayoutDTO>
|
* @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<>();
|
List<LayoutDTO> layoutDTOS = new ArrayList<>();
|
||||||
LayoutDTO projectLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_VIEW, "workbench.homePage.projectOverview", 0, new ArrayList<>(), new ArrayList<>());
|
LayoutDTO projectLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_VIEW, "workbench.homePage.projectOverview", 0, new ArrayList<>(), new ArrayList<>());
|
||||||
layoutDTOS.add(projectLayoutDTO);
|
layoutDTOS.add(projectLayoutDTO);
|
||||||
|
@ -539,6 +543,9 @@ public class DashboardService {
|
||||||
layoutDTOS.add(createByMeLayoutDTO);
|
layoutDTOS.add(createByMeLayoutDTO);
|
||||||
LayoutDTO projectMemberLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW, "workbench.homePage.staffOverview", 2, List.of(projectId), userIds);
|
LayoutDTO projectMemberLayoutDTO = buildDefaultLayoutDTO(DashboardUserLayoutKeys.PROJECT_MEMBER_VIEW, "workbench.homePage.staffOverview", 2, List.of(projectId), userIds);
|
||||||
layoutDTOS.add(projectMemberLayoutDTO);
|
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;
|
return layoutDTOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
||||||
String defaultString = defaultResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
String defaultString = defaultResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
ResultHolder defaultHolder = JSON.parseObject(defaultString, ResultHolder.class);
|
ResultHolder defaultHolder = JSON.parseObject(defaultString, ResultHolder.class);
|
||||||
List<LayoutDTO>defaultDTOS = JSON.parseArray(JSON.toJSONString(defaultHolder.getData()), LayoutDTO.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 projectExample = new ProjectExample();
|
||||||
projectExample.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID);
|
projectExample.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID);
|
||||||
List<Project> projects = projectMapper.selectByExample(projectExample);
|
List<Project> projects = projectMapper.selectByExample(projectExample);
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
a.project_id, a.module_id, a.latest, a.version_id, a.ref_id, a.description,
|
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,
|
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
|
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
|
where a.deleted = false
|
||||||
<include refid="queryWhereApiDefinitionCondition"/>
|
<include refid="queryWhereApiDefinitionCondition"/>
|
||||||
and exists (
|
and exists (
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
</if>
|
</if>
|
||||||
<if test="request.keyword != null and request.keyword != ''">
|
<if test="request.keyword != null and request.keyword != ''">
|
||||||
and (
|
and (
|
||||||
a.name like concat('%', #{request.keyword},'%')
|
a.name like concat('%', #{request.keyword},'%')
|
||||||
or a.num like concat('%', #{request.keyword},'%')
|
or a.num like concat('%', #{request.keyword},'%')
|
||||||
or a.path like concat('%', #{request.keyword},'%')
|
or a.path like concat('%', #{request.keyword},'%')
|
||||||
or a.tags like concat('%', #{request.keyword},'%')
|
or a.tags like concat('%', #{request.keyword},'%')
|
||||||
|
@ -152,27 +152,27 @@
|
||||||
<if test="values != null and values.size() > 0">
|
<if test="values != null and values.size() > 0">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="key=='status'">
|
<when test="key=='status'">
|
||||||
and api_definition.status in
|
and a.status in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='method'">
|
<when test="key=='method'">
|
||||||
and api_definition.method in
|
and a.method in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='createUser'">
|
<when test="key=='createUser'">
|
||||||
and api_definition.create_user in
|
and a.create_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='versionId'">
|
<when test="key=='versionId'">
|
||||||
and api_definition.version_id in
|
and a.version_id in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key=='deleteUser'">
|
<when test="key=='deleteUser'">
|
||||||
and api_definition.delete_user in
|
and a.delete_user in
|
||||||
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
<include refid="io.metersphere.system.mapper.BaseMapper.filterInWrapper"/>
|
||||||
</when>
|
</when>
|
||||||
<when test="key.startsWith('custom_single')">
|
<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) =
|
select api_id from api_definition_custom_field where concat('custom_single_', field_id) =
|
||||||
#{key}
|
#{key}
|
||||||
and trim(both '"' from `value`) in
|
and trim(both '"' from `value`) in
|
||||||
|
@ -180,7 +180,7 @@
|
||||||
)
|
)
|
||||||
</when>
|
</when>
|
||||||
<when test="key.startsWith('custom_multiple')">
|
<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) =
|
select api_id from api_definition_custom_field where concat('custom_multiple_', field_id) =
|
||||||
#{key}
|
#{key}
|
||||||
and JSON_CONTAINS(`value`, json_array(#{value}))
|
and JSON_CONTAINS(`value`, json_array(#{value}))
|
||||||
|
|
Loading…
Reference in New Issue