fix(缺陷管理): 缺陷关联用例左侧模块树展示数据有误

--bug=1036504 --user=宋昌昌 【缺陷管理】缺陷详情-关联用例-列表有数据不展示-无法关联 https://www.tapd.cn/55049933/s/1470107
This commit is contained in:
song-cc-rock 2024-03-06 15:24:18 +08:00 committed by 刘瑞斌
parent 8daf876eef
commit a0f704b6f6
6 changed files with 22 additions and 13 deletions

View File

@ -3,7 +3,7 @@
<mapper namespace="io.metersphere.bug.mapper.ExtBugRelateCaseMapper">
<select id="getRelateCaseModule" resultType="io.metersphere.system.dto.sdk.BaseTreeNode">
select
fcm.id,
distinct fcm.id,
fcm.parent_id as parentId,
fcm.name,
fcm.pos,
@ -21,18 +21,17 @@
<select id="countRelateCaseModuleTree" resultType="io.metersphere.project.dto.ModuleCountDTO">
select
fcm.id as moduleId,
fc.module_id AS moduleId,
count(fc.id) as dataCount
from functional_case_module fcm left join functional_case fc on fc.module_id = fcm.id
from functional_case fc
where fc.deleted = #{deleted}
and fc.project_id = #{request.projectId}
and fc.version_id = #{request.versionId}
and fc.id not in
(
select brc.case_id from bug_relation_case brc where brc.bug_id = #{request.sourceId} and brc.case_type = #{request.sourceType}
)
<include refid="queryModuleWhereCondition"/>
group by fcm.id
group by fc.module_id
</select>
<select id="countRelationCases" resultType="io.metersphere.bug.dto.response.BugRelateCaseCountDTO">
@ -107,7 +106,7 @@
)
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and fcm.module_id in
and fc.module_id in
<foreach collection="request.moduleIds" item="moduleId" open="(" separator="," close=")">
#{moduleId}
</foreach>

View File

@ -78,6 +78,8 @@ public class BugRelateCaseCommonService extends ModuleTreeService {
* @return 模块树集合
*/
public Map<String, Long> countTree(TestCasePageProviderRequest request) {
// 统计模块数量不用传模块ID
request.setModuleIds(null);
// 目前只保留功能用例的左侧模块树方法调用, 后续其他用例根据RelateCaseType扩展
List<ModuleCountDTO> moduleCounts = extBugRelateCaseMapper.countRelateCaseModuleTree(request, false);
AssociateCaseModuleRequest moduleRequest = new AssociateCaseModuleRequest();

View File

@ -732,7 +732,6 @@
from functional_case fc
where fc.deleted = #{deleted}
and fc.project_id = #{request.projectId}
and fc.version_id = #{request.versionId}
and fc.id not in
(
select brc.case_id from bug_relation_case brc where brc.bug_id = #{request.sourceId} and brc.case_type = #{request.sourceType}

View File

@ -1,11 +1,11 @@
import {CommentParams} from '@/components/business/ms-comment/types';
import { CommentParams } from '@/components/business/ms-comment/types';
import MSR from '@/api/http/index';
import * as bugURL from '@/api/requrls/bug-management';
import {BugEditFormObject, BugListItem} from '@/models/bug-management';
import {AssociatedList, DemandItem, OperationFile} from '@/models/caseManagement/featureCase';
import {CommonList, TableQueryParams, TemplateOption} from '@/models/common';
import { BugEditFormObject, BugListItem } from '@/models/bug-management';
import { AssociatedList, DemandItem, OperationFile } from '@/models/caseManagement/featureCase';
import { CommonList, TableQueryParams, TemplateOption } from '@/models/common';
/**
*
@ -196,7 +196,7 @@ export function deleteBatchByRecycle(data: TableQueryParams) {
// ----------------------关联需求
// 已关联需求列表
// 已关联用例列表
export function getAssociatedList(data: TableQueryParams) {
return MSR.post<CommonList<DemandItem[]>>({ url: bugURL.getDemandListUrl, data });
}
@ -211,6 +211,11 @@ export function getModuleTree(data: TableQueryParams) {
return MSR.post({ url: `${bugURL.getUnrelatedModuleTreeUrl}`, data });
}
// 未关联用例-模块树-统计
export function getModuleTreeCounts(data: TableQueryParams) {
return MSR.post({ url: `${bugURL.getUnrelatedModuleTreeCountUrl}`, data });
}
// 批量关联需求
export function batchAssociation(data: TableQueryParams) {
return MSR.post({ url: bugURL.postAddDemandUrl, data });

View File

@ -1,9 +1,11 @@
/* eslint-disable no-shadow */
import { getModuleTreeCounts } from '@/api/modules/bug-management';
import { getCaseModulesCounts, getPublicLinkCaseModulesCounts } from '@/api/modules/case-management/featureCase';
export enum RequestModuleEnum {
API_CASE = 'API_CASE',
CASE_MANAGEMENT = 'CASE_MANAGEMENT',
BUG_MANAGEMENT = 'BUG_MANAGEMENT',
}
export function initGetModuleCountFunc(type: RequestModuleEnum[keyof RequestModuleEnum], params: Record<string, any>) {
@ -12,6 +14,8 @@ export function initGetModuleCountFunc(type: RequestModuleEnum[keyof RequestModu
return getPublicLinkCaseModulesCounts(params);
case RequestModuleEnum.CASE_MANAGEMENT:
return getCaseModulesCounts(params);
case RequestModuleEnum.BUG_MANAGEMENT:
return getModuleTreeCounts(params);
default:
break;
}

View File

@ -65,7 +65,7 @@
:confirm-loading="confirmLoading"
:case-id="props.bugId"
:associated-ids="associatedIds"
:type="RequestModuleEnum.CASE_MANAGEMENT"
:type="RequestModuleEnum.BUG_MANAGEMENT"
@close="emit('close')"
@save="saveHandler"
>