refactor(测试跟踪): 功能用例列表不展示文本框类型的自定义字段,优化效率
--bug=1027283 --user=陈建星 【测试跟踪】github#25017,【功能用例】功能用例-自定义字段为“csc预期返回”和“csc请求参数”为大json串,当同种类型用例有50个用例,每页从默认切到50条,页面加载特别慢,至少得等1分钟 https://www.tapd.cn/55049933/s/1386041
This commit is contained in:
parent
aefea087de
commit
d70bcdca41
|
@ -19,6 +19,8 @@ public interface BaseCustomFieldResourceMapper {
|
||||||
|
|
||||||
List<CustomFieldResourceDTO> getByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List<String> resourceIds);
|
List<CustomFieldResourceDTO> getByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List<String> resourceIds);
|
||||||
|
|
||||||
|
List<CustomFieldResourceDTO> getByResourceIdsForList(@Param("tableName") String tableName, @Param("resourceIds") List<String> resourceIds);
|
||||||
|
|
||||||
long countFieldResource(@Param("tableName") String tableName, @Param("resourceId") String resourceId, @Param("fieldId") String field_id);
|
long countFieldResource(@Param("tableName") String tableName, @Param("resourceId") String resourceId, @Param("fieldId") String field_id);
|
||||||
|
|
||||||
int batchUpdateByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List<String> resourceIds, @Param("record") CustomFieldResourceDTO customField);
|
int batchUpdateByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List<String> resourceIds, @Param("record") CustomFieldResourceDTO customField);
|
||||||
|
|
|
@ -88,4 +88,13 @@
|
||||||
<select id="countFieldResource" resultType="java.lang.Long">
|
<select id="countFieldResource" resultType="java.lang.Long">
|
||||||
select count(1) from ${tableName} where resource_id = #{resourceId} and field_id = #{fieldId}
|
select count(1) from ${tableName} where resource_id = #{resourceId} and field_id = #{fieldId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getByResourceIdsForList" resultType="io.metersphere.dto.CustomFieldResourceDTO">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List" />
|
||||||
|
from ${tableName}
|
||||||
|
where resource_id in
|
||||||
|
<foreach collection="resourceIds" item="resourceId" separator="," open="(" close=")">
|
||||||
|
#{resourceId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.mybatis.spring.SqlSessionUtils;
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -114,11 +115,31 @@ public class CustomFieldResourceService {
|
||||||
return baseCustomFieldResourceMapper.getByResourceIds(tableName, resourceIds);
|
return baseCustomFieldResourceMapper.getByResourceIds(tableName, resourceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<CustomFieldResourceDTO> getByResourceIdsForList(String tableName, List<String> resourceIds) {
|
||||||
|
if (CollectionUtils.isEmpty(resourceIds)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return baseCustomFieldResourceMapper.getByResourceIdsForList(tableName, resourceIds);
|
||||||
|
}
|
||||||
|
|
||||||
protected Map<String, List<CustomFieldDao>> getMapByResourceIds(String tableName, List<String> resourceIds) {
|
protected Map<String, List<CustomFieldDao>> getMapByResourceIds(String tableName, List<String> resourceIds) {
|
||||||
if (CollectionUtils.isEmpty(resourceIds)) {
|
if (CollectionUtils.isEmpty(resourceIds)) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
List<CustomFieldResourceDTO> CustomFieldResourceDTOs = getByResourceIds(tableName, resourceIds);
|
List<CustomFieldResourceDTO> CustomFieldResourceDTOs = getByResourceIds(tableName, resourceIds);
|
||||||
|
return getFieldMap(CustomFieldResourceDTOs);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Map<String, List<CustomFieldDao>> getMapByResourceIdsForList(String tableName, List<String> resourceIds) {
|
||||||
|
if (CollectionUtils.isEmpty(resourceIds)) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
List<CustomFieldResourceDTO> CustomFieldResourceDTOs = getByResourceIdsForList(tableName, resourceIds);
|
||||||
|
return getFieldMap(CustomFieldResourceDTOs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static Map<String, List<CustomFieldDao>> getFieldMap(List<CustomFieldResourceDTO> CustomFieldResourceDTOs) {
|
||||||
Map<String, List<CustomFieldDao>> fieldMap = new HashMap<>();
|
Map<String, List<CustomFieldDao>> fieldMap = new HashMap<>();
|
||||||
CustomFieldResourceDTOs.forEach(i -> {
|
CustomFieldResourceDTOs.forEach(i -> {
|
||||||
List<CustomFieldDao> fields = fieldMap.get(i.getResourceId());
|
List<CustomFieldDao> fields = fieldMap.get(i.getResourceId());
|
||||||
|
|
|
@ -68,4 +68,9 @@ public class TestCaseTemplateController {
|
||||||
public TestCaseTemplateDao getTemplate(@PathVariable String projectId) {
|
public TestCaseTemplateDao getTemplate(@PathVariable String projectId) {
|
||||||
return testCaseTemplateService.getTemplate(projectId);
|
return testCaseTemplateService.getTemplate(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/relate/simple/{projectId}")
|
||||||
|
public TestCaseTemplateDao getTemplateForList(@PathVariable String projectId) {
|
||||||
|
return testCaseTemplateService.getTemplateForList(projectId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package io.metersphere.service;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.TestCaseTemplateMapper;
|
import io.metersphere.base.mapper.TestCaseTemplateMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseTemplateMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseTemplateMapper;
|
||||||
|
import io.metersphere.commons.constants.CustomFieldType;
|
||||||
import io.metersphere.commons.constants.TemplateConstants;
|
import io.metersphere.commons.constants.TemplateConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
|
@ -251,6 +252,14 @@ public class TestCaseTemplateService extends TemplateBaseService {
|
||||||
return caseTemplateDao;
|
return caseTemplateDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TestCaseTemplateDao getTemplateForList(String projectId) {
|
||||||
|
TestCaseTemplateDao template = getTemplate(projectId);
|
||||||
|
// 列表展示过滤掉文本框和富文本框等大字段,否则加载效率低
|
||||||
|
template.getCustomFields().stream().filter(field ->
|
||||||
|
!StringUtils.equalsAnyIgnoreCase(field.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue()));
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLogDetails(String id) {
|
public String getLogDetails(String id) {
|
||||||
TestCaseTemplateWithBLOBs templateWithBLOBs = testCaseTemplateMapper.selectByPrimaryKey(id);
|
TestCaseTemplateWithBLOBs templateWithBLOBs = testCaseTemplateMapper.selectByPrimaryKey(id);
|
||||||
if (templateWithBLOBs != null) {
|
if (templateWithBLOBs != null) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class TestPlanTestCaseService {
|
||||||
ServiceUtils.buildCombineTagsToSupportMultiple(request);
|
ServiceUtils.buildCombineTagsToSupportMultiple(request);
|
||||||
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
|
List<TestPlanCaseDTO> list = extTestPlanTestCaseMapper.list(request);
|
||||||
Map<String, List<CustomFieldDao>> fieldMap =
|
Map<String, List<CustomFieldDao>> fieldMap =
|
||||||
customFieldTestCaseService.getMapByResourceIds(list.stream().map(TestPlanCaseDTO::getCaseId).collect(Collectors.toList()));
|
customFieldTestCaseService.getMapByResourceIdsForList(list.stream().map(TestPlanCaseDTO::getCaseId).collect(Collectors.toList()));
|
||||||
list.forEach(i -> i.setFields(fieldMap.get(i.getCaseId())));
|
list.forEach(i -> i.setFields(fieldMap.get(i.getCaseId())));
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
// 设置版本信息
|
// 设置版本信息
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class CustomFieldTestCaseService extends CustomFieldResourceService {
|
||||||
super.deleteByResourceIds(TABLE_NAME, resourceIds);
|
super.deleteByResourceIds(TABLE_NAME, resourceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<CustomFieldDao>> getMapByResourceIds(List<String> resourceIds) {
|
public Map<String, List<CustomFieldDao>> getMapByResourceIdsForList(List<String> resourceIds) {
|
||||||
return super.getMapByResourceIds(TABLE_NAME, resourceIds);
|
return super.getMapByResourceIdsForList(TABLE_NAME, resourceIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CustomFieldResourceDTO> getByResourceId(String resourceId) {
|
public List<CustomFieldResourceDTO> getByResourceId(String resourceId) {
|
||||||
|
|
|
@ -829,7 +829,7 @@ public class TestCaseService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, List<CustomFieldDao>> fieldMap =
|
Map<String, List<CustomFieldDao>> fieldMap =
|
||||||
customFieldTestCaseService.getMapByResourceIds(data.stream().map(TestCaseDTO::getId).collect(Collectors.toList()));
|
customFieldTestCaseService.getMapByResourceIdsForList(data.stream().map(TestCaseDTO::getId).collect(Collectors.toList()));
|
||||||
data.forEach(i -> i.setFields(fieldMap.get(i.getId())));
|
data.forEach(i -> i.setFields(fieldMap.get(i.getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ export function getTestTemplate(projectId) {
|
||||||
return getTemplate('field/template/case/get/relate/', projectId);
|
return getTemplate('field/template/case/get/relate/', projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTestTemplateForList(projectId) {
|
||||||
|
return getTemplate('field/template/case/get/relate/simple/', projectId);
|
||||||
|
}
|
||||||
|
|
||||||
export function updateCustomFieldTemplate(request) {
|
export function updateCustomFieldTemplate(request) {
|
||||||
return post('/custom/field/template/update', request);
|
return post('/custom/field/template/update', request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ import PlanStatusTableItem from "@/business/common/tableItems/plan/PlanStatusTab
|
||||||
import {getCurrentProjectID, getCurrentWorkspaceId, setCurrentProjectID} from "metersphere-frontend/src/utils/token";
|
import {getCurrentProjectID, getCurrentWorkspaceId, setCurrentProjectID} from "metersphere-frontend/src/utils/token";
|
||||||
import {parseTag} from "metersphere-frontend/src/utils"
|
import {parseTag} from "metersphere-frontend/src/utils"
|
||||||
import {hasLicense} from "metersphere-frontend/src/utils/permission"
|
import {hasLicense} from "metersphere-frontend/src/utils/permission"
|
||||||
import {getTestTemplate} from "@/api/custom-field-template";
|
import {getTestTemplateForList} from "@/api/custom-field-template";
|
||||||
import {getProjectMember, getProjectMemberUserFilter} from "@/api/user";
|
import {getProjectMember, getProjectMemberUserFilter} from "@/api/user";
|
||||||
import MsTable from "metersphere-frontend/src/components/new-ui/MsTable";
|
import MsTable from "metersphere-frontend/src/components/new-ui/MsTable";
|
||||||
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
|
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
|
||||||
|
@ -637,7 +637,7 @@ export default {
|
||||||
this.memberMap.set(item.id, item.name);
|
this.memberMap.set(item.id, item.name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
let p2 = getTestTemplate();
|
let p2 = getTestTemplateForList();
|
||||||
Promise.all([p1, p2]).then((data) => {
|
Promise.all([p1, p2]).then((data) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
let template = data[1];
|
let template = data[1];
|
||||||
|
|
|
@ -311,12 +311,11 @@ import {
|
||||||
initCondition,
|
initCondition,
|
||||||
getCustomFieldFilter,
|
getCustomFieldFilter,
|
||||||
parseCustomFilesForList,
|
parseCustomFilesForList,
|
||||||
getCustomFieldValue as _getCustomFieldValue,
|
|
||||||
} from "metersphere-frontend/src/utils/tableUtils";
|
} from "metersphere-frontend/src/utils/tableUtils";
|
||||||
import MsTable from "metersphere-frontend/src/components/table/MsTable";
|
import MsTable from "metersphere-frontend/src/components/table/MsTable";
|
||||||
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
|
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
|
||||||
import {getProjectMember} from "@/api/user";
|
import {getProjectMember} from "@/api/user";
|
||||||
import {getTestTemplate} from "@/api/custom-field-template";
|
import {getTestTemplateForList} from "@/api/custom-field-template";
|
||||||
import {
|
import {
|
||||||
editTestPlanTestCaseOrder,
|
editTestPlanTestCaseOrder,
|
||||||
testPlanAutoCheck,
|
testPlanAutoCheck,
|
||||||
|
@ -581,7 +580,7 @@ export default {
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.members = response.data;
|
this.members = response.data;
|
||||||
});
|
});
|
||||||
let p2 = getTestTemplate();
|
let p2 = getTestTemplateForList();
|
||||||
Promise.all([p1, p2]).then((data) => {
|
Promise.all([p1, p2]).then((data) => {
|
||||||
let template = data[1];
|
let template = data[1];
|
||||||
this.testCaseTemplate = template;
|
this.testCaseTemplate = template;
|
||||||
|
|
Loading…
Reference in New Issue