fix(测试跟踪): 公共用例校验编辑权限
--bug=1023520 --user=陈建星 【测试跟踪】功能用例-公共用例库-操作-查看-点击下一条-从无权限项目用例切换到有权限项目用例-仍提示无权限 https://www.tapd.cn/55049933/s/1339509
This commit is contained in:
parent
9e69c839f8
commit
9f32ff4295
|
@ -1412,7 +1412,7 @@
|
||||||
inner join project p on p.id = test_case.project_id
|
inner join project p on p.id = test_case.project_id
|
||||||
<include refid="queryWhereCondition"/>
|
<include refid="queryWhereCondition"/>
|
||||||
and p.workspace_id = #{request.workspaceId}
|
and p.workspace_id = #{request.workspaceId}
|
||||||
group by tcn.id, test_case.project_id;
|
group by tcn.id;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateNoModuleTrashNodeToDefault">
|
<update id="updateNoModuleTrashNodeToDefault">
|
||||||
|
|
|
@ -179,6 +179,11 @@ public class TestCaseController {
|
||||||
return testCaseService.getSimpleCase(testCaseId);
|
return testCaseService.getSimpleCase(testCaseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/edit/simple/{testCaseId}")
|
||||||
|
public TestCaseWithBLOBs getSimpleCaseForEdit(@PathVariable String testCaseId) {
|
||||||
|
return testCaseService.getSimpleCaseForEdit(testCaseId);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/project/{testCaseId}")
|
@GetMapping("/project/{testCaseId}")
|
||||||
public Project getProjectByTestCaseId(@PathVariable String testCaseId) {
|
public Project getProjectByTestCaseId(@PathVariable String testCaseId) {
|
||||||
trackCheckPermissionService.checkTestCaseOwner(testCaseId);
|
trackCheckPermissionService.checkTestCaseOwner(testCaseId);
|
||||||
|
|
|
@ -3157,6 +3157,15 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TestCaseWithBLOBs getSimpleCaseForEdit(String testCaseId) {
|
||||||
|
TestCaseWithBLOBs testCase = testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||||
|
Project project = baseProjectService.getProjectById(testCase.getProjectId());
|
||||||
|
if (!SessionUtils.hasPermission(project.getWorkspaceId(), project.getId(), PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT)) {
|
||||||
|
MSException.throwException(Translator.get("check_owner_project"));
|
||||||
|
}
|
||||||
|
return testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||||
|
}
|
||||||
|
|
||||||
public TestCaseWithBLOBs getSimpleCase(String testCaseId) {
|
public TestCaseWithBLOBs getSimpleCase(String testCaseId) {
|
||||||
return testCaseMapper.selectByPrimaryKey(testCaseId);
|
return testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,10 @@ export function getSimpleTestCase(id) {
|
||||||
return get(BASE_URL + `get/simple/${id}`);
|
return get(BASE_URL + `get/simple/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEditSimpleTestCase(id) {
|
||||||
|
return get(BASE_URL + `get/edit/simple/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
export function getTestCaseByVersionId(refId, versionId) {
|
export function getTestCaseByVersionId(refId, versionId) {
|
||||||
return get(BASE_URL + `get/version/${refId}/${versionId}`);
|
return get(BASE_URL + `get/version/${refId}/${versionId}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@
|
||||||
<div
|
<div
|
||||||
class="edit-public-row head-opt"
|
class="edit-public-row head-opt"
|
||||||
v-if="isPublicShow"
|
v-if="isPublicShow"
|
||||||
@click="editPublicCase"
|
@click="editPublicCase()"
|
||||||
>
|
>
|
||||||
<div class="icon-row">
|
<div class="icon-row">
|
||||||
<img src="/assets/module/figma/icon_edit_outlined.svg" alt="" />
|
<img src="/assets/module/figma/icon_edit_outlined.svg" alt="" />
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 正文 -->
|
<!-- 正文 -->
|
||||||
<div class="edit-content-container" :class="{'editable-edit-content-container' : editable}">
|
<div v-loading="loading" class="edit-content-container" :class="{'editable-edit-content-container' : editable}">
|
||||||
<case-edit-info-component
|
<case-edit-info-component
|
||||||
:editable="editable"
|
:editable="editable"
|
||||||
:richTextDefaultOpen="richTextDefaultOpen"
|
:richTextDefaultOpen="richTextDefaultOpen"
|
||||||
|
@ -360,7 +360,7 @@ import {
|
||||||
hasTestCaseOtherInfo,
|
hasTestCaseOtherInfo,
|
||||||
testCaseEditFollows,
|
testCaseEditFollows,
|
||||||
testCaseGetByVersionId,
|
testCaseGetByVersionId,
|
||||||
testCaseDeleteToGc, getTestCaseNodesByCaseFilter, getTestCaseByVersionId, getSimpleTestCase,
|
testCaseDeleteToGc, getTestCaseNodesByCaseFilter, getTestCaseByVersionId, getEditSimpleTestCase, getSimpleTestCase,
|
||||||
} from "@/api/testCase";
|
} from "@/api/testCase";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -376,7 +376,7 @@ import CaseBaseInfo from "./case/CaseBaseInfo";
|
||||||
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
|
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
|
||||||
import MxVersionHistory from "./common/CaseVersionHistory"
|
import MxVersionHistory from "./common/CaseVersionHistory"
|
||||||
import {buildTree} from "metersphere-frontend/src/model/NodeTree";
|
import {buildTree} from "metersphere-frontend/src/model/NodeTree";
|
||||||
import {versionEnableByProjectId} from "@/api/project";
|
import {getProject, versionEnableByProjectId} from "@/api/project";
|
||||||
import {openCaseEdit} from "@/business/case/test-case";
|
import {openCaseEdit} from "@/business/case/test-case";
|
||||||
import ListItemDeleteConfirm from "metersphere-frontend/src/components/ListItemDeleteConfirm";
|
import ListItemDeleteConfirm from "metersphere-frontend/src/components/ListItemDeleteConfirm";
|
||||||
import CaseDiffSideViewer from "./case/diff/CaseDiffSideViewer";
|
import CaseDiffSideViewer from "./case/diff/CaseDiffSideViewer";
|
||||||
|
@ -581,8 +581,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
routeProjectId() {
|
routeProjectId() {
|
||||||
let pId = this.$route.params.projectId;
|
return this.$route.params.projectId;
|
||||||
return pId ? pId : getCurrentProjectID();
|
|
||||||
},
|
},
|
||||||
moduleOptions() {
|
moduleOptions() {
|
||||||
return store.testCaseModuleOptions;
|
return store.testCaseModuleOptions;
|
||||||
|
@ -688,6 +687,7 @@ export default {
|
||||||
},
|
},
|
||||||
created(){
|
created(){
|
||||||
this.$EventBus.$on('projectChange', () => {
|
this.$EventBus.$on('projectChange', () => {
|
||||||
|
localStorage.setItem('projectChangeFlag', 'true');
|
||||||
this.$router.push('/track/case/all');
|
this.$router.push('/track/case/all');
|
||||||
});
|
});
|
||||||
this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent);
|
this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent);
|
||||||
|
@ -728,6 +728,11 @@ export default {
|
||||||
},
|
},
|
||||||
async loadTestCase() {
|
async loadTestCase() {
|
||||||
|
|
||||||
|
if (localStorage.getItem('projectChangeFlag')) {
|
||||||
|
localStorage.removeItem('projectChangeFlag');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let initFuc = this.initEdit;
|
let initFuc = this.initEdit;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
|
@ -758,15 +763,18 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTestCaseNodesByCaseFilter(this.projectId, {})
|
if (!this.isPublicShow) {
|
||||||
.then(r => {
|
// 公共用例库不展示模块,这里调用接口会有权限校验
|
||||||
this.treeNodes = r.data;
|
getTestCaseNodesByCaseFilter(this.projectId, {})
|
||||||
this.treeNodes.forEach(node => {
|
.then(r => {
|
||||||
node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
|
this.treeNodes = r.data;
|
||||||
buildTree(node, {path: ''});
|
this.treeNodes.forEach(node => {
|
||||||
this.setNodeModule();
|
node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
|
||||||
|
buildTree(node, {path: ''});
|
||||||
|
this.setNodeModule();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
getTestCaseFollow(this.caseId).then((response) => {
|
getTestCaseFollow(this.caseId).then((response) => {
|
||||||
this.form.follows = response.data;
|
this.form.follows = response.data;
|
||||||
|
@ -802,7 +810,12 @@ export default {
|
||||||
this.checkVersionEnable();
|
this.checkVersionEnable();
|
||||||
},
|
},
|
||||||
editPublicCase(type) {
|
editPublicCase(type) {
|
||||||
openCaseEdit({caseId: this.caseId, type}, this)
|
// 这个接口会校验权限
|
||||||
|
getEditSimpleTestCase(this.caseId)
|
||||||
|
.then(() => {
|
||||||
|
openCaseEdit({caseId: this.caseId, type}, this);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
copyPublicCase() {
|
copyPublicCase() {
|
||||||
this.editPublicCase('copy');
|
this.editPublicCase('copy');
|
||||||
|
@ -980,7 +993,7 @@ export default {
|
||||||
},
|
},
|
||||||
async checkCurrentProject() {
|
async checkCurrentProject() {
|
||||||
if (this.isPublicShow) {
|
if (this.isPublicShow) {
|
||||||
// 如果是用例库查看用例
|
// 用例库查看用例
|
||||||
await getSimpleTestCase(this.caseId).then((response) => {
|
await getSimpleTestCase(this.caseId).then((response) => {
|
||||||
let testCase = response.data;
|
let testCase = response.data;
|
||||||
this.projectId = testCase.projectId;
|
this.projectId = testCase.projectId;
|
||||||
|
@ -993,17 +1006,22 @@ export default {
|
||||||
setCurrentProjectID(this.projectId);
|
setCurrentProjectID(this.projectId);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (this.caseId) {
|
||||||
if (this.caseId) {
|
// 接口会校验是否有改用例的编辑权限
|
||||||
await getSimpleTestCase(this.caseId).then((response) => {
|
await getEditSimpleTestCase(this.caseId).then((response) => {
|
||||||
let testCase = response.data;
|
let testCase = response.data;
|
||||||
if (getCurrentProjectID() !== testCase.projectId) {
|
if (getCurrentProjectID() !== testCase.projectId) {
|
||||||
// 如果不是当前项目,先切项目
|
// 如果不是当前项目,先切项目
|
||||||
setCurrentProjectID(testCase.projectId);
|
setCurrentProjectID(testCase.projectId);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
} else {
|
||||||
})
|
this.projectId = testCase.projectId;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// 没有权限则跳转到根路径
|
||||||
|
this.$router.push("/");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,7 +47,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="module-row case-wrap">
|
<!-- 用例库展示项目,不展示模块 -->
|
||||||
|
<div class="module-row case-wrap" v-else>
|
||||||
<div class="case-title-wrap">
|
<div class="case-title-wrap">
|
||||||
<div class="name title-wrap">
|
<div class="name title-wrap">
|
||||||
{{ $t("test_track.case.module") }}
|
{{ $t("test_track.case.module") }}
|
||||||
|
|
|
@ -229,8 +229,8 @@ import TestCaseReviewStatusTableItem from "@/business/common/tableItems/TestCase
|
||||||
import BatchMove from "@/business/case/components/BatchMove";
|
import BatchMove from "@/business/case/components/BatchMove";
|
||||||
import TestCasePreview from "@/business/case/components/TestCasePreview";
|
import TestCasePreview from "@/business/case/components/TestCasePreview";
|
||||||
import {
|
import {
|
||||||
deletePublicTestCaseVersion, editTestCaseOrder, getTestCase,
|
deletePublicTestCaseVersion, editTestCaseOrder, getEditSimpleTestCase,
|
||||||
getTestCaseStep, getTestCaseVersions, testCaseBatchDeleteToGc, testCasePublicBatchCopy,
|
getTestCaseStep, getTestCaseVersions, testCasePublicBatchCopy,
|
||||||
testCasePublicBatchDeleteToGc, testCasePublicList,
|
testCasePublicBatchDeleteToGc, testCasePublicList,
|
||||||
} from "@/api/testCase";
|
} from "@/api/testCase";
|
||||||
import ListItemDeleteConfirm from "metersphere-frontend/src/components/ListItemDeleteConfirm";
|
import ListItemDeleteConfirm from "metersphere-frontend/src/components/ListItemDeleteConfirm";
|
||||||
|
@ -448,7 +448,12 @@ export default {
|
||||||
this.selectCounts = this.$refs.table.selectDataCounts;
|
this.selectCounts = this.$refs.table.selectDataCounts;
|
||||||
},
|
},
|
||||||
handleEdit(testCase, type) {
|
handleEdit(testCase, type) {
|
||||||
openCaseEdit({caseId: testCase.id, type}, this);
|
// 这个接口会校验权限
|
||||||
|
getEditSimpleTestCase(testCase.id)
|
||||||
|
.then(() => {
|
||||||
|
openCaseEdit({caseId: testCase.id, type}, this);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
},
|
},
|
||||||
handleEditShow(testCase, column) {
|
handleEditShow(testCase, column) {
|
||||||
this.$refs.publicTestCaseShow.open(testCase.id);
|
this.$refs.publicTestCaseShow.open(testCase.id);
|
||||||
|
|
|
@ -66,7 +66,7 @@ export default {
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
publicCaseId() {
|
publicCaseId() {
|
||||||
if (this.publicCaseId) {
|
if (this.publicCaseId && this.$refs.testCaseEdit) {
|
||||||
this.$refs.testCaseEdit.loadTestCase();
|
this.$refs.testCaseEdit.loadTestCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue