refactor(接口用例): 列表增加运行环境列

--story=1003532 --user=lyh 6.单接口用例列表和场景列表新增 运行环境 参考测试计划列表的运行环境展示
https://www.tapd.cn/55049933/s/1057394
This commit is contained in:
shiziyuan9527 2021-10-21 16:45:28 +08:00 committed by shiziyuan9527
parent 0a1e1c0914
commit 49dde8e5a1
6 changed files with 40 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import io.metersphere.api.dto.definition.*;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.domain.ApiTestEnvironment;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.utils.PageUtils;
@ -75,6 +76,11 @@ public class ApiTestCaseController {
return apiTestCaseService.getRequest(request);
}
@GetMapping("/get/env/{id}")
public ApiTestEnvironment getApiCaseEnvironment(@PathVariable("id") String caseId) {
return apiTestCaseService.getApiCaseEnvironment(caseId);
}
@PostMapping("/get/caseBLOBs/request")
public List<ApiTestCaseInfo> getCaseBLOBs(@RequestBody ApiTestCaseRequest request) {

View File

@ -97,6 +97,8 @@ public class ApiTestCaseService {
private APITestService apiTestService;
@Resource
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
@Resource
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
@ -1117,4 +1119,14 @@ public class ApiTestCaseService {
extApiTestCaseMapper::getLastOrder,
apiTestCaseMapper::updateByPrimaryKeySelective);
}
public ApiTestEnvironment getApiCaseEnvironment(String caseId) {
String environmentId = extApiTestCaseMapper.getApiCaseEnvironment(caseId);
if (StringUtils.isBlank(environmentId)) {
return null;
}
// "environmentId"
environmentId = environmentId.substring(1,environmentId.length()-1);
return apiTestEnvironmentMapper.selectByPrimaryKey(environmentId);
}
}

View File

@ -58,5 +58,10 @@ public interface ExtApiTestCaseMapper {
Long getLastOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
int moduleCount(@Param("request")ApiTestCaseRequest request);
/**
* 获取接口用例的环境
* @param caseId 用例ID
* @return ApiEnvironment
*/
String getApiCaseEnvironment(@Param("caseId") String caseId);
}

View File

@ -709,6 +709,9 @@
</if>
order by `order` desc limit 1;
</select>
<select id="getApiCaseEnvironment" resultType="java.lang.String">
select request -> '$.useEnvironment' from api_test_case where id = #{caseId}
</select>
<update id="deleteToGc" parameterType="io.metersphere.api.dto.definition.ApiTestCaseRequest">
update api_test_case
set original_status=status,

View File

@ -137,6 +137,14 @@
</template>
</ms-table-column>
<ms-table-column
prop="environment"
:field="item"
:fields-width="fieldsWidth"
:label="'运行环境'"
>
</ms-table-column>
<ms-table-column
prop="createUser"
:field="item"
@ -589,6 +597,10 @@ export default {
if (item.status === 'Running') {
isNext = true;
}
this.$get('/api/testcase/get/env/' + item.id, res => {
let environment = res.data ? res.data.name : '-';
this.$set(item, 'environment', environment);
})
});
this.$nextTick(() => {
if (this.$refs.caseTable) {

View File

@ -57,6 +57,7 @@ export let CUSTOM_TABLE_HEADER = {
{id: 'status', key: '5', label: 'test_track.plan_view.execute_result'},
{id: 'caseStatus', key: '6', label: 'commons.status'},
{id: 'tags', key: '7', label: 'commons.tag'},
{id: 'environment', key: '10', label: 'commons.environment'},
{id: 'createUser', key: '8', label: 'api_test.creator'},
{id: 'updateTime', key: '9', label: 'api_test.definition.api_last_time'},
{id: 'createTime', key: 'a', label: 'commons.create_time'},