refactor(测试计划): 功能用例关联缺陷列表增加创建人

This commit is contained in:
wxg0103 2024-05-23 18:52:24 +08:00 committed by Craftsman
parent 1735124242
commit 705122cf87
4 changed files with 67 additions and 62 deletions

View File

@ -34,6 +34,9 @@ public class BugProviderDTO implements Serializable {
@Schema(description = "创建人")
private String createUser;
@Schema(description = "创建人名称")
private String createUserName;
@Schema(description = "处理人名称")
private String handleUserName;

View File

@ -475,11 +475,10 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
}
if (modelByRef != null) {
if (modelByRef instanceof ArraySchema arraySchema) {
return parseArraySchema(arraySchema.getItems(), false);
} else if (modelByRef instanceof ObjectSchema objectSchema) {
return parseObject(objectSchema, false);
} else {
return switch (modelByRef) {
case ArraySchema arraySchema -> parseArraySchema(arraySchema.getItems(), false);
case ObjectSchema objectSchema -> parseObject(objectSchema, false);
default -> {
JsonSchemaItem jsonSchemaItem = new JsonSchemaItem();
Map<String, JsonSchemaItem> jsonSchemaProperties = new LinkedHashMap<>();
if (MapUtils.isNotEmpty(modelByRef.getProperties())) {
@ -489,10 +488,10 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
});
}
jsonSchemaItem.setProperties(jsonSchemaProperties);
return jsonSchemaItem;
yield jsonSchemaItem;
}
};
}
}
return null;
}
@ -541,56 +540,49 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
}
private JsonSchemaItem parseProperty(Schema<?> value, boolean onlyOnce) {
if (value instanceof IntegerSchema integerSchema) {
return parseInteger(integerSchema);
if (StringUtils.equals(value.getType(), PropertyConstant.NULL)) {
return parseNull();
}
if (value instanceof StringSchema stringSchema) {
return parseString(stringSchema);
}
if (value instanceof NumberSchema numberSchema) {
return parseNumber(numberSchema);
}
if (value instanceof BooleanSchema booleanSchema) {
return parseBoolean(booleanSchema);
}
if (value instanceof ArraySchema arraySchema) {
return switch (value) {
case IntegerSchema integerSchema -> parseInteger(integerSchema);
case StringSchema stringSchema -> parseString(stringSchema);
case NumberSchema numberSchema -> parseNumber(numberSchema);
case BooleanSchema booleanSchema -> parseBoolean(booleanSchema);
case ArraySchema arraySchema -> {
if (onlyOnce) {
JsonSchemaItem arrayItem = new JsonSchemaItem();
arrayItem.setId(IDGenerator.nextStr());
arrayItem.setType(PropertyConstant.ARRAY);
arrayItem.setItems(new JsonSchemaItem());
return arrayItem;
yield arrayItem;
}
return isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema.getItems(), true) :
yield isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema.getItems(), true) :
parseArraySchema(arraySchema.getItems(), false);
}
if (value instanceof ObjectSchema objectSchema) {
case ObjectSchema objectSchema -> {
if (onlyOnce) {
JsonSchemaItem objectItem = new JsonSchemaItem();
objectItem.setId(IDGenerator.nextStr());
objectItem.setType(PropertyConstant.OBJECT);
objectItem.setProperties(new LinkedHashMap<>());
return objectItem;
yield objectItem;
}
return isRef(objectSchema, 0) ? parseObject(objectSchema, true) :
yield isRef(objectSchema, 0) ? parseObject(objectSchema, true) :
parseObject(objectSchema, false);
}
if (StringUtils.equals(value.getType(), PropertyConstant.NULL)) {
return parseNull();
}
if (value instanceof MapSchema mapSchema) {
return parseMapObject(mapSchema);
}
if (value instanceof Schema<?> items) {
case MapSchema mapSchema -> parseMapObject(mapSchema);
case Schema<?> items -> {
if (isRef(items, 0)) {
JsonSchemaItem arrayItem = new JsonSchemaItem();
arrayItem.setId(IDGenerator.nextStr());
arrayItem.setType(PropertyConstant.OBJECT);
return arrayItem;
yield arrayItem;
}
return parseSchema(items);
yield parseSchema(items);
}
return new JsonSchemaItem();
};
}

View File

@ -131,6 +131,7 @@
b.num as num,
b.title as name,
b.handle_user handleUser,
b.create_user createUser,
b.`status`,
bc.description as content,
brc.test_plan_id testPlanId,
@ -283,6 +284,7 @@
b.num as num,
b.title as name,
b.handle_user handleUser,
b.create_user createUser,
b.`status`,
bc.description as content,
brc.test_plan_id testPlanId,

View File

@ -15,14 +15,17 @@ import io.metersphere.request.AssociateBugPageRequest;
import io.metersphere.request.AssociateBugRequest;
import io.metersphere.request.BugPageProviderRequest;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.service.UserLoginService;
import io.metersphere.system.uid.IDGenerator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@ -40,6 +43,8 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
private BugRelateCaseCommonService bugRelateCaseCommonService;
@Resource
private ExtBugRelateCaseMapper extBugRelateCaseMapper;
@Resource
private UserLoginService userLoginService;
@Override
@ -112,9 +117,12 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
public List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
List<SelectOption> headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(projectId);
List<String> createUserList = associateBugs.stream().map(BugProviderDTO::getCreateUser).distinct().toList();
Map<String, String> userMap = userLoginService.getUserNameMap(createUserList.stream().filter(StringUtils::isNotBlank).distinct().toList());
associateBugs.forEach(item -> {
headerHandlerOption.stream().filter(option -> StringUtils.equals(option.getValue(), item.getHandleUser())).findFirst().ifPresent(option -> item.setHandleUserName(option.getText()));
statusOption.stream().filter(option -> StringUtils.equals(option.getValue(), item.getStatus())).findFirst().ifPresent(option -> item.setStatusName(option.getText()));
item.setCreateUserName(MapUtils.isNotEmpty(userMap) && userMap.containsKey(item.getCreateUser()) ? userMap.get(item.getCreateUser()) : StringUtils.EMPTY);
});
return associateBugs;
}