fix(接口定义): 快捷调试默认放到bug目录下

This commit is contained in:
fit2-zhao 2021-01-28 18:03:18 +08:00
parent 21935279ce
commit ea79196478
3 changed files with 41 additions and 3 deletions

View File

@ -29,6 +29,12 @@ public class ApiModuleController {
return apiModuleService.getNodeTreeByProjectId(projectId,protocol); return apiModuleService.getNodeTreeByProjectId(projectId,protocol);
} }
@GetMapping("/getModuleByName/{projectId}/{protocol}")
public ApiModule getModuleByName(@PathVariable String projectId,@PathVariable String protocol) {
checkPermissionService.checkProjectOwner(projectId);
return apiModuleService.getModuleByName(projectId,protocol);
}
@GetMapping("/list/plan/{planId}/{protocol}") @GetMapping("/list/plan/{planId}/{protocol}")
public List<ApiModuleDTO> getNodeByPlanId(@PathVariable String planId, @PathVariable String protocol) { public List<ApiModuleDTO> getNodeByPlanId(@PathVariable String planId, @PathVariable String protocol) {
checkPermissionService.checkTestPlanOwner(planId); checkPermissionService.checkTestPlanOwner(planId);

View File

@ -332,5 +332,27 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
public ApiModule getModuleByName(String projectId, String protocol) {
ApiModuleExample example = new ApiModuleExample();
ApiModuleExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo("bug")
.andProjectIdEqualTo(projectId).andProtocolEqualTo(protocol);
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
return modules.get(0);
} else {
ApiModule node = new ApiModule();
node.setName("bug");
node.setLevel(1);
node.setPos(0.0);
node.setParentId(null);
node.setProjectId(projectId);
node.setProtocol(protocol);
node.setCreateTime(System.currentTimeMillis());
node.setUpdateTime(System.currentTimeMillis());
node.setId(UUID.randomUUID().toString());
apiModuleMapper.insertSelective(node);
return node;
}
}
} }

View File

@ -250,9 +250,19 @@
data.method = data.protocol; data.method = data.protocol;
} }
}, },
saveApi(row) { addModule(row) {
let url = '/api/module/getModuleByName/' + getCurrentProjectID() + "/" + this.api.protocol;
this.$get(url, response => {
if (response.data) {
this.saveApi(row, response.data);
}
});
},
saveApi(row, module) {
let data = this.api; let data = this.api;
data.name = this.apiCase.name; data.name = this.apiCase.name;
data.moduleId = module.id;
data.modulePath = '/bug';
this.setParameters(data); this.setParameters(data);
let bodyFiles = this.getBodyUploadFiles(data); let bodyFiles = this.getBodyUploadFiles(data);
this.$fileUpload("/api/definition/create", null, bodyFiles, data, () => { this.$fileUpload("/api/definition/create", null, bodyFiles, data, () => {
@ -296,7 +306,7 @@
}, },
saveTestCase(row) { saveTestCase(row) {
if (this.api.saved) { if (this.api.saved) {
this.saveApi(row); this.addModule(row);
} else { } else {
this.saveCase(row); this.saveCase(row);
} }