refactor(功能用例): 功能用例关联缺陷列表返回字段新增属性

This commit is contained in:
WangXu10 2024-01-10 16:02:49 +08:00 committed by Craftsman
parent 281e1e0b17
commit d14c30cdb2
8 changed files with 47 additions and 9 deletions

View File

@ -15,9 +15,12 @@ public class BugProviderDTO implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "缺陷id") @Schema(description = "id")
private String id; private String id;
@Schema(description = "bugId")
private String bugId;
@Schema(description = "缺陷名称") @Schema(description = "缺陷名称")
private String name; private String name;
@ -35,4 +38,13 @@ public class BugProviderDTO implements Serializable {
@Schema(description = "创建时间") @Schema(description = "创建时间")
private Long createTime; private Long createTime;
@Schema(description = "计划名称")
private String testPlanName;
@Schema(description = "计划id")
private String testPlanId;
@Schema(description = "来源")
private String source;
} }

View File

@ -117,4 +117,6 @@ bug.export.system.other.columns.create_time=Create time
bug.export.system.other.columns.case_count=Case count bug.export.system.other.columns.case_count=Case count
bug.export.system.other.columns.comment=Comment bug.export.system.other.columns.comment=Comment
bug.export.system.other.columns.platform=Platform bug.export.system.other.columns.platform=Platform
permission.bug.name=Bug management permission.bug.name=Bug management
test_plan_related=Test plan related
direct_related=Direct related

View File

@ -117,4 +117,6 @@ bug.export.system.other.columns.create_time=创建时间
bug.export.system.other.columns.case_count=用例数 bug.export.system.other.columns.case_count=用例数
bug.export.system.other.columns.comment=评论 bug.export.system.other.columns.comment=评论
bug.export.system.other.columns.platform=所属平台 bug.export.system.other.columns.platform=所属平台
permission.bug.name=缺陷管理 permission.bug.name=缺陷管理
test_plan_relate=测试计划关联
direct_related=直接关联

View File

@ -118,4 +118,6 @@ bug.export.system.other.columns.create_time=創建時間
bug.export.system.other.columns.case_count=用例數 bug.export.system.other.columns.case_count=用例數
bug.export.system.other.columns.comment=評論 bug.export.system.other.columns.comment=評論
bug.export.system.other.columns.platform=所屬平台 bug.export.system.other.columns.platform=所屬平台
permission.bug.name=缺陷管理 permission.bug.name=缺陷管理
test_plan_related=測試計劃關聯
direct_related=直接關聯

View File

@ -22,14 +22,17 @@
<select id="getAssociateBugs" resultType="io.metersphere.dto.BugProviderDTO"> <select id="getAssociateBugs" resultType="io.metersphere.dto.BugProviderDTO">
SELECT SELECT
brc.bug_id id, brc.id id,
b.title NAME, brc.bug_id bugId,
b.title name,
b.handle_user handleUser, b.handle_user handleUser,
b.`status`, b.`status`,
brc.test_plan_id brc.test_plan_id testPlanId,
tp.name testPlanName
FROM FROM
bug_relation_case brc bug_relation_case brc
INNER JOIN bug b ON brc.bug_id = b.id INNER JOIN bug b ON brc.bug_id = b.id
left join test_plan tp on brc.test_plan_id = tp.id
where b.deleted = false where b.deleted = false
<include refid="queryWhereConditionByProvider"/> <include refid="queryWhereConditionByProvider"/>
order by order by

View File

@ -11,9 +11,11 @@ import io.metersphere.provider.BaseAssociateBugProvider;
import io.metersphere.request.AssociateBugPageRequest; import io.metersphere.request.AssociateBugPageRequest;
import io.metersphere.request.AssociateBugRequest; import io.metersphere.request.AssociateBugRequest;
import io.metersphere.request.BugPageProviderRequest; import io.metersphere.request.BugPageProviderRequest;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -75,7 +77,15 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
@Override @Override
public List<BugProviderDTO> hasAssociateBugPage(AssociateBugPageRequest request) { public List<BugProviderDTO> hasAssociateBugPage(AssociateBugPageRequest request) {
return extBugRelateCaseMapper.getAssociateBugs(request, request.getSortString()); List<BugProviderDTO> associateBugs = extBugRelateCaseMapper.getAssociateBugs(request, request.getSortString());
//TODO 需要转义状态和处理人属性 //TODO 需要转义状态和处理人属性
associateBugs.stream().forEach(item -> {
if (StringUtils.isNotBlank(item.getTestPlanName())) {
item.setSource(Translator.get("test_plan_relate"));
} else {
item.setSource(Translator.get("direct_related"));
}
});
return associateBugs;
} }
} }

View File

@ -86,5 +86,9 @@ public class AssociateBugProviderTests extends BaseTest {
request.setPageSize(10); request.setPageSize(10);
request.setCaseId("123"); request.setCaseId("123");
associateBugProvider.hasAssociateBugPage(request); associateBugProvider.hasAssociateBugPage(request);
request.setCaseId("wx_2");
associateBugProvider.hasAssociateBugPage(request);
request.setCaseId("wx_3");
associateBugProvider.hasAssociateBugPage(request);
} }
} }

View File

@ -6,4 +6,7 @@ INSERT INTO bug (id, num, title, handle_users, handle_user, create_user, create_
INSERT INTO bug_relation_case(id, case_id, bug_id, case_type, test_plan_id, test_plan_case_id, create_user, create_time, update_time) INSERT INTO bug_relation_case(id, case_id, bug_id, case_type, test_plan_id, test_plan_case_id, create_user, create_time, update_time)
VALUES ('wx_test_id_1', 'wx_1', 'bug_id_1', 'FUNCTIONAL', null, null, 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000), VALUES ('wx_test_id_1', 'wx_1', 'bug_id_1', 'FUNCTIONAL', null, null, 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
('wx_test_id_2', 'wx_2', 'bug_id_1', 'FUNCTIONAL', 'test-plan-id', 'bug_relate_case', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000), ('wx_test_id_2', 'wx_2', 'bug_id_1', 'FUNCTIONAL', 'test-plan-id', 'bug_relate_case', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
('wx_test_id_3', 'wx_3', 'bug_id_2', 'FUNCTIONAL', 'test-plan-id', 'bug_relate_case-1', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000); ('wx_test_id_3', 'wx_3', 'bug_id_2', 'FUNCTIONAL', null, null, 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
INSERT INTO `test_plan` (`id`,`project_id`,`parent_id`,`name`,`status`,`stage`,`create_time`,`create_user`)
VALUES('test-plan-id','wx_test','3','cececec','3','4',UNIX_TIMESTAMP() * 1000,'admin');