Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
0450186735
|
@ -1,11 +1,20 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.SaveApiScenarioRequest;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -17,5 +26,36 @@ public class ApiAutomationController {
|
|||
@Resource
|
||||
ApiAutomationService apiAutomationService;
|
||||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
public Pager<List<ApiScenarioDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiScenarioRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
return PageUtils.setPageInfo(page, apiAutomationService.list(request));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create")
|
||||
public void create(@RequestBody SaveApiScenarioRequest request) {
|
||||
apiAutomationService.create(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/update")
|
||||
public void update(@RequestBody SaveApiScenarioRequest request) {
|
||||
apiAutomationService.update(request);
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
public void delete(@PathVariable String id) {
|
||||
apiAutomationService.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteBatch")
|
||||
public void deleteBatch(@RequestBody List<String> ids) {
|
||||
apiAutomationService.deleteBatch(ids);
|
||||
}
|
||||
|
||||
@PostMapping("/removeToGc")
|
||||
public void removeToGc(@RequestBody List<String> ids) {
|
||||
apiAutomationService.removeToGc(ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
||||
import io.metersphere.api.dto.automation.DragApiScenarioModuleRequest;
|
||||
import io.metersphere.api.service.ApiScenarioModuleService;
|
||||
import io.metersphere.base.domain.ApiScenarioModule;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.service.CheckOwnerService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("/api/automation/module")
|
||||
@RestController
|
||||
@RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER, RoleConstants.ORG_ADMIN}, logical = Logical.OR)
|
||||
public class ApiScenarioModuleController {
|
||||
|
||||
@Resource
|
||||
ApiScenarioModuleService apiScenarioModuleService;
|
||||
@Resource
|
||||
private CheckOwnerService checkOwnerService;
|
||||
|
||||
@GetMapping("/list/{projectId}")
|
||||
public List<ApiScenarioModuleDTO> getNodeByProjectId(@PathVariable String projectId) {
|
||||
checkOwnerService.checkProjectOwner(projectId);
|
||||
return apiScenarioModuleService.getNodeTreeByProjectId(projectId);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public String addNode(@RequestBody ApiScenarioModule node) {
|
||||
return apiScenarioModuleService.addNode(node);
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public int editNode(@RequestBody DragApiScenarioModuleRequest node) {
|
||||
return apiScenarioModuleService.editNode(node);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public int deleteNode(@RequestBody List<String> nodeIds) {
|
||||
//nodeIds 包含删除节点ID及其所有子节点ID
|
||||
return apiScenarioModuleService.deleteNode(nodeIds);
|
||||
}
|
||||
|
||||
@PostMapping("/drag")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public void dragNode(@RequestBody DragApiScenarioModuleRequest node) {
|
||||
apiScenarioModuleService.dragNode(node);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenario;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiScenarioDTO extends ApiScenario {
|
||||
|
||||
private String projectName;
|
||||
private String userName;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioModule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiScenarioModuleDTO extends ApiScenarioModule {
|
||||
|
||||
private String label;
|
||||
private List<ApiScenarioModuleDTO> children;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiScenarioRequest {
|
||||
private String id;
|
||||
private String excludeId;
|
||||
private String projectId;
|
||||
private String moduleId;
|
||||
private List<String> moduleIds;
|
||||
private String name;
|
||||
private String workspaceId;
|
||||
private String userId;
|
||||
private boolean recent = false;
|
||||
private List<OrderRequest> orders;
|
||||
private List<String> filters;
|
||||
private Map<String, Object> combine;
|
||||
private List<String> ids;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioModule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DragApiScenarioModuleRequest extends ApiScenarioModule {
|
||||
|
||||
List<String> nodeIds;
|
||||
ApiScenarioModuleDTO nodeTree;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SaveApiScenarioRequest {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String tagId;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String apiScenarioModuleId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String name;
|
||||
|
||||
private String level;
|
||||
|
||||
private String status;
|
||||
|
||||
private String principal;
|
||||
|
||||
private Integer stepTotal;
|
||||
|
||||
private String followPeople;
|
||||
|
||||
private String schedule;
|
||||
|
||||
private String description;
|
||||
|
||||
private String scenarioDefinition;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
public enum ScenarioStatus {
|
||||
Saved, Success, Fail, Trash
|
||||
}
|
|
@ -1,10 +1,113 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.SaveApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.ScenarioStatus;
|
||||
import io.metersphere.base.domain.ApiScenario;
|
||||
import io.metersphere.base.domain.ApiScenarioExample;
|
||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiAutomationService {
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
@Resource
|
||||
private ExtApiScenarioMapper extApiScenarioMapper;
|
||||
|
||||
public List<ApiScenarioDTO> list(ApiScenarioRequest request) {
|
||||
return extApiScenarioMapper.list(request);
|
||||
}
|
||||
|
||||
public void deleteByIds(List<String> nodeIds) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andApiScenarioModuleIdIn(nodeIds);
|
||||
apiScenarioMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void create(SaveApiScenarioRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiScenario scenario = new ApiScenario();
|
||||
scenario.setId(request.getId());
|
||||
scenario.setName(request.getName());
|
||||
scenario.setProjectId(request.getProjectId());
|
||||
scenario.setTagId(request.getTagId());
|
||||
scenario.setApiScenarioModuleId(request.getApiScenarioModuleId());
|
||||
scenario.setModulePath(request.getModulePath());
|
||||
scenario.setLevel(request.getLevel());
|
||||
scenario.setFollowPeople(request.getFollowPeople());
|
||||
scenario.setPrincipal(request.getPrincipal());
|
||||
scenario.setStepTotal(request.getStepTotal());
|
||||
scenario.setScenarioDefinition(request.getScenarioDefinition());
|
||||
scenario.setCreateTime(System.currentTimeMillis());
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setStatus(ScenarioStatus.Saved.name());
|
||||
if (request.getUserId() == null) {
|
||||
scenario.setUserId(SessionUtils.getUserId());
|
||||
} else {
|
||||
scenario.setUserId(request.getUserId());
|
||||
}
|
||||
scenario.setDescription(request.getDescription());
|
||||
apiScenarioMapper.insert(scenario);
|
||||
}
|
||||
|
||||
public void update(SaveApiScenarioRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiScenario scenario = new ApiScenario();
|
||||
scenario.setId(request.getId());
|
||||
scenario.setName(request.getName());
|
||||
scenario.setProjectId(request.getProjectId());
|
||||
scenario.setTagId(request.getTagId());
|
||||
scenario.setApiScenarioModuleId(request.getApiScenarioModuleId());
|
||||
scenario.setModulePath(request.getModulePath());
|
||||
scenario.setLevel(request.getLevel());
|
||||
scenario.setFollowPeople(request.getFollowPeople());
|
||||
scenario.setPrincipal(request.getPrincipal());
|
||||
scenario.setStepTotal(request.getStepTotal());
|
||||
scenario.setScenarioDefinition(request.getScenarioDefinition());
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setStatus(ScenarioStatus.Saved.name());
|
||||
scenario.setUserId(request.getUserId());
|
||||
scenario.setDescription(request.getDescription());
|
||||
apiScenarioMapper.updateByPrimaryKeySelective(scenario);
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
apiScenarioMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public void deleteBatch(List<String> ids) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
apiScenarioMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public void removeToGc(List<String> ids) {
|
||||
ApiScenario record = new ApiScenario();
|
||||
record.setStatus(ScenarioStatus.Trash.name());
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
apiScenarioMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
private void checkNameExist(SaveApiScenarioRequest request) {
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId())
|
||||
.andApiScenarioModuleIdEqualTo(request.getApiScenarioModuleId()).andIdNotEqualTo(request.getId());
|
||||
if (apiScenarioMapper.countByExample(example) > 0) {
|
||||
MSException.throwException(Translator.get("automation_name_already_exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
package io.metersphere.api.service;
|
||||
|
||||
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.DragApiScenarioModuleRequest;
|
||||
import io.metersphere.base.domain.ApiScenario;
|
||||
import io.metersphere.base.domain.ApiScenarioModule;
|
||||
import io.metersphere.base.domain.ApiScenarioModuleExample;
|
||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ApiScenarioModuleMapper;
|
||||
import io.metersphere.commons.constants.TestCaseConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiScenarioModuleService {
|
||||
|
||||
@Resource
|
||||
ApiScenarioModuleMapper apiScenarioModuleMapper;
|
||||
@Resource
|
||||
ApiAutomationService apiAutomationService;
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
||||
public List<ApiScenarioModuleDTO> getNodeTreeByProjectId(String projectId) {
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||
example.setOrderByClause("create_time asc");
|
||||
List<ApiScenarioModule> nodes = apiScenarioModuleMapper.selectByExample(example);
|
||||
return getNodeTrees(nodes);
|
||||
}
|
||||
|
||||
public List<ApiScenarioModuleDTO> getNodeTrees(List<ApiScenarioModule> nodes) {
|
||||
List<ApiScenarioModuleDTO> nodeTreeList = new ArrayList<>();
|
||||
Map<Integer, List<ApiScenarioModule>> nodeLevelMap = new HashMap<>();
|
||||
nodes.forEach(node -> {
|
||||
Integer level = node.getLevel();
|
||||
if (nodeLevelMap.containsKey(level)) {
|
||||
nodeLevelMap.get(level).add(node);
|
||||
} else {
|
||||
List<ApiScenarioModule> apiScenarioModules = new ArrayList<>();
|
||||
apiScenarioModules.add(node);
|
||||
nodeLevelMap.put(node.getLevel(), apiScenarioModules);
|
||||
}
|
||||
});
|
||||
List<ApiScenarioModule> rootNodes = Optional.ofNullable(nodeLevelMap.get(1)).orElse(new ArrayList<>());
|
||||
rootNodes.forEach(rootNode -> nodeTreeList.add(buildNodeTree(nodeLevelMap, rootNode)));
|
||||
return nodeTreeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建节点树
|
||||
*/
|
||||
private ApiScenarioModuleDTO buildNodeTree(Map<Integer, List<ApiScenarioModule>> nodeLevelMap, ApiScenarioModule rootNode) {
|
||||
|
||||
ApiScenarioModuleDTO nodeTree = new ApiScenarioModuleDTO();
|
||||
BeanUtils.copyBean(nodeTree, rootNode);
|
||||
nodeTree.setLabel(rootNode.getName());
|
||||
|
||||
List<ApiScenarioModule> lowerNodes = nodeLevelMap.get(rootNode.getLevel() + 1);
|
||||
if (lowerNodes == null) {
|
||||
return nodeTree;
|
||||
}
|
||||
List<ApiScenarioModuleDTO> children = Optional.ofNullable(nodeTree.getChildren()).orElse(new ArrayList<>());
|
||||
lowerNodes.forEach(node -> {
|
||||
if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) {
|
||||
children.add(buildNodeTree(nodeLevelMap, node));
|
||||
nodeTree.setChildren(children);
|
||||
}
|
||||
});
|
||||
|
||||
return nodeTree;
|
||||
}
|
||||
|
||||
public String addNode(ApiScenarioModule node) {
|
||||
validateNode(node);
|
||||
node.setCreateTime(System.currentTimeMillis());
|
||||
node.setUpdateTime(System.currentTimeMillis());
|
||||
node.setId(UUID.randomUUID().toString());
|
||||
apiScenarioModuleMapper.insertSelective(node);
|
||||
return node.getId();
|
||||
}
|
||||
|
||||
private void validateNode(ApiScenarioModule node) {
|
||||
if (node.getLevel() > TestCaseConstants.MAX_NODE_DEPTH) {
|
||||
throw new RuntimeException(Translator.get("test_case_node_level_tip")
|
||||
+ TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"));
|
||||
}
|
||||
checkApiScenarioModuleExist(node);
|
||||
}
|
||||
|
||||
private void checkApiScenarioModuleExist(ApiScenarioModule node) {
|
||||
if (node.getName() != null) {
|
||||
ApiScenarioModuleExample example = new ApiScenarioModuleExample();
|
||||
ApiScenarioModuleExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andNameEqualTo(node.getName())
|
||||
.andProjectIdEqualTo(node.getProjectId());
|
||||
if (StringUtils.isNotBlank(node.getParentId())) {
|
||||
criteria.andParentIdEqualTo(node.getParentId());
|
||||
} else {
|
||||
criteria.andParentIdIsNull();
|
||||
}
|
||||
if (StringUtils.isNotBlank(node.getId())) {
|
||||
criteria.andIdNotEqualTo(node.getId());
|
||||
}
|
||||
if (apiScenarioModuleMapper.selectByExample(example).size() > 0) {
|
||||
MSException.throwException(Translator.get("test_case_module_already_exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ApiScenarioDTO> queryByModuleIds(List<String> nodeIds) {
|
||||
ApiScenarioRequest apiScenarioRequest = new ApiScenarioRequest();
|
||||
apiScenarioRequest.setModuleIds(nodeIds);
|
||||
return apiAutomationService.list(apiScenarioRequest);
|
||||
}
|
||||
|
||||
public int editNode(DragApiScenarioModuleRequest request) {
|
||||
request.setUpdateTime(System.currentTimeMillis());
|
||||
checkApiScenarioModuleExist(request);
|
||||
List<ApiScenarioDTO> apiScenarios = queryByModuleIds(request.getNodeIds());
|
||||
|
||||
apiScenarios.forEach(apiScenario -> {
|
||||
StringBuilder path = new StringBuilder(apiScenario.getModulePath());
|
||||
List<String> pathLists = Arrays.asList(path.toString().split("/"));
|
||||
pathLists.set(request.getLevel(), request.getName());
|
||||
path.delete(0, path.length());
|
||||
for (int i = 1; i < pathLists.size(); i++) {
|
||||
path.append("/").append(pathLists.get(i));
|
||||
}
|
||||
apiScenario.setModulePath(path.toString());
|
||||
});
|
||||
|
||||
batchUpdateApiScenario(apiScenarios);
|
||||
|
||||
return apiScenarioModuleMapper.updateByPrimaryKeySelective(request);
|
||||
}
|
||||
|
||||
public int deleteNode(List<String> nodeIds) {
|
||||
apiAutomationService.deleteByIds(nodeIds);
|
||||
|
||||
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
||||
apiScenarioModuleExample.createCriteria().andIdIn(nodeIds);
|
||||
return apiScenarioModuleMapper.deleteByExample(apiScenarioModuleExample);
|
||||
}
|
||||
|
||||
private void batchUpdateApiScenario(List<ApiScenarioDTO> apiScenarios) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioMapper apiScenarioMapper = sqlSession.getMapper(ApiScenarioMapper.class);
|
||||
apiScenarios.forEach(apiScenarioMapper::updateByPrimaryKey);
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
public void dragNode(DragApiScenarioModuleRequest request) {
|
||||
|
||||
checkApiScenarioModuleExist(request);
|
||||
|
||||
List<String> nodeIds = request.getNodeIds();
|
||||
|
||||
List<ApiScenarioDTO> apiScenarios = queryByModuleIds(nodeIds);
|
||||
|
||||
ApiScenarioModuleDTO nodeTree = request.getNodeTree();
|
||||
|
||||
List<ApiScenarioModule> updateNodes = new ArrayList<>();
|
||||
|
||||
buildUpdateDefinition(nodeTree, apiScenarios, updateNodes, "/", "0", nodeTree.getLevel());
|
||||
|
||||
updateNodes = updateNodes.stream()
|
||||
.filter(item -> nodeIds.contains(item.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
batchUpdateModule(updateNodes);
|
||||
|
||||
batchUpdateApiScenario(apiScenarios);
|
||||
}
|
||||
|
||||
private void buildUpdateDefinition(ApiScenarioModuleDTO rootNode, List<ApiScenarioDTO> apiScenarios,
|
||||
List<ApiScenarioModule> updateNodes, String rootPath, String pId, int level) {
|
||||
|
||||
rootPath = rootPath + rootNode.getName();
|
||||
|
||||
if (level > 8) {
|
||||
MSException.throwException(Translator.get("node_deep_limit"));
|
||||
}
|
||||
if (rootNode.getId().equals("root")) {
|
||||
rootPath = "";
|
||||
}
|
||||
ApiScenarioModule apiScenarioModule = new ApiScenarioModule();
|
||||
apiScenarioModule.setId(rootNode.getId());
|
||||
apiScenarioModule.setLevel(level);
|
||||
apiScenarioModule.setParentId(pId);
|
||||
updateNodes.add(apiScenarioModule);
|
||||
|
||||
for (ApiScenario item : apiScenarios) {
|
||||
if (StringUtils.equals(item.getApiScenarioModuleId(), rootNode.getId())) {
|
||||
item.setModulePath(rootPath);
|
||||
}
|
||||
}
|
||||
|
||||
List<ApiScenarioModuleDTO> children = rootNode.getChildren();
|
||||
if (children != null && children.size() > 0) {
|
||||
for (ApiScenarioModuleDTO child : children) {
|
||||
buildUpdateDefinition(child, apiScenarios, updateNodes, rootPath + '/', rootNode.getId(), level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void batchUpdateModule(List<ApiScenarioModule> updateNodes) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiScenarioModuleMapper apiScenarioModuleMapper = sqlSession.getMapper(ApiScenarioModuleMapper.class);
|
||||
updateNodes.forEach(apiScenarioModuleMapper::updateByPrimaryKeySelective);
|
||||
sqlSession.flushStatements();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiScenario implements Serializable {
|
||||
|
@ -10,9 +9,15 @@ public class ApiScenario implements Serializable {
|
|||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
private String tagId;
|
||||
|
||||
private String scenarioId;
|
||||
private String userId;
|
||||
|
||||
private String apiScenarioModuleId;
|
||||
|
||||
private String modulePath;
|
||||
|
||||
private String name;
|
||||
|
||||
private String level;
|
||||
|
||||
|
@ -20,17 +25,19 @@ public class ApiScenario implements Serializable {
|
|||
|
||||
private String principal;
|
||||
|
||||
private String stepTotal;
|
||||
private Integer stepTotal;
|
||||
|
||||
private String followPeople;
|
||||
|
||||
private String schedule;
|
||||
|
||||
private String description;
|
||||
|
||||
private String scenarioDefinition;
|
||||
|
||||
private String userId;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String scenarioDefinition;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,7 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiScenarioModule implements Serializable {
|
||||
|
@ -12,14 +11,13 @@ public class ApiScenarioModule implements Serializable {
|
|||
|
||||
private String name;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private String level;
|
||||
private Integer level;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,660 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiScenarioModuleExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiScenarioModuleExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNull() {
|
||||
addCriterion("project_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIsNotNull() {
|
||||
addCriterion("project_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdEqualTo(String value) {
|
||||
addCriterion("project_id =", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotEqualTo(String value) {
|
||||
addCriterion("project_id <>", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThan(String value) {
|
||||
addCriterion("project_id >", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_id >=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThan(String value) {
|
||||
addCriterion("project_id <", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_id <=", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdLike(String value) {
|
||||
addCriterion("project_id like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotLike(String value) {
|
||||
addCriterion("project_id not like", value, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdIn(List<String> values) {
|
||||
addCriterion("project_id in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotIn(List<String> values) {
|
||||
addCriterion("project_id not in", values, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdBetween(String value1, String value2) {
|
||||
addCriterion("project_id between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectIdNotBetween(String value1, String value2) {
|
||||
addCriterion("project_id not between", value1, value2, "projectId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNull() {
|
||||
addCriterion("`name` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIsNotNull() {
|
||||
addCriterion("`name` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameEqualTo(String value) {
|
||||
addCriterion("`name` =", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotEqualTo(String value) {
|
||||
addCriterion("`name` <>", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThan(String value) {
|
||||
addCriterion("`name` >", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`name` >=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThan(String value) {
|
||||
addCriterion("`name` <", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("`name` <=", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameLike(String value) {
|
||||
addCriterion("`name` like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotLike(String value) {
|
||||
addCriterion("`name` not like", value, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameIn(List<String> values) {
|
||||
addCriterion("`name` in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotIn(List<String> values) {
|
||||
addCriterion("`name` not in", values, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameBetween(String value1, String value2) {
|
||||
addCriterion("`name` between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNameNotBetween(String value1, String value2) {
|
||||
addCriterion("`name` not between", value1, value2, "name");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIsNull() {
|
||||
addCriterion("parent_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIsNotNull() {
|
||||
addCriterion("parent_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdEqualTo(String value) {
|
||||
addCriterion("parent_id =", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotEqualTo(String value) {
|
||||
addCriterion("parent_id <>", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdGreaterThan(String value) {
|
||||
addCriterion("parent_id >", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("parent_id >=", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLessThan(String value) {
|
||||
addCriterion("parent_id <", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("parent_id <=", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdLike(String value) {
|
||||
addCriterion("parent_id like", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotLike(String value) {
|
||||
addCriterion("parent_id not like", value, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdIn(List<String> values) {
|
||||
addCriterion("parent_id in", values, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotIn(List<String> values) {
|
||||
addCriterion("parent_id not in", values, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdBetween(String value1, String value2) {
|
||||
addCriterion("parent_id between", value1, value2, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andParentIdNotBetween(String value1, String value2) {
|
||||
addCriterion("parent_id not between", value1, value2, "parentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNull() {
|
||||
addCriterion("`level` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIsNotNull() {
|
||||
addCriterion("`level` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelEqualTo(Integer value) {
|
||||
addCriterion("`level` =", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotEqualTo(Integer value) {
|
||||
addCriterion("`level` <>", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThan(Integer value) {
|
||||
addCriterion("`level` >", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("`level` >=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThan(Integer value) {
|
||||
addCriterion("`level` <", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("`level` <=", value, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelIn(List<Integer> values) {
|
||||
addCriterion("`level` in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotIn(List<Integer> values) {
|
||||
addCriterion("`level` not in", values, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`level` between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLevelNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("`level` not between", value1, value2, "level");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Long value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Long value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Long value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Long value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Long> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Long> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNull() {
|
||||
addCriterion("update_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIsNotNull() {
|
||||
addCriterion("update_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeEqualTo(Long value) {
|
||||
addCriterion("update_time =", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotEqualTo(Long value) {
|
||||
addCriterion("update_time <>", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThan(Long value) {
|
||||
addCriterion("update_time >", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time >=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThan(Long value) {
|
||||
addCriterion("update_time <", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
|
||||
addCriterion("update_time <=", value, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeIn(List<Long> values) {
|
||||
addCriterion("update_time in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotIn(List<Long> values) {
|
||||
addCriterion("update_time not in", values, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
|
||||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenario;
|
||||
import io.metersphere.base.domain.ApiScenarioExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ApiScenarioMapper {
|
||||
long countByExample(ApiScenarioExample example);
|
||||
|
||||
int deleteByExample(ApiScenarioExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiScenario record);
|
||||
|
||||
int insertSelective(ApiScenario record);
|
||||
|
||||
List<ApiScenario> selectByExampleWithBLOBs(ApiScenarioExample example);
|
||||
|
||||
List<ApiScenario> selectByExample(ApiScenarioExample example);
|
||||
|
||||
ApiScenario selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ApiScenario record, @Param("example") ApiScenarioExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") ApiScenario record, @Param("example") ApiScenarioExample example);
|
||||
|
||||
int updateByExample(@Param("record") ApiScenario record, @Param("example") ApiScenarioExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(ApiScenario record);
|
||||
|
||||
int updateByPrimaryKeyWithBLOBs(ApiScenario record);
|
||||
|
||||
int updateByPrimaryKey(ApiScenario record);
|
||||
}
|
|
@ -0,0 +1,465 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ApiScenarioMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiScenario">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="tag_id" jdbcType="VARCHAR" property="tagId" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="api_scenario_module_id" jdbcType="VARCHAR" property="apiScenarioModuleId" />
|
||||
<result column="module_path" jdbcType="VARCHAR" property="modulePath" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="level" jdbcType="VARCHAR" property="level" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="principal" jdbcType="VARCHAR" property="principal" />
|
||||
<result column="step_total" jdbcType="INTEGER" property="stepTotal" />
|
||||
<result column="follow_people" jdbcType="VARCHAR" property="followPeople" />
|
||||
<result column="schedule" jdbcType="VARCHAR" property="schedule" />
|
||||
<result column="description" jdbcType="VARCHAR" property="description" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenario">
|
||||
<result column="scenario_definition" jdbcType="LONGVARCHAR" property="scenarioDefinition" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, tag_id, user_id, api_scenario_module_id, module_path, `name`, `level`,
|
||||
`status`, principal, step_total, follow_people, schedule, description, create_time,
|
||||
update_time
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
scenario_definition
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiScenarioExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from api_scenario
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiScenarioExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from api_scenario
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from api_scenario
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from api_scenario
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiScenarioExample">
|
||||
delete from api_scenario
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenario">
|
||||
insert into api_scenario (id, project_id, tag_id,
|
||||
user_id, api_scenario_module_id, module_path,
|
||||
`name`, `level`, `status`,
|
||||
principal, step_total, follow_people,
|
||||
schedule, description, create_time,
|
||||
update_time, scenario_definition)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tagId,jdbcType=VARCHAR},
|
||||
#{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
|
||||
#{principal,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER}, #{followPeople,jdbcType=VARCHAR},
|
||||
#{schedule,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||
#{updateTime,jdbcType=BIGINT}, #{scenarioDefinition,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenario">
|
||||
insert into api_scenario
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="tagId != null">
|
||||
tag_id,
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id,
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
api_scenario_module_id,
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
module_path,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level`,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status`,
|
||||
</if>
|
||||
<if test="principal != null">
|
||||
principal,
|
||||
</if>
|
||||
<if test="stepTotal != null">
|
||||
step_total,
|
||||
</if>
|
||||
<if test="followPeople != null">
|
||||
follow_people,
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
schedule,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
scenario_definition,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tagId != null">
|
||||
#{tagId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
#{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
#{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
#{modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
#{level,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="principal != null">
|
||||
#{principal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="stepTotal != null">
|
||||
#{stepTotal,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="followPeople != null">
|
||||
#{followPeople,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
#{schedule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
#{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioExample" resultType="java.lang.Long">
|
||||
select count(*) from api_scenario
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update api_scenario
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.tagId != null">
|
||||
tag_id = #{record.tagId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.userId != null">
|
||||
user_id = #{record.userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.apiScenarioModuleId != null">
|
||||
api_scenario_module_id = #{record.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.modulePath != null">
|
||||
module_path = #{record.modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.level != null">
|
||||
`level` = #{record.level,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.status != null">
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.principal != null">
|
||||
principal = #{record.principal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.stepTotal != null">
|
||||
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.followPeople != null">
|
||||
follow_people = #{record.followPeople,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.schedule != null">
|
||||
schedule = #{record.schedule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.description != null">
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.scenarioDefinition != null">
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
update api_scenario
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
tag_id = #{record.tagId,jdbcType=VARCHAR},
|
||||
user_id = #{record.userId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{record.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_path = #{record.modulePath,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
`level` = #{record.level,jdbcType=VARCHAR},
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
principal = #{record.principal,jdbcType=VARCHAR},
|
||||
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
||||
follow_people = #{record.followPeople,jdbcType=VARCHAR},
|
||||
schedule = #{record.schedule,jdbcType=VARCHAR},
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update api_scenario
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
tag_id = #{record.tagId,jdbcType=VARCHAR},
|
||||
user_id = #{record.userId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{record.apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_path = #{record.modulePath,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
`level` = #{record.level,jdbcType=VARCHAR},
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
principal = #{record.principal,jdbcType=VARCHAR},
|
||||
step_total = #{record.stepTotal,jdbcType=INTEGER},
|
||||
follow_people = #{record.followPeople,jdbcType=VARCHAR},
|
||||
schedule = #{record.schedule,jdbcType=VARCHAR},
|
||||
description = #{record.description,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiScenario">
|
||||
update api_scenario
|
||||
<set>
|
||||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="tagId != null">
|
||||
tag_id = #{tagId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="apiScenarioModuleId != null">
|
||||
api_scenario_module_id = #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="modulePath != null">
|
||||
module_path = #{modulePath,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level` = #{level,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="principal != null">
|
||||
principal = #{principal,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="stepTotal != null">
|
||||
step_total = #{stepTotal,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="followPeople != null">
|
||||
follow_people = #{followPeople,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
schedule = #{schedule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiScenario">
|
||||
update api_scenario
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
tag_id = #{tagId,jdbcType=VARCHAR},
|
||||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_path = #{modulePath,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
`level` = #{level,jdbcType=VARCHAR},
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
principal = #{principal,jdbcType=VARCHAR},
|
||||
step_total = #{stepTotal,jdbcType=INTEGER},
|
||||
follow_people = #{followPeople,jdbcType=VARCHAR},
|
||||
schedule = #{schedule,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiScenario">
|
||||
update api_scenario
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
tag_id = #{tagId,jdbcType=VARCHAR},
|
||||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
api_scenario_module_id = #{apiScenarioModuleId,jdbcType=VARCHAR},
|
||||
module_path = #{modulePath,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
`level` = #{level,jdbcType=VARCHAR},
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
principal = #{principal,jdbcType=VARCHAR},
|
||||
step_total = #{stepTotal,jdbcType=INTEGER},
|
||||
follow_people = #{followPeople,jdbcType=VARCHAR},
|
||||
schedule = #{schedule,jdbcType=VARCHAR},
|
||||
description = #{description,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -0,0 +1,30 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioModule;
|
||||
import io.metersphere.base.domain.ApiScenarioModuleExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ApiScenarioModuleMapper {
|
||||
long countByExample(ApiScenarioModuleExample example);
|
||||
|
||||
int deleteByExample(ApiScenarioModuleExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiScenarioModule record);
|
||||
|
||||
int insertSelective(ApiScenarioModule record);
|
||||
|
||||
List<ApiScenarioModule> selectByExample(ApiScenarioModuleExample example);
|
||||
|
||||
ApiScenarioModule selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ApiScenarioModule record, @Param("example") ApiScenarioModuleExample example);
|
||||
|
||||
int updateByExample(@Param("record") ApiScenarioModule record, @Param("example") ApiScenarioModuleExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(ApiScenarioModule record);
|
||||
|
||||
int updateByPrimaryKey(ApiScenarioModule record);
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ApiScenarioModuleMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiScenarioModule">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
|
||||
<result column="level" jdbcType="INTEGER" property="level" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, `name`, parent_id, `level`, create_time, update_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from api_scenario_module
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from api_scenario_module
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from api_scenario_module
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample">
|
||||
delete from api_scenario_module
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioModule">
|
||||
insert into api_scenario_module (id, project_id, `name`,
|
||||
parent_id, `level`, create_time,
|
||||
update_time)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{parentId,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT},
|
||||
#{updateTime,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioModule">
|
||||
insert into api_scenario_module
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
project_id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name`,
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
parent_id,
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level`,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="projectId != null">
|
||||
#{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
#{parentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
#{level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultType="java.lang.Long">
|
||||
select count(*) from api_scenario_module
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update api_scenario_module
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.projectId != null">
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.name != null">
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.level != null">
|
||||
`level` = #{record.level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update api_scenario_module
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||
`name` = #{record.name,jdbcType=VARCHAR},
|
||||
parent_id = #{record.parentId,jdbcType=VARCHAR},
|
||||
`level` = #{record.level,jdbcType=INTEGER},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiScenarioModule">
|
||||
update api_scenario_module
|
||||
<set>
|
||||
<if test="projectId != null">
|
||||
project_id = #{projectId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
parent_id = #{parentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
`level` = #{level,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiScenarioModule">
|
||||
update api_scenario_module
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
`name` = #{name,jdbcType=VARCHAR},
|
||||
parent_id = #{parentId,jdbcType=VARCHAR},
|
||||
`level` = #{level,jdbcType=INTEGER},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtApiScenarioMapper {
|
||||
List<ApiScenarioDTO> list(@Param("request") ApiScenarioRequest request);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiScenarioMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.api.dto.automation.ApiScenarioDTO"
|
||||
extends="io.metersphere.base.mapper.ApiScenarioMapper.BaseResultMap">
|
||||
<result column="project_name" property="projectName"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
select api_scenario.id, api_scenario.project_id, api_scenario.tag_id, api_scenario.user_id,
|
||||
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
||||
api_scenario.status, api_scenario.principal, api_scenario.step_total, api_scenario.follow_people,
|
||||
api_scenario.schedule, api_scenario.description, api_scenario.create_time, api_scenario.update_time,
|
||||
project.name as project_name, user.name as user_name
|
||||
from api_scenario
|
||||
left join project on api_scenario.project_id = project.id
|
||||
left join user on api_scenario.user_id = user.id
|
||||
<where>
|
||||
<if test="request.name != null">
|
||||
and api_scenario.name like CONCAT('%', #{request.name},'%')
|
||||
</if>
|
||||
<if test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId}
|
||||
</if>
|
||||
<if test="request.projectId != null">
|
||||
AND project.id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.id != null">
|
||||
AND api_scenario.id = #{request.id}
|
||||
</if>
|
||||
<if test="request.userId != null">
|
||||
AND api_scenario.user_id = #{request.userId}
|
||||
</if>
|
||||
<if test="request.moduleId != null">
|
||||
AND api_scenario.api_scenario_module_id = #{request.moduleId}
|
||||
</if>
|
||||
<if test="request.projectId != null">
|
||||
AND api_scenario.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
|
||||
AND api_scenario.api_scenario_module_id in
|
||||
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
|
||||
#{nodeId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
and api_scenario.status in
|
||||
<foreach collection="request.filters" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
api_scenario.${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -172,6 +172,8 @@ api_definition_url_not_repeating=The interface request address already exists
|
|||
task_notification_jenkins=Jenkins Task notification
|
||||
task_notification=Result notification
|
||||
message_task_already_exists=Task recipient already exists
|
||||
#automation
|
||||
automation_name_already_exists=the scenario already exists in the project and the module
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -173,3 +173,5 @@ api_definition_url_not_repeating=接口请求地址已经存在
|
|||
task_notification_jenkins=jenkins任务通知
|
||||
task_notification=任务通知
|
||||
message_task_already_exists=任务接收人已经存在
|
||||
#automation
|
||||
automation_name_already_exists=同一个项目和模块下,场景名称不能重复
|
|
@ -174,4 +174,5 @@ task_notification=任務通知
|
|||
task_notification_=定時任務通知
|
||||
api_definition_url_not_repeating=接口請求地址已經存在
|
||||
message_task_already_exists=任務接收人已經存在
|
||||
|
||||
#automation
|
||||
automation_name_already_exists=同一個項目和模塊下,場景名稱不能重複
|
||||
|
|
|
@ -1,21 +1,111 @@
|
|||
<template>
|
||||
<div>
|
||||
<ms-edit-api-scenario/>
|
||||
<ms-container>
|
||||
<ms-aside-container>
|
||||
<ms-api-scenario-module @selectModule="selectModule" @getApiModuleTree="initTree" @changeProject="changeProject"
|
||||
@refresh="refresh" @saveAsEdit="editScenario"/>
|
||||
</ms-aside-container>
|
||||
<ms-main-container>
|
||||
<el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="removeTab">
|
||||
<el-tab-pane name="default" :label="$t('api_test.automation.scenario_test')">
|
||||
<ms-api-scenario-list
|
||||
:current-project="currentProject"
|
||||
:current-module="currentModule"
|
||||
@edit="editScenario"
|
||||
ref="apiScenarioList"/>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane
|
||||
:key="item.name"
|
||||
v-for="(item) in tabs"
|
||||
:label="item.label"
|
||||
:name="item.name"
|
||||
closable>
|
||||
<div class="ms-api-scenario-div">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane name="add">
|
||||
<template v-slot:label>
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini"/>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</ms-main-container>
|
||||
</ms-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsEditApiScenario from "./scenario/EditApiScenario";
|
||||
|
||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
|
||||
|
||||
export default {
|
||||
name: "ApiAutomation",
|
||||
components: {MsEditApiScenario},
|
||||
components: {MsApiScenarioModule, MsApiScenarioList, MsMainContainer, MsAsideContainer, MsContainer},
|
||||
comments: {},
|
||||
data() {
|
||||
return {}
|
||||
return {
|
||||
isHide: true,
|
||||
activeName: 'default',
|
||||
currentProject: null,
|
||||
currentModule: null,
|
||||
currentScenario: {},
|
||||
moduleOptions: {},
|
||||
tabs: [],
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
methods: {
|
||||
addTab(tab) {
|
||||
if (tab.name === 'add') {
|
||||
let label = this.$t('api_test.automation.add_scenario');
|
||||
let name = getUUID().substring(0, 8);
|
||||
this.tabs.push({label: label, name: name});
|
||||
this.activeName = name;
|
||||
}
|
||||
},
|
||||
removeTab(targetName) {
|
||||
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
|
||||
if (this.tabs.length > 0) {
|
||||
this.activeName = this.tabs[this.tabs.length - 1].name;
|
||||
} else {
|
||||
this.activeName = "default"
|
||||
}
|
||||
},
|
||||
setTabLabel(data) {
|
||||
for (const tab of this.tabs) {
|
||||
if (tab.name === this.activeName) {
|
||||
tab.label = data.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
selectModule(data) {
|
||||
this.currentModule = data;
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
},
|
||||
saveScenario(data) {
|
||||
this.setTabLabel(data);
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
},
|
||||
initTree(data) {
|
||||
this.moduleOptions = data;
|
||||
},
|
||||
changeProject(data) {
|
||||
this.currentProject = data;
|
||||
},
|
||||
refresh(data) {
|
||||
this.$refs.apiScenarioList.search(data);
|
||||
},
|
||||
editScenario(row) {
|
||||
this.currentScenario = row;
|
||||
this.addTab({name: 'add'});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<template>
|
||||
<el-dialog :close-on-click-modal="false" :title="$t('api_test.definition.request.title')" :visible.sync="visible"
|
||||
width="45%"
|
||||
:destroy-on-close="true">
|
||||
<el-form :model="scenarioForm" label-position="right" label-width="80px" size="small" :rules="rule"
|
||||
ref="scenarioForm">
|
||||
<el-form-item :label="$t('commons.name')" prop="name">
|
||||
<el-input v-model="scenarioForm.name" autocomplete="off" :placeholder="$t('commons.name')"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('api_test.automation.scenario.principal')" prop="principal">
|
||||
<el-select v-model="scenarioForm.principal"
|
||||
:placeholder="$t('api_test.automation.scenario.principal')" filterable size="small"
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in userOptions"
|
||||
:key="item.id"
|
||||
:label="item.id + ' (' + item.name + ')'"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('api_test.automation.scenario.follow_people')" prop="followPeople">
|
||||
<el-select v-model="scenarioForm.followPeople"
|
||||
:placeholder="$t('api_test.automation.scenario.follow_people')" filterable size="small"
|
||||
style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in userOptions"
|
||||
:key="item.id"
|
||||
:label="item.id + ' (' + item.name + ')'"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('commons.description')" prop="description" style="margin-bottom: 29px">
|
||||
<el-input class="ms-http-textarea" v-model="scenarioForm.description"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 10}"
|
||||
:rows="2" size="small"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template v-slot:footer>
|
||||
<ms-dialog-footer
|
||||
@cancel="visible = false"
|
||||
:isShow="true"
|
||||
title="编辑详情"
|
||||
@saveAsEdit="saveScenario(true)"
|
||||
@confirm="saveScenario">
|
||||
</ms-dialog-footer>
|
||||
|
||||
</template>
|
||||
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||
import {getCurrentUser, getUUID} from "@/common/js/utils";
|
||||
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
|
||||
|
||||
export default {
|
||||
name: "MsAddBasisScenario",
|
||||
components: {MsDialogFooter},
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
scenarioForm: {},
|
||||
visible: false,
|
||||
currentModule: {},
|
||||
projectId: "",
|
||||
userOptions: [],
|
||||
rule: {
|
||||
name: [
|
||||
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
|
||||
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
|
||||
],
|
||||
principal: [{
|
||||
required: true,
|
||||
message: this.$t('api_test.automation.scenario.select_principal'),
|
||||
trigger: 'change'
|
||||
}],
|
||||
},
|
||||
}
|
||||
}
|
||||
,
|
||||
methods: {
|
||||
saveScenario(saveAs) {
|
||||
this.$refs['scenarioForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
let path = "/api/automation/create";
|
||||
this.setParameter();
|
||||
this.result = this.$post(path, this.scenarioForm, () => {
|
||||
this.visible = false;
|
||||
if (saveAs) {
|
||||
this.scenarioForm.request = JSON.stringify(this.scenarioForm.request);
|
||||
this.$parent.saveAsEdit(this.scenarioForm);
|
||||
} else {
|
||||
this.$parent.refresh(this.currentModule);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
},
|
||||
setParameter() {
|
||||
this.scenarioForm.projectId = this.projectId;
|
||||
this.scenarioForm.id = getUUID().substring(0, 8);
|
||||
this.scenarioForm.protocol = this.currentProtocol;
|
||||
if (this.currentModule != null) {
|
||||
this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
|
||||
this.scenarioForm.apiScenarioModuleId = this.currentModule.id;
|
||||
}
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
this.userOptions = response.data;
|
||||
});
|
||||
},
|
||||
open(currentModule, projectId) {
|
||||
this.scenarioForm = {principal: getCurrentUser().id};
|
||||
this.currentModule = currentModule;
|
||||
this.projectId = projectId;
|
||||
this.getMaintainerOptions();
|
||||
this.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,158 @@
|
|||
<template>
|
||||
<el-card class="table-card" v-loading="result.loading">
|
||||
<template v-slot:header>
|
||||
<ms-table-header :condition.sync="condition" @search="search" :title="$t('commons.test')"
|
||||
:show-create="false"/>
|
||||
</template>
|
||||
|
||||
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select">
|
||||
<el-table-column width="100">
|
||||
<template v-slot:header="{row}">
|
||||
<el-dropdown id="select" size="small" split-button @command="handleCommand">
|
||||
<el-checkbox @change="selectAllChange"></el-checkbox>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="table">{{ $t('api_test.automation.scenario.select_table') }}</el-dropdown-item>
|
||||
<el-dropdown-item command="all">{{ $t('api_test.automation.scenario.select_all') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')" width="200"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="level" :label="$t('api_test.automation.case_level')" width="100"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="tagName" :label="$t('api_test.automation.tag')" width="200" show-overflow-tooltip/>
|
||||
<el-table-column prop="userId" :label="$t('api_test.automation.creator')" width="150" show-overflow-tooltip/>
|
||||
<el-table-column prop="updateTime" :label="$t('api_test.automation.update_time')" width="160">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" width="100" show-overflow-tooltip/>
|
||||
<el-table-column prop="status" :label="$t('api_test.automation.last_result')" width="100">
|
||||
<template v-slot:default="{row}">
|
||||
<el-link type="success" v-if="row.status === 'Success'">{{ $t('api_test.automation.success') }}</el-link>
|
||||
<el-link type="danger" v-if="row.status === 'Fail'">{{ $t('api_test.automation.fail') }}</el-link>
|
||||
<el-link type="info" v-if="row.status === 'Saved'">{{ $t('api_test.automation.saved') }}</el-link>
|
||||
<el-link type="warning" v-if="row.status === 'Trash'">{{ $t('api_test.automation.trash') }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="passingRate" :label="$t('api_test.automation.passing_rate')" width="100"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column :label="$t('commons.operating')">
|
||||
<template v-slot:default="{row}">
|
||||
<el-button type="text" @click="edit(row)">{{ $t('api_test.automation.edit') }}</el-button>
|
||||
<el-button type="text" @click="execute(row)">{{ $t('api_test.automation.execute') }}</el-button>
|
||||
<el-button type="text" @click="copy(row)">{{ $t('api_test.automation.copy') }}</el-button>
|
||||
<el-button type="text" @click="remove(row)">{{ $t('api_test.automation.remove') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||
:total="total"/>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||
|
||||
export default {
|
||||
name: "MsApiScenarioList",
|
||||
components: {MsTablePagination, MsTableHeader},
|
||||
props: {
|
||||
currentProject: Object,
|
||||
currentModule: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
condition: {},
|
||||
selectAll: false,
|
||||
tableData: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
this.condition.filters = ["Saved", "Success", "Fail"];
|
||||
if (this.currentModule != null) {
|
||||
if (this.currentModule.id === "root") {
|
||||
this.condition.moduleIds = [];
|
||||
} else if (this.currentModule.id === "gc") {
|
||||
this.condition.moduleIds = [];
|
||||
this.condition.filters = ["Trash"];
|
||||
} else {
|
||||
this.condition.moduleIds = this.currentModule.ids;
|
||||
}
|
||||
}
|
||||
if (this.currentProject != null) {
|
||||
this.condition.projectId = this.currentProject.id;
|
||||
}
|
||||
|
||||
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
|
||||
this.result = this.$post(url, this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
});
|
||||
},
|
||||
handleCommand(cmd) {
|
||||
let table = this.$refs.scenarioTable;
|
||||
switch (cmd) {
|
||||
case "table":
|
||||
this.selectAll = false;
|
||||
table.toggleAllSelection();
|
||||
break;
|
||||
case "all":
|
||||
this.selectAll = true;
|
||||
break
|
||||
}
|
||||
},
|
||||
selectAllChange() {
|
||||
this.handleCommand("table");
|
||||
},
|
||||
select(selection) {
|
||||
console.log(selection)
|
||||
},
|
||||
edit(row) {
|
||||
|
||||
},
|
||||
execute(row) {
|
||||
|
||||
},
|
||||
copy(row) {
|
||||
|
||||
},
|
||||
remove(row) {
|
||||
if (this.currentModule !== undefined && this.currentModule.id === "gc") {
|
||||
this.$get('/api/automation/delete/' + row.id, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = [row.id];
|
||||
this.$post('/api/automation/removeToGc/', ids, () => {
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.search();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
#select >>> .el-button-group > .el-button:first-child {
|
||||
padding: 7px 15px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,461 @@
|
|||
<template>
|
||||
<div>
|
||||
<select-menu
|
||||
:data="projects"
|
||||
:current-data="currentProject"
|
||||
:title="$t('test_track.project')"
|
||||
@dataChange="changeProject" style="margin-bottom: 20px"/>
|
||||
<el-input style="width: 275px;" :placeholder="$t('test_track.module.search')" v-model="filterText"
|
||||
size="small">
|
||||
<template v-slot:append>
|
||||
<el-button icon="el-icon-folder-add" @click="addScenario"/>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<el-tree :data="data"
|
||||
class="filter-tree node-tree"
|
||||
node-key="id"
|
||||
:default-expanded-keys="expandedNode"
|
||||
:expand-on-click-node="false"
|
||||
@node-expand="nodeExpand"
|
||||
@node-collapse="nodeCollapse"
|
||||
@node-click="selectModule"
|
||||
@node-drag-end="handleDragEnd"
|
||||
:filter-node-method="filterNode"
|
||||
draggable
|
||||
:allow-drop="allowDrop"
|
||||
:allow-drag="allowDrag" ref="tree">
|
||||
<span class="custom-tree-node father"
|
||||
slot-scope="{ node, data }">
|
||||
<!-- 如果是编辑状态 -->
|
||||
<template v-if="data.isEdit === 1">
|
||||
<el-input ref="input"
|
||||
@blur="() => submitEdit(node,data)"
|
||||
v-model="newLabel"
|
||||
class="ms-el-input" size="mini"></el-input>
|
||||
</template>
|
||||
<!-- 如果不是编辑状态 -->
|
||||
<span v-else>
|
||||
<i class="el-icon-delete" v-if="data.id==='gc'"/>
|
||||
<i class="el-icon-folder" v-else/>
|
||||
<span class="node-title" v-text="data.name"></span>
|
||||
</span>
|
||||
|
||||
<span class="node-operate child">
|
||||
<el-tooltip
|
||||
v-if="data.id!=='root' && data.id!=='gc'"
|
||||
class="item"
|
||||
effect="dark"
|
||||
:open-delay="200"
|
||||
:content="$t('test_track.module.rename')"
|
||||
placement="top">
|
||||
<i @click.stop="() => edit(node,data)" class="el-icon-edit"></i>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip
|
||||
v-if="data.id!=='gc'"
|
||||
class="item"
|
||||
effect="dark"
|
||||
:open-delay="200"
|
||||
:content="$t('test_track.module.add_submodule')"
|
||||
placement="top">
|
||||
<i @click.stop="() => append(node,data)" class="el-icon-circle-plus-outline"></i>
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip
|
||||
v-if="data.id!=='root' && data.id!=='gc'"
|
||||
class="item"
|
||||
effect="dark"
|
||||
:open-delay="200"
|
||||
:content="$t('commons.delete')"
|
||||
placement="top">
|
||||
<i @click.stop="() => remove(node, data)" class="el-icon-delete"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
|
||||
<ms-add-basis-scenario ref="basisScenario"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SelectMenu from "../../../track/common/SelectMenu";
|
||||
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
|
||||
|
||||
export default {
|
||||
name: 'MsApiScenarioModule',
|
||||
components: {
|
||||
MsAddBasisScenario,
|
||||
SelectMenu,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
httpVisible: false,
|
||||
expandedNode: [],
|
||||
filterText: "",
|
||||
nextFlag: true,
|
||||
currentProject: {},
|
||||
projects: [],
|
||||
currentModule: {},
|
||||
newLabel: "",
|
||||
data: [{
|
||||
"id": "gc",
|
||||
"name": "回收站",
|
||||
"level": 1,
|
||||
"children": [],
|
||||
}, {
|
||||
"id": "root",
|
||||
"name": "默认模块",
|
||||
"level": 0,
|
||||
"children": [],
|
||||
}]
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getProjects();
|
||||
this.changeProtocol();
|
||||
},
|
||||
watch: {
|
||||
currentProject() {
|
||||
this.getApiModuleTree();
|
||||
this.$emit('changeProject', this.currentProject);
|
||||
},
|
||||
filterText(val) {
|
||||
this.$refs.tree.filter(val);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getApiModuleTree() {
|
||||
if (this.currentProject) {
|
||||
if (this.expandedNode.length === 0) {
|
||||
this.expandedNode.push("root");
|
||||
}
|
||||
this.$get("/api/automation/module/list/" + this.currentProject.id, response => {
|
||||
if (response.data !== undefined && response.data !== null) {
|
||||
this.data[1].children = response.data;
|
||||
let moduleOptions = [];
|
||||
this.data[1].children.forEach(node => {
|
||||
this.buildNodePath(node, {path: ''}, moduleOptions);
|
||||
});
|
||||
this.$emit('getApiModuleTree', moduleOptions);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
buildNodePath(node, option, moduleOptions) {
|
||||
//递归构建节点路径
|
||||
option.id = node.id;
|
||||
option.path = option.path + '/' + node.name;
|
||||
node.path = option.path;
|
||||
moduleOptions.push(option);
|
||||
if (node.children) {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
this.buildNodePath(node.children[i], {path: option.path}, moduleOptions);
|
||||
}
|
||||
}
|
||||
},
|
||||
findTreeByNodeId(rootNode, nodeId) {
|
||||
if (rootNode.id === nodeId) {
|
||||
return rootNode;
|
||||
}
|
||||
if (rootNode.children) {
|
||||
for (let i = 0; i < rootNode.children.length; i++) {
|
||||
if (this.findTreeByNodeId(rootNode.children[i], nodeId)) {
|
||||
return rootNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
buildParam(draggingNode, dropNode, dropType) {
|
||||
let param = {};
|
||||
param.id = draggingNode.data.id;
|
||||
param.name = draggingNode.data.name;
|
||||
param.projectId = draggingNode.data.projectId;
|
||||
if (dropType === "inner") {
|
||||
param.parentId = dropNode.data.id;
|
||||
param.level = dropNode.data.level;
|
||||
} else {
|
||||
if (!dropNode.parent.id || dropNode.parent.id === 0) {
|
||||
param.parentId = 0;
|
||||
param.level = 1;
|
||||
} else {
|
||||
param.parentId = dropNode.parent.data.id;
|
||||
param.level = dropNode.parent.data.level;
|
||||
}
|
||||
}
|
||||
let nodeIds = [];
|
||||
this.getChildNodeId(draggingNode.data, nodeIds);
|
||||
if (dropNode.level === 1 && dropType !== "inner") {
|
||||
param.nodeTree = draggingNode.data;
|
||||
} else {
|
||||
for (let i = 0; i < this.data.length; i++) {
|
||||
param.nodeTree = this.findTreeByNodeId(this.data[i], dropNode.data.id);
|
||||
if (param.nodeTree) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
param.nodeIds = nodeIds;
|
||||
return param;
|
||||
},
|
||||
getTreeNode(nodes, id, list) {
|
||||
if (!nodes) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].id === id) {
|
||||
i - 1 >= 0 ? list[0] = nodes[i - 1].id : list[0] = "";
|
||||
list[1] = nodes[i].id;
|
||||
i + 1 < nodes.length ? list[2] = nodes[i + 1].id : list[2] = "";
|
||||
return;
|
||||
}
|
||||
if (nodes[i].children) {
|
||||
this.getTreeNode(nodes[i].children, id, list);
|
||||
}
|
||||
}
|
||||
},
|
||||
handleDragEnd(draggingNode, dropNode, dropType) {
|
||||
if (dropNode.data.id === "root" || dropType === "none" || dropType === undefined) {
|
||||
return;
|
||||
}
|
||||
let param = this.buildParam(draggingNode, dropNode, dropType);
|
||||
|
||||
this.list = [];
|
||||
if (param.parentId === "root") {
|
||||
param.parentId = null;
|
||||
}
|
||||
this.getTreeNode(this.data, draggingNode.data.id, this.list);
|
||||
|
||||
this.$post("/api/automation/module/drag", param, () => {
|
||||
this.getApiModuleTree();
|
||||
}, () => {
|
||||
this.getApiModuleTree();
|
||||
});
|
||||
},
|
||||
|
||||
allowDrop(draggingNode, dropNode) {
|
||||
return dropNode.data.id !== "root";
|
||||
},
|
||||
allowDrag(draggingNode) {
|
||||
// 顶层默认分组不允许拖拽
|
||||
return draggingNode.data.id !== "root";
|
||||
},
|
||||
append(node, data) {
|
||||
if (this.nextFlag === true) {
|
||||
const newChild = {
|
||||
id: "newId",
|
||||
isEdit: 0,
|
||||
name: "",
|
||||
children: []
|
||||
}
|
||||
if (!data.children) {
|
||||
this.$set(data, 'children', [])
|
||||
}
|
||||
this.nextFlag = false;
|
||||
data.children.push(newChild)
|
||||
this.edit(node, newChild);
|
||||
} else {
|
||||
this.$message.warning(this.$t('commons.please_save'));
|
||||
}
|
||||
},
|
||||
|
||||
remove(node, data) {
|
||||
if (data.name === "") {
|
||||
this.nextFlag = true;
|
||||
}
|
||||
let delIds = [];
|
||||
this.getChildNodeId(data, delIds);
|
||||
delIds.push(data.id);
|
||||
this.$post("/api/automation/module/delete", delIds, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
// 移除节点
|
||||
const parent = node.parent
|
||||
const children = parent.data.children || parent.data
|
||||
const index = children.findIndex(d => d.id !== undefined && data.id !== undefined && d.id === data.id)
|
||||
children.splice(index, 1);
|
||||
});
|
||||
},
|
||||
|
||||
edit(node, data) {
|
||||
this.$set(data, 'isEdit', 1)
|
||||
this.newLabel = data.name
|
||||
this.$nextTick(() => {
|
||||
})
|
||||
},
|
||||
|
||||
submitEdit(node, data) {
|
||||
// 触发了保存按钮
|
||||
if (this.newLabel === "") {
|
||||
this.nextFlag = false;
|
||||
this.$message.warning(this.$t('commons.input_name'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.$set(data, 'name', this.newLabel)
|
||||
let flag = this.editApiModule(node, data);
|
||||
if (flag === false) {
|
||||
this.$set(data, 'isEdit', 1)
|
||||
return;
|
||||
}
|
||||
this.$set(data, 'isEdit', 0)
|
||||
this.newLabel = ""
|
||||
this.nextFlag = true;
|
||||
},
|
||||
|
||||
cancelEdit(node, data) {
|
||||
this.newLabel = ""
|
||||
this.$set(data, 'isEdit', 0)
|
||||
},
|
||||
|
||||
getChildNodeId(rootNode, nodeIds) {
|
||||
//递归获取所有子节点ID
|
||||
nodeIds.push(rootNode.id);
|
||||
this.nodePath += rootNode.name + "/";
|
||||
if (rootNode.children) {
|
||||
for (let i = 0; i < rootNode.children.length; i++) {
|
||||
this.getChildNodeId(rootNode.children[i], nodeIds);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 保存或修改
|
||||
editApiModule(node, data) {
|
||||
if (!this.currentProject) {
|
||||
this.$error("$t('api_test.select_project')");
|
||||
return;
|
||||
}
|
||||
let url = "";
|
||||
if (data.id === "newId") {
|
||||
url = '/api/automation/module/add';
|
||||
data.level = 1;
|
||||
if (node.parent && node.parent.key !== "root") {
|
||||
data.parentId = node.parent.key;
|
||||
data.level = node.parent.level;
|
||||
}
|
||||
} else {
|
||||
url = '/api/automation/module/edit';
|
||||
let ids = [];
|
||||
this.getChildNodeId(data, ids);
|
||||
data.nodeIds = ids;
|
||||
}
|
||||
data.protocol = this.protocol;
|
||||
data.projectId = this.currentProject.id;
|
||||
this.$post(url, data, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.getApiModuleTree();
|
||||
this.nextFlag = true;
|
||||
return true;
|
||||
});
|
||||
return false;
|
||||
},
|
||||
|
||||
selectModule(data) {
|
||||
if (data.id !== "root") {
|
||||
if (data.path !== undefined && !data.path.startsWith("/")) {
|
||||
data.path = "/" + data.path;
|
||||
}
|
||||
if (data.path !== undefined && data.path.endsWith("/")) {
|
||||
data.path = data.path.substr(0, data.path.length - 1);
|
||||
}
|
||||
let nodeIds = [];
|
||||
this.getChildNodeId(data, nodeIds);
|
||||
data.ids = nodeIds;
|
||||
this.currentModule = data;
|
||||
}
|
||||
this.$emit('selectModule', data);
|
||||
},
|
||||
refresh(data) {
|
||||
this.$emit('refresh', data);
|
||||
},
|
||||
saveAsEdit(data) {
|
||||
this.$emit('saveAsEdit', data);
|
||||
},
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.name.indexOf(value) !== -1;
|
||||
},
|
||||
addScenario() {
|
||||
this.$refs.basisScenario.open(this.currentModule, this.currentProject.id);
|
||||
},
|
||||
// 项目相关方法
|
||||
changeProject(project) {
|
||||
this.currentProject = project;
|
||||
},
|
||||
getProjects() {
|
||||
this.$get("/project/listAll", (response) => {
|
||||
this.projects = response.data;
|
||||
if (this.projects.length > 0) {
|
||||
this.currentProject = this.projects[0];
|
||||
}
|
||||
});
|
||||
},
|
||||
nodeExpand(data) {
|
||||
if (data.id) {
|
||||
this.expandedNode.push(data.id);
|
||||
}
|
||||
},
|
||||
nodeCollapse(data) {
|
||||
if (data.id) {
|
||||
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
|
||||
}
|
||||
},
|
||||
changeProtocol() {
|
||||
this.getApiModuleTree();
|
||||
this.$emit('changeProtocol', this.protocol);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.node-tree {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.ms-el-input {
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.custom-tree-node {
|
||||
flex: 1 1 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
padding-right: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.father .child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.father:hover .child {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.node-title {
|
||||
width: 0;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1 1 auto;
|
||||
padding: 0 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.node-operate > i {
|
||||
color: #409eff;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
/deep/ .el-tree-node__content {
|
||||
height: 33px;
|
||||
}
|
||||
|
||||
.ms-api-buttion {
|
||||
width: 30px;
|
||||
}
|
||||
</style>
|
|
@ -542,7 +542,32 @@ export default {
|
|||
scenario_import: "场景导入",
|
||||
customize_script: "自定义脚本",
|
||||
customize_req: "自定义请求",
|
||||
reference_info: "请选择接口或用例"
|
||||
reference_info: "请选择接口或用例",
|
||||
scenario_test: "场景",
|
||||
add_scenario: "创建场景",
|
||||
scenario_name: "场景名称",
|
||||
case_level: "用例等级",
|
||||
tag: "标签",
|
||||
creator: "创建人",
|
||||
update_time: "最后更新时间",
|
||||
step: "步骤数",
|
||||
last_result: "最后结果",
|
||||
passing_rate: "通过率",
|
||||
success: "通过",
|
||||
fail: "失败",
|
||||
saved: "保存",
|
||||
trash: "回收",
|
||||
edit: "编辑",
|
||||
execute: "执行",
|
||||
copy: "复制",
|
||||
remove: "删除",
|
||||
scenario: {
|
||||
principal: "责任人",
|
||||
select_principal: "请选择责任人",
|
||||
follow_people: "关注人",
|
||||
select_table: "选择可见数据",
|
||||
select_all: "选择全部数据"
|
||||
}
|
||||
},
|
||||
environment: {
|
||||
name: "环境名称",
|
||||
|
|
Loading…
Reference in New Issue