feat(测试用例): 获取用例导出字段

This commit is contained in:
WangXu10 2024-08-05 10:35:14 +08:00 committed by Craftsman
parent f53bac0332
commit 8bb5567c5f
7 changed files with 106 additions and 8 deletions

View File

@ -266,4 +266,16 @@ xmind_tags=tags
xmind_textDescription=Text description
xmind_expectedResult=Expected result
xmind_step=Step
xmind_stepDescription=Step description
xmind_stepDescription=Step description
# case export columns
case.export.system.columns.name=Name
case.export.system.columns.id=ID
case.export.system.columns.prerequisite=Prerequisite
case.export.system.columns.text_description=Text description
case.export.system.columns.expected_result=Expected result
case.export.system.other.columns.last_execute_result=Last execution result
case.export.system.other.columns.review_status=Review status
case.export.system.other.columns.create_user=Create user
case.export.system.other.columns.create_time=Create time
case.export.system.other.columns.update_user=Update user
case.export.system.other.columns.update_time=Update time

View File

@ -264,4 +264,16 @@ xmind_tags=标签
xmind_textDescription=文本描述
xmind_expectedResult=预期结果
xmind_step=用例步骤
xmind_stepDescription=步骤描述
xmind_stepDescription=步骤描述
# case export columns
case.export.system.columns.name=用例名称
case.export.system.columns.id=ID
case.export.system.columns.prerequisite=前置条件
case.export.system.columns.text_description=步骤描述
case.export.system.columns.expected_result=预期结果
case.export.system.other.columns.last_execute_result=执行结果
case.export.system.other.columns.review_status=评审结果
case.export.system.other.columns.create_user=创建人
case.export.system.other.columns.create_time=创建时间
case.export.system.other.columns.update_user=更新人
case.export.system.other.columns.update_time=更新时间

View File

@ -265,4 +265,16 @@ xmind_tags=標簽
xmind_textDescription=文本描述
xmind_expectedResult=預期結果
xmind_step=用例步驟
xmind_stepDescription=步驟描述
xmind_stepDescription=步驟描述
# case export columns
case.export.system.columns.name=用例名稱
case.export.system.columns.id=ID
case.export.system.columns.prerequisite=前置條件
case.export.system.columns.text_description=步驟描述
case.export.system.columns.expected_result=預期結果
case.export.system.other.columns.last_execute_result=執行結果
case.export.system.other.columns.review_status=評審結果
case.export.system.other.columns.create_user=創建人
case.export.system.other.columns.create_time=創建時間
case.export.system.other.columns.update_user=更新人
case.export.system.other.columns.update_time=更新時間

View File

@ -8,6 +8,7 @@ import io.metersphere.functional.dto.FunctionalCaseDetailDTO;
import io.metersphere.functional.dto.FunctionalCasePageDTO;
import io.metersphere.functional.dto.FunctionalCaseVersionDTO;
import io.metersphere.functional.dto.response.FunctionalCaseImportResponse;
import io.metersphere.functional.excel.domain.FunctionalCaseExportColumns;
import io.metersphere.functional.request.*;
import io.metersphere.functional.service.*;
import io.metersphere.project.dto.CustomFieldOptions;
@ -263,4 +264,12 @@ public class FunctionalCaseController {
public void xmindTemplateExport(@PathVariable String projectId, HttpServletResponse response) {
functionalCaseXmindService.downloadXmindTemplate(projectId, response);
}
@GetMapping("/export/columns/{projectId}")
@Operation(summary = "用例管理-获取导出字段配置")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@CheckOwner(resourceId = "#projectId", resourceType = "project")
public FunctionalCaseExportColumns getExportColumns(@PathVariable String projectId) {
return functionalCaseFileService.getExportColumns(projectId);
}
}

View File

@ -0,0 +1,41 @@
package io.metersphere.functional.excel.domain;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.List;
/**
* @author wx
*/
@Data
public class FunctionalCaseExportColumns {
private LinkedHashMap<String, String> systemColumns = new LinkedHashMap<>();
private LinkedHashMap<String, String> otherColumns = new LinkedHashMap<>();
private LinkedHashMap<String, String> customColumns = new LinkedHashMap<>();
public FunctionalCaseExportColumns() {
// 系统字段
systemColumns.put("name", Translator.get("case.export.system.columns.name"));
systemColumns.put("num", Translator.get("case.export.system.columns.id"));
systemColumns.put("prerequisite", Translator.get("case.export.system.columns.prerequisite"));
systemColumns.put("module", Translator.get("case.export.system.columns.module"));
systemColumns.put("text_description", Translator.get("case.export.system.columns.text_description"));
systemColumns.put("expected_result", Translator.get("case.export.system.columns.expected_result"));
// 其他字段
otherColumns.put("last_execute_result", Translator.get("case.export.system.other.columns.last_execute_result"));
otherColumns.put("review_status", Translator.get("case.export.system.other.columns.review_status"));
otherColumns.put("create_user", Translator.get("case.export.system.other.columns.create_user"));
otherColumns.put("create_time", Translator.get("case.export.system.other.columns.create_time"));
otherColumns.put("update_user", Translator.get("case.export.system.other.columns.update_user"));
otherColumns.put("update_time", Translator.get("case.export.system.other.columns.update_time"));
}
public void initCustomColumns(List<TemplateCustomFieldDTO> headerCustomFields) {
headerCustomFields.forEach(item -> customColumns.put(item.getFieldId(), item.getFieldName()));
}
}

View File

@ -14,10 +14,7 @@ import io.metersphere.functional.dto.response.FunctionalCaseImportResponse;
import io.metersphere.functional.excel.constants.FunctionalCaseImportFiled;
import io.metersphere.functional.excel.converter.FunctionalCaseExportConverter;
import io.metersphere.functional.excel.converter.FunctionalCaseExportConverterFactory;
import io.metersphere.functional.excel.domain.ExcelMergeInfo;
import io.metersphere.functional.excel.domain.FunctionalCaseExcelData;
import io.metersphere.functional.excel.domain.FunctionalCaseExcelDataFactory;
import io.metersphere.functional.excel.domain.FunctionalCaseHeader;
import io.metersphere.functional.excel.domain.*;
import io.metersphere.functional.excel.handler.FunctionCaseMergeWriteHandler;
import io.metersphere.functional.excel.handler.FunctionCaseTemplateWriteHandler;
import io.metersphere.functional.excel.listener.FunctionalCaseCheckEventListener;
@ -729,4 +726,12 @@ public class FunctionalCaseFileService {
};
return headList;
}
public FunctionalCaseExportColumns getExportColumns(String projectId) {
FunctionalCaseExportColumns functionalCaseExportColumns = new FunctionalCaseExportColumns();
// 表头自定义字段
List<TemplateCustomFieldDTO> headerCustomFields = getCustomFields(projectId);
functionalCaseExportColumns.initCustomColumns(headerCustomFields);
return functionalCaseExportColumns;
}
}

View File

@ -88,6 +88,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
public static final String OPERATION_HISTORY_URL = "/functional/case/operation-history";
public static final String EXPORT_EXCEL_URL = "/functional/case/export/excel";
public static final String DOWNLOAD_XMIND_TEMPLATE_URL = "/functional/case/download/xmind/template/";
public static final String EXPORT_COLUMNS_URL = "/functional/case/export/columns/";
@Resource
private NotificationMapper notificationMapper;
@ -645,7 +646,7 @@ public class FunctionalCaseControllerTests extends BaseTest {
request.setAppend(true);
request.setTags(Arrays.asList("追加标签_1", "追加标签_2"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_EDIT_URL, request);
request.setTags(Arrays.asList("追加标签_1", "追加标签_2","追加标签_3","追加标签_4","追加标签_5","追加标签_6","追加标签_7","追加标签_8","追加标签_9","追加标签_10","追加标签_11"));
request.setTags(Arrays.asList("追加标签_1", "追加标签_2", "追加标签_3", "追加标签_4", "追加标签_5", "追加标签_6", "追加标签_7", "追加标签_8", "追加标签_9", "追加标签_10", "追加标签_11"));
this.requestPost(FUNCTIONAL_CASE_BATCH_EDIT_URL, request);
request.setAppend(false);
request.setTags(Arrays.asList("覆盖标签1", "覆盖标签2"));
@ -842,4 +843,10 @@ public class FunctionalCaseControllerTests extends BaseTest {
public void testDownloadXmindTemplate() throws Exception {
this.requestGetExcel(DOWNLOAD_XMIND_TEMPLATE_URL + DEFAULT_PROJECT_ID);
}
@Test
@Order(23)
public void getExportColumns() throws Exception {
this.requestGetExcel(EXPORT_COLUMNS_URL + DEFAULT_PROJECT_ID);
}
}