fix: 关联前后置用例列表数量显示不正确

This commit is contained in:
chenjianxing 2021-10-22 15:56:48 +08:00 committed by jianxing
parent da47fe6a08
commit 113de8da6c
10 changed files with 44 additions and 142 deletions

View File

@ -322,7 +322,6 @@ public class ApiDefinitionController {
@PostMapping("/relationship/relate/{goPage}/{pageSize}") @PostMapping("/relationship/relate/{goPage}/{pageSize}")
public Pager< List<ApiDefinitionResult>> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) { public Pager< List<ApiDefinitionResult>> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); return apiDefinitionService.getRelationshipRelateList(request, goPage, pageSize);
return PageUtils.setPageInfo(page, apiDefinitionService.getRelationshipRelateList(request));
} }
} }

View File

@ -2,6 +2,8 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.automation.ApiScenarioRequest;
@ -58,6 +60,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import sun.security.util.Cache; import sun.security.util.Cache;
@ -1663,11 +1666,12 @@ public class ApiDefinitionService {
} }
} }
public List<ApiDefinitionResult> getRelationshipRelateList(ApiDefinitionRequest request) { public Pager<List<ApiDefinitionResult>> getRelationshipRelateList(ApiDefinitionRequest request, int goPage, @PathVariable int pageSize) {
request = this.initRequest(request, true, true); request = this.initRequest(request, true, true);
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
request.setNotInIds(relationshipIds); request.setNotInIds(relationshipIds);
request.setId(null); // 去掉id的查询条件 request.setId(null); // 去掉id的查询条件
return extApiDefinitionMapper.list(request); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, extApiDefinitionMapper.list(request));
} }
} }

View File

@ -559,7 +559,7 @@
</select> </select>
<select id="getTestCase" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCase" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status, select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status,
test_case.num, test_case.custom_num, test_case.priority, test_case.tags, test_case.create_time, test_case.update_time test_case.num, test_case.custom_num, test_case.tags, test_case.create_time, test_case.update_time
from test_case as test_case from test_case as test_case
<include refid="notInQueryWhereCondition"></include> <include refid="notInQueryWhereCondition"></include>
ORDER BY test_case.order DESC ORDER BY test_case.order DESC

View File

@ -127,8 +127,7 @@ public class TestCaseController {
@PostMapping("/relationship/relate/{goPage}/{pageSize}") @PostMapping("/relationship/relate/{goPage}/{pageSize}")
public Pager<List<TestCase>> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) { public Pager<List<TestCase>> getRelationshipRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); return testCaseService.getRelationshipRelateList(request, goPage, pageSize);
return PageUtils.setPageInfo(page, testCaseService.getRelationshipRelateList(request));
} }
@PostMapping("/relate/issue/{goPage}/{pageSize}") @PostMapping("/relate/issue/{goPage}/{pageSize}")

View File

@ -5,6 +5,7 @@ import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.automation.ApiScenarioDTO; import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest; import io.metersphere.api.dto.automation.ApiScenarioRequest;
@ -1955,11 +1956,12 @@ public class TestCaseService {
testCaseMapper::updateByPrimaryKeySelective); testCaseMapper::updateByPrimaryKeySelective);
} }
public List<TestCase> getRelationshipRelateList(QueryTestCaseRequest request) { public Pager<List<TestCase>> getRelationshipRelateList(QueryTestCaseRequest request, int goPage, int pageSize) {
setDefaultOrder(request); setDefaultOrder(request);
List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId()); List<String> relationshipIds = relationshipEdgeService.getRelationshipIds(request.getId());
request.setTestCaseContainIds(relationshipIds); request.setTestCaseContainIds(relationshipIds);
return extTestCaseMapper.getTestCase(request); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, extTestCaseMapper.getTestCase(request));
} }
public List<RelationshipEdgeDTO> getRelationshipCase(String id, String relationshipType) { public List<RelationshipEdgeDTO> getRelationshipCase(String id, String relationshipType) {

View File

@ -10,8 +10,6 @@
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:result="result" :result="result"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
:current-page="currentPage"
:page-size="pageSize"
:screen-height="screenHeight" :screen-height="screenHeight"
@setSelectRow="setSelectRow" @setSelectRow="setSelectRow"
@refreshTable="initTable" @refreshTable="initTable"
@ -58,8 +56,6 @@
result: {}, result: {},
screenHeight: 'calc(100vh - 400px)',//, screenHeight: 'calc(100vh - 400px)',//,
tableData: [], tableData: [],
currentPage: 1,
pageSize: 10,
environmentId: "", environmentId: "",
selectRows: new Set() selectRows: new Set()
} }
@ -133,7 +129,8 @@
this.condition.planId = this.planId; this.condition.planId = this.planId;
} }
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => { this.$nextTick(() => {
this.result = this.$post(url + this.$refs.apitable.currentPage + "/" + this.$refs.apitable.pageSize, this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
this.tableData.forEach(item => { this.tableData.forEach(item => {
@ -142,6 +139,7 @@
} }
}); });
}); });
});
}, },
setEnvironment(data) { setEnvironment(data) {
this.environmentId = data.id; this.environmentId = data.id;

View File

@ -22,8 +22,6 @@
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:result="result" :result="result"
:current-protocol="currentProtocol" :current-protocol="currentProtocol"
:current-page="currentPage"
:page-size="pageSize"
@refreshTable="initTable" @refreshTable="initTable"
ref="apitable"/> ref="apitable"/>
@ -55,8 +53,6 @@
currentRow: {}, currentRow: {},
projectId: "", projectId: "",
result: {}, result: {},
currentPage: 1,
pageSize: 10,
tableData: [] tableData: []
}; };
}, },
@ -91,6 +87,7 @@
this.condition.protocol = "HTTP"; this.condition.protocol = "HTTP";
} }
this.$nextTick(() => {
if (this.apiDefinitionId) { if (this.apiDefinitionId) {
this.condition.id = this.apiDefinitionId; this.condition.id = this.apiDefinitionId;
this.result = this.$post(this.buildPagePath('/api/definition/relationship/relate'), this.condition, response => { this.result = this.$post(this.buildPagePath('/api/definition/relationship/relate'), this.condition, response => {
@ -103,9 +100,10 @@
}); });
}); });
} }
});
}, },
buildPagePath(path) { buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize; return path + "/" + this.$refs.apitable.currentPage + "/" + this.$refs.apitable.pageSize;
}, },
setProject(projectId) { setProject(projectId) {
this.projectId = projectId; this.projectId = projectId;

View File

@ -143,7 +143,9 @@
], ],
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
methodFilters: [], methodFilters: [],
userFilters: [] userFilters: [],
currentPage: 1,
pageSize: 10,
} }
}, },
props: { props: {
@ -152,8 +154,8 @@
result: Object, result: Object,
tableData: Array, tableData: Array,
condition: Object, condition: Object,
currentPage: Number, // currentPage: Number,
pageSize: Number, // pageSize: Number,
screenHeight: { screenHeight: {
type: [Number, String], type: [Number, String],
default() { default() {

View File

@ -1,100 +0,0 @@
<template>
<api-table-list
:table-data="tableData"
:condition="condition"
:select-node-ids="selectNodeIds"
:result="result"
:current-protocol="currentProtocol"
:current-page="currentPage"
:page-size="pageSize"
@refreshTable="initTable"
ref="apitable"/>
</template>
<script>
import {
TEST_PLAN_RELEVANCE_API_DEFINITION_CONFIGS,
} from "@/business/components/common/components/search/search-components";
import ApiTableList from "@/business/components/api/definition/components/complete/ApiTableList";
export default {
name: "RelationshipRelevanceList",
components: {
ApiTableList,
},
data() {
return {
condition: {
components: TEST_PLAN_RELEVANCE_API_DEFINITION_CONFIGS
},
result: {},
tableData: [],
currentPage: 1,
pageSize: 10,
environmentId: "",
selectRows: new Set()
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
visible: {
type: Boolean,
default: false,
},
projectId: String,
apiDefinitionId: String
},
created: function () {
this.initTable();
},
watch: {
selectNodeIds() {
this.initTable();
},
currentProtocol() {
this.initTable();
},
projectId() {
this.initTable();
}
},
methods: {
initTable(projectId) {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.condition.moduleIds = this.selectNodeIds;
if (projectId != null && typeof projectId === 'string') {
this.condition.projectId = projectId;
} else if (this.projectId != null) {
this.condition.projectId = this.projectId;
}
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
} else {
this.condition.protocol = "HTTP";
}
if (this.apiDefinitionId) {
this.condition.id = this.apiDefinitionId;
this.result = this.$post(this.buildPagePath('/api/definition/relationship/relate'), this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
});
}
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
},
}
</script>
<style scoped>
</style>

View File

@ -38,7 +38,7 @@ export function hasPermission(permission) {
}); });
// todo 权限验证 // todo 权限验证
let currentProjectPermissions = user.userGroups.filter(ug => ug.group.type === 'PROJECT') let currentProjectPermissions = user.userGroups.filter(ug => ug.group && ug.group.type === 'PROJECT')
.filter(ug => ug.sourceId === getCurrentProjectID()) .filter(ug => ug.sourceId === getCurrentProjectID())
.map(ug => ug.userGroupPermissions) .map(ug => ug.userGroupPermissions)
.reduce((total, current) => { .reduce((total, current) => {
@ -56,7 +56,7 @@ export function hasPermission(permission) {
} }
} }
let currentWorkspacePermissions = user.userGroups.filter(ug => ug.group.type === 'WORKSPACE') let currentWorkspacePermissions = user.userGroups.filter(ug => ug.group && ug.group.type === 'WORKSPACE')
.filter(ug => ug.sourceId === getCurrentWorkspaceId()) .filter(ug => ug.sourceId === getCurrentWorkspaceId())
.map(ug => ug.userGroupPermissions) .map(ug => ug.userGroupPermissions)
.reduce((total, current) => { .reduce((total, current) => {
@ -74,7 +74,7 @@ export function hasPermission(permission) {
} }
} }
let systemPermissions = user.userGroups.filter(gp => gp.group.type === 'SYSTEM') let systemPermissions = user.userGroups.filter(gp => gp.group && gp.group.type === 'SYSTEM')
.filter(ug => ug.sourceId === 'system' || ug.sourceId === 'adminSourceId') .filter(ug => ug.sourceId === 'system' || ug.sourceId === 'adminSourceId')
.map(ug => ug.userGroupPermissions) .map(ug => ug.userGroupPermissions)
.reduce((total, current) => { .reduce((total, current) => {