fix(接口测试): 场景导入创建人默认

--user=郭雨琦
场景导入创建人默认
查case也要过滤
This commit is contained in:
guoyuqi 2022-03-29 17:34:07 +08:00 committed by 刘瑞斌
parent 2aadf5a4fb
commit ab31ec2fe9
2 changed files with 8 additions and 5 deletions

View File

@ -116,9 +116,7 @@ public class ApiScenarioImportUtil {
}
}
private static ApiDefinition getApiDefinitionResult(JSONObject object, ApiDefinitionService apiDefinitionService,Map<String,ApiDefinition>definitionMap) {
CheckPermissionService checkPermissionService = CommonBeanFactory.getBean(CheckPermissionService.class);
Set<String> userRelatedProjectIds = checkPermissionService.getUserRelatedProjectIds();
private static ApiDefinition getApiDefinitionResult(JSONObject object, ApiDefinitionService apiDefinitionService,Map<String,ApiDefinition>definitionMap,Set<String> userRelatedProjectIds) {
List<String> projectIds = new ArrayList<>(userRelatedProjectIds);
ApiDefinitionExample apiDefinitionExample = new ApiDefinitionExample();
apiDefinitionExample.createCriteria()
@ -147,8 +145,10 @@ public class ApiScenarioImportUtil {
ApiTestCaseService testCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
ApiTestCaseWithBLOBs bloBs = testCaseService.get(object.getString("id"));
if (bloBs == null) {
ApiDefinition apiDefinition = getApiDefinitionResult(object,apiDefinitionService,definitionMap);
CheckPermissionService checkPermissionService = CommonBeanFactory.getBean(CheckPermissionService.class);
Set<String> userRelatedProjectIds = checkPermissionService.getUserRelatedProjectIds();
if (bloBs == null||!userRelatedProjectIds.contains(bloBs.getProjectId())) {
ApiDefinition apiDefinition = getApiDefinitionResult(object,apiDefinitionService,definitionMap,userRelatedProjectIds);
if(apiDefinition!=null){
if(MapUtils.isNotEmpty(definitionMap)||definitionMap.size()==0){
structureCaseByJson(i,object,testCaseService, apiDefinition,apiTestCaseMapper);

View File

@ -1299,6 +1299,9 @@ public class ApiAutomationService {
if (StringUtils.isBlank(item.getId())) {
item.setId(UUID.randomUUID().toString());
}
item.setCreateUser(SessionUtils.getUserId());
item.setUserId(SessionUtils.getUserId());
item.setPrincipal(SessionUtils.getUserId());
// 导入之后刷新latest
importCreate(item, batchMapper, extApiScenarioMapper, request,apiTestCaseMapper,apiDefinitionMapper);
if (i % 300 == 0) {