refactor: 默认模块改为未规划的模块

This commit is contained in:
chenjianxing 2021-09-08 14:53:52 +08:00 committed by jianxing
parent 45636c5186
commit a6f916702c
18 changed files with 47 additions and 26 deletions

View File

@ -194,7 +194,7 @@ public class MsScenarioParser extends MsAbstractParser<ScenarioImport> {
if (StringUtils.isNotBlank(this.selectModulePath)) { if (StringUtils.isNotBlank(this.selectModulePath)) {
apiScenarioWithBLOBs.setModulePath(this.selectModulePath + path); apiScenarioWithBLOBs.setModulePath(this.selectModulePath + path);
} else if (StringUtils.isBlank(importRequest.getModuleId())) { } else if (StringUtils.isBlank(importRequest.getModuleId())) {
apiScenarioWithBLOBs.setModulePath("/默认模块" + path); apiScenarioWithBLOBs.setModulePath("/未规划场景" + path);
} }
} }
} }

View File

@ -123,7 +123,7 @@ public class HarParser extends HarAbstractParser {
if (StringUtils.isNotBlank(selectModulePath)) { if (StringUtils.isNotBlank(selectModulePath)) {
apiDefinition.setModulePath(selectModulePath); apiDefinition.setModulePath(selectModulePath);
} else { } else {
apiDefinition.setModulePath("/默认模块"); apiDefinition.setModulePath("/未规划接口");
} }
results.add(apiDefinition); results.add(apiDefinition);
} }

View File

@ -165,7 +165,7 @@ public class MsDefinitionParser extends MsAbstractParser<ApiDefinitionImport> {
if (StringUtils.isNotBlank(this.selectModulePath)) { if (StringUtils.isNotBlank(this.selectModulePath)) {
apiDefinition.setModulePath(this.selectModulePath + path); apiDefinition.setModulePath(this.selectModulePath + path);
} else if (StringUtils.isBlank(importRequest.getModuleId())){ } else if (StringUtils.isBlank(importRequest.getModuleId())){
apiDefinition.setModulePath("/默认模块" + path); apiDefinition.setModulePath("/未规划接口" + path);
} }
} }
} }

View File

@ -407,7 +407,7 @@ public class ApiAutomationService {
if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || "default-module".equals(request.getApiScenarioModuleId())) { if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || "default-module".equals(request.getApiScenarioModuleId())) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andNameEqualTo("未规划场景");
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example); List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) { if (CollectionUtils.isNotEmpty(modules)) {
scenario.setApiScenarioModuleId(modules.get(0).getId()); scenario.setApiScenarioModuleId(modules.get(0).getId());

View File

@ -408,11 +408,11 @@ public class ApiDefinitionService {
test.setFollowPeople(request.getFollowPeople()); test.setFollowPeople(request.getFollowPeople());
if (StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) { if (StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("未规划接口");
List<ApiModule> modules = apiModuleMapper.selectByExample(example); List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) { if (CollectionUtils.isNotEmpty(modules)) {
test.setModuleId(modules.get(0).getId()); test.setModuleId(modules.get(0).getId());
test.setModulePath("/默认模块"); test.setModulePath("/未规划接口");
} }
} }
test.setResponse(JSONObject.toJSONString(request.getResponse())); test.setResponse(JSONObject.toJSONString(request.getResponse()));
@ -770,7 +770,7 @@ public class ApiDefinitionService {
private void setModule(ApiDefinitionWithBLOBs item) { private void setModule(ApiDefinitionWithBLOBs item) {
if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) { if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("未规划接口");
List<ApiModule> modules = apiModuleMapper.selectByExample(example); List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) { if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId()); item.setModuleId(modules.get(0).getId());

View File

@ -504,12 +504,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
public ApiModule getDefaultNode(String projectId,String protocol) { public ApiModule getDefaultNode(String projectId,String protocol) {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("默认模块").andParentIdIsNull();; example.createCriteria().andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol).andNameEqualTo("未规划接口").andParentIdIsNull();;
List<ApiModule> list = apiModuleMapper.selectByExample(example); List<ApiModule> list = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
ApiModule record = new ApiModule(); ApiModule record = new ApiModule();
record.setId(UUID.randomUUID().toString()); record.setId(UUID.randomUUID().toString());
record.setName("默认模块"); record.setName("未规划接口");
record.setProtocol(protocol); record.setProtocol(protocol);
record.setPos(1.0); record.setPos(1.0);
record.setLevel(1); record.setLevel(1);

View File

@ -447,12 +447,12 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
public ApiScenarioModule getDefaultNode(String projectId) { public ApiScenarioModule getDefaultNode(String projectId) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("默认模块").andParentIdIsNull(); example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("未规划场景").andParentIdIsNull();
List<ApiScenarioModule> list = apiScenarioModuleMapper.selectByExample(example); List<ApiScenarioModule> list = apiScenarioModuleMapper.selectByExample(example);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
ApiScenarioModule record = new ApiScenarioModule(); ApiScenarioModule record = new ApiScenarioModule();
record.setId(UUID.randomUUID().toString()); record.setId(UUID.randomUUID().toString());
record.setName("默认模块"); record.setName("未规划场景");
record.setPos(1.0); record.setPos(1.0);
record.setLevel(1); record.setLevel(1);
record.setCreateTime(System.currentTimeMillis()); record.setCreateTime(System.currentTimeMillis());

View File

@ -123,14 +123,14 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
public TestCaseNode getDefaultNode(String projectId) { public TestCaseNode getDefaultNode(String projectId) {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("默认模块").andParentIdIsNull();; example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("未规划用例").andParentIdIsNull();;
List<TestCaseNode> list = testCaseNodeMapper.selectByExample(example); List<TestCaseNode> list = testCaseNodeMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){ if(CollectionUtils.isEmpty(list)){
NodeNumDTO record = new NodeNumDTO(); NodeNumDTO record = new NodeNumDTO();
//TestCaseNode record = new TestCaseNode(); //TestCaseNode record = new TestCaseNode();
record.setId(UUID.randomUUID().toString()); record.setId(UUID.randomUUID().toString());
record.setCreateUser(SessionUtils.getUserId()); record.setCreateUser(SessionUtils.getUserId());
record.setName("默认模块"); record.setName("未规划用例");
record.setPos(1.0); record.setPos(1.0);
record.setLevel(1); record.setLevel(1);
record.setCreateTime(System.currentTimeMillis()); record.setCreateTime(System.currentTimeMillis());

View File

@ -143,7 +143,7 @@ public class TestCaseService {
private void setNode(TestCaseWithBLOBs testCase) { private void setNode(TestCaseWithBLOBs testCase) {
if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) { if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("未规划用例");
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example); List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(nodes)) { if (CollectionUtils.isNotEmpty(nodes)) {
testCase.setNodeId(nodes.get(0).getId()); testCase.setNodeId(nodes.get(0).getId());

View File

@ -15,4 +15,15 @@ CREATE TABLE `plugin` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = InnoDB ) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 DEFAULT CHARSET = utf8mb4
COLLATE utf8mb4_general_ci; COLLATE utf8mb4_general_ci;
update test_case_node set name = '未规划用例' where name = '默认模块' and `level` = 1;
update test_case set node_path = replace (`node_path`,'/默认模块','/未规划用例') where node_path like '/默认模块%';
update api_module set name = '未规划接口' where name = '默认模块' and `level` = 1;
update api_definition set module_path = replace (`module_path`,'/默认模块','/未规划接口') where module_path like '/默认模块%';
update api_scenario_module set name = '未规划场景' where name = '默认模块' and `level` = 1;
update api_scenario set module_path = replace (`module_path`,'/默认模块','/未规划场景') where module_path like '/默认模块%';

View File

@ -7,11 +7,12 @@
:is-display="getIsRelevance" :is-display="getIsRelevance"
v-loading="result.loading" v-loading="result.loading"
:tree-nodes="data" :tree-nodes="data"
:allLabel="$t('commons.all_module_title')" :allLabel="$t('全部场景')"
:type="isReadOnly ? 'view' : 'edit'" :type="isReadOnly ? 'view' : 'edit'"
:delete-permission="['PROJECT_API_SCENARIO:READ+DELETE']" :delete-permission="['PROJECT_API_SCENARIO:READ+DELETE']"
:add-permission="['PROJECT_API_SCENARIO:READ+CREATE']" :add-permission="['PROJECT_API_SCENARIO:READ+CREATE']"
:update-permission="['PROJECT_API_SCENARIO:READ+EDIT']" :update-permission="['PROJECT_API_SCENARIO:READ+EDIT']"
:default-label="'未规划场景'"
@add="add" @add="add"
@edit="edit" @edit="edit"
@drag="drag" @drag="drag"

View File

@ -8,7 +8,8 @@
v-loading="result.loading" v-loading="result.loading"
:tree-nodes="data" :tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'" :type="isReadOnly ? 'view' : 'edit'"
:allLabel="$t('commons.all_module_title')" :allLabel="$t('全部接口')"
:default-label="'未规划接口'"
@add="add" @add="add"
@edit="edit" @edit="edit"
@drag="drag" @drag="drag"

View File

@ -98,7 +98,7 @@
return; return;
} }
if (this.currentModule.id === "root") { if (this.currentModule.id === "root") {
this.$warning("不能选默认模块,请重新选择一个模块"); this.$warning("不能选模块,请重新选择一个模块");
return; return;
} }
this.loading = true; this.loading = true;

View File

@ -369,7 +369,7 @@ export default {
if ('default-module' === data.nodeId) { if ('default-module' === data.nodeId) {
for (let i = 0; i < this.moduleOptions.length; i++) { for (let i = 0; i < this.moduleOptions.length; i++) {
let item = this.moduleOptions[i]; let item = this.moduleOptions[i];
if (item.path.indexOf('默认模块') > -1) { if (item.path.indexOf('未规划用例') > -1) {
data.nodeId = item.id; data.nodeId = item.id;
break; break;
} }

View File

@ -117,7 +117,7 @@ export default {
this.testCaseForm.nodePath = this.currentModule.path; this.testCaseForm.nodePath = this.currentModule.path;
this.testCaseForm.nodeId = this.currentModule.id; this.testCaseForm.nodeId = this.currentModule.id;
} else { } else {
this.testCaseForm.nodePath = "/默认模块" this.testCaseForm.nodePath = "/未规划用例"
this.testCaseForm.nodeId = "default-module" this.testCaseForm.nodeId = "default-module"
} }
this.result = this.$post(path, this.testCaseForm, response => { this.result = this.$post(path, this.testCaseForm, response => {

View File

@ -203,7 +203,7 @@
form: { form: {
name: '', name: '',
module: 'default-module', module: 'default-module',
nodePath: '/默认模块', nodePath: '/未规划用例',
maintainer: getCurrentUser().id, maintainer: getCurrentUser().id,
priority: 'P0', priority: 'P0',
type: '', type: '',

View File

@ -35,7 +35,7 @@
</span> </span>
<span v-if="!disabled" class="node-operate child"> <span v-if="!disabled" class="node-operate child">
<el-tooltip <el-tooltip
v-if="data.id !== 'root' && data.name !=='默认模块'" v-if="data.id !== 'root' && data.name !== defaultLabel"
class="item" class="item"
effect="dark" effect="dark"
v-permission="updatePermission" v-permission="updatePermission"
@ -45,7 +45,7 @@
<i @click.stop="edit(node, data)" class="el-icon-edit"></i> <i @click.stop="edit(node, data)" class="el-icon-edit"></i>
</el-tooltip> </el-tooltip>
<el-tooltip <el-tooltip
v-if="data.name ==='默认模块' && data.level !==1" v-if="data.name === defaultLabel && data.level !==1"
v-permission="updatePermission" v-permission="updatePermission"
class="item" class="item"
effect="dark" effect="dark"
@ -59,13 +59,14 @@
effect="dark" effect="dark"
:open-delay="200" :open-delay="200"
v-permission="addPermission" v-permission="addPermission"
v-if="!(data.name === defaultLabel && data.level ===1)"
:content="$t('test_track.module.add_submodule')" :content="$t('test_track.module.add_submodule')"
placement="top"> placement="top">
<i @click.stop="append(node, data)" class="el-icon-circle-plus-outline"></i> <i @click.stop="append(node, data)" class="el-icon-circle-plus-outline"></i>
</el-tooltip> </el-tooltip>
<el-tooltip <el-tooltip
v-if="data.name ==='默认模块' && data.level !==1" v-if="data.name === defaultLabel && data.level !==1"
class="item" effect="dark" class="item" effect="dark"
:open-delay="200" :open-delay="200"
v-permission="deletePermission" v-permission="deletePermission"
@ -75,7 +76,7 @@
</el-tooltip> </el-tooltip>
<el-tooltip <el-tooltip
v-if="data.id !== 'root' && data.name !=='默认模块'" v-if="data.id !== 'root' && data.name !== defaultLabel"
class="item" effect="dark" class="item" effect="dark"
:open-delay="200" :open-delay="200"
:content="$t('commons.delete')" :content="$t('commons.delete')"
@ -124,6 +125,12 @@ export default {
return this.$t("commons.all_label.case"); return this.$t("commons.all_label.case");
} }
}, },
defaultLabel: {
type: String,
default() {
return '默认模块';
}
},
nameLimit: { nameLimit: {
type: Number, type: Number,
default() { default() {
@ -317,7 +324,7 @@ export default {
if (dropType === "none" || dropType === undefined) { if (dropType === "none" || dropType === undefined) {
return; return;
} }
if (dropNode.data.id === 'root' && dropType === 'before' || draggingNode.data.name==='默认模块') { if (dropNode.data.id === 'root' && dropType === 'before' || draggingNode.data.name === this.defaultLabel) {
this.$emit('refresh'); this.$emit('refresh');
return false; return false;
} }

View File

@ -9,6 +9,7 @@
:delete-permission="['PROJECT_TRACK_CASE:READ+DELETE']" :delete-permission="['PROJECT_TRACK_CASE:READ+DELETE']"
:add-permission="['PROJECT_TRACK_CASE:READ+CREATE']" :add-permission="['PROJECT_TRACK_CASE:READ+CREATE']"
:update-permission="['PROJECT_TRACK_CASE:READ+EDIT']" :update-permission="['PROJECT_TRACK_CASE:READ+EDIT']"
:default-label="'未规划用例'"
@add="add" @add="add"
@edit="edit" @edit="edit"
@drag="drag" @drag="drag"