refactor(测试计划): 功能用例关联缺陷列表增加创建人
This commit is contained in:
parent
1735124242
commit
705122cf87
|
@ -34,6 +34,9 @@ public class BugProviderDTO implements Serializable {
|
||||||
@Schema(description = "创建人")
|
@Schema(description = "创建人")
|
||||||
private String createUser;
|
private String createUser;
|
||||||
|
|
||||||
|
@Schema(description = "创建人名称")
|
||||||
|
private String createUserName;
|
||||||
|
|
||||||
@Schema(description = "处理人名称")
|
@Schema(description = "处理人名称")
|
||||||
private String handleUserName;
|
private String handleUserName;
|
||||||
|
|
||||||
|
|
|
@ -475,24 +475,23 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modelByRef != null) {
|
if (modelByRef != null) {
|
||||||
if (modelByRef instanceof ArraySchema arraySchema) {
|
return switch (modelByRef) {
|
||||||
return parseArraySchema(arraySchema.getItems(), false);
|
case ArraySchema arraySchema -> parseArraySchema(arraySchema.getItems(), false);
|
||||||
} else if (modelByRef instanceof ObjectSchema objectSchema) {
|
case ObjectSchema objectSchema -> parseObject(objectSchema, false);
|
||||||
return parseObject(objectSchema, false);
|
default -> {
|
||||||
} else {
|
JsonSchemaItem jsonSchemaItem = new JsonSchemaItem();
|
||||||
JsonSchemaItem jsonSchemaItem = new JsonSchemaItem();
|
Map<String, JsonSchemaItem> jsonSchemaProperties = new LinkedHashMap<>();
|
||||||
Map<String, JsonSchemaItem> jsonSchemaProperties = new LinkedHashMap<>();
|
if (MapUtils.isNotEmpty(modelByRef.getProperties())) {
|
||||||
if (MapUtils.isNotEmpty(modelByRef.getProperties())) {
|
modelByRef.getProperties().forEach((key, value) -> {
|
||||||
modelByRef.getProperties().forEach((key, value) -> {
|
JsonSchemaItem item = parseProperty(value, false);
|
||||||
JsonSchemaItem item = parseProperty(value, false);
|
jsonSchemaProperties.put(key, item);
|
||||||
jsonSchemaProperties.put(key, item);
|
});
|
||||||
});
|
}
|
||||||
|
jsonSchemaItem.setProperties(jsonSchemaProperties);
|
||||||
|
yield jsonSchemaItem;
|
||||||
}
|
}
|
||||||
jsonSchemaItem.setProperties(jsonSchemaProperties);
|
};
|
||||||
return jsonSchemaItem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -541,56 +540,49 @@ public class Swagger3Parser<T> extends ApiImportAbstractParser<ApiDefinitionImpo
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonSchemaItem parseProperty(Schema<?> value, boolean onlyOnce) {
|
private JsonSchemaItem parseProperty(Schema<?> value, boolean onlyOnce) {
|
||||||
if (value instanceof IntegerSchema integerSchema) {
|
|
||||||
return parseInteger(integerSchema);
|
|
||||||
}
|
|
||||||
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) {
|
|
||||||
if (onlyOnce) {
|
|
||||||
JsonSchemaItem arrayItem = new JsonSchemaItem();
|
|
||||||
arrayItem.setId(IDGenerator.nextStr());
|
|
||||||
arrayItem.setType(PropertyConstant.ARRAY);
|
|
||||||
arrayItem.setItems(new JsonSchemaItem());
|
|
||||||
return arrayItem;
|
|
||||||
}
|
|
||||||
return isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema.getItems(), true) :
|
|
||||||
parseArraySchema(arraySchema.getItems(), false);
|
|
||||||
}
|
|
||||||
if (value instanceof ObjectSchema objectSchema) {
|
|
||||||
if (onlyOnce) {
|
|
||||||
JsonSchemaItem objectItem = new JsonSchemaItem();
|
|
||||||
objectItem.setId(IDGenerator.nextStr());
|
|
||||||
objectItem.setType(PropertyConstant.OBJECT);
|
|
||||||
objectItem.setProperties(new LinkedHashMap<>());
|
|
||||||
return objectItem;
|
|
||||||
}
|
|
||||||
return isRef(objectSchema, 0) ? parseObject(objectSchema, true) :
|
|
||||||
parseObject(objectSchema, false);
|
|
||||||
}
|
|
||||||
if (StringUtils.equals(value.getType(), PropertyConstant.NULL)) {
|
if (StringUtils.equals(value.getType(), PropertyConstant.NULL)) {
|
||||||
return parseNull();
|
return parseNull();
|
||||||
}
|
}
|
||||||
if (value instanceof MapSchema mapSchema) {
|
|
||||||
return parseMapObject(mapSchema);
|
return switch (value) {
|
||||||
}
|
case IntegerSchema integerSchema -> parseInteger(integerSchema);
|
||||||
if (value instanceof Schema<?> items) {
|
case StringSchema stringSchema -> parseString(stringSchema);
|
||||||
if (isRef(items, 0)) {
|
case NumberSchema numberSchema -> parseNumber(numberSchema);
|
||||||
JsonSchemaItem arrayItem = new JsonSchemaItem();
|
case BooleanSchema booleanSchema -> parseBoolean(booleanSchema);
|
||||||
arrayItem.setId(IDGenerator.nextStr());
|
case ArraySchema arraySchema -> {
|
||||||
arrayItem.setType(PropertyConstant.OBJECT);
|
if (onlyOnce) {
|
||||||
return arrayItem;
|
JsonSchemaItem arrayItem = new JsonSchemaItem();
|
||||||
|
arrayItem.setId(IDGenerator.nextStr());
|
||||||
|
arrayItem.setType(PropertyConstant.ARRAY);
|
||||||
|
arrayItem.setItems(new JsonSchemaItem());
|
||||||
|
yield arrayItem;
|
||||||
|
}
|
||||||
|
yield isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema.getItems(), true) :
|
||||||
|
parseArraySchema(arraySchema.getItems(), false);
|
||||||
}
|
}
|
||||||
return parseSchema(items);
|
case ObjectSchema objectSchema -> {
|
||||||
}
|
if (onlyOnce) {
|
||||||
return new JsonSchemaItem();
|
JsonSchemaItem objectItem = new JsonSchemaItem();
|
||||||
|
objectItem.setId(IDGenerator.nextStr());
|
||||||
|
objectItem.setType(PropertyConstant.OBJECT);
|
||||||
|
objectItem.setProperties(new LinkedHashMap<>());
|
||||||
|
yield objectItem;
|
||||||
|
}
|
||||||
|
yield isRef(objectSchema, 0) ? parseObject(objectSchema, true) :
|
||||||
|
parseObject(objectSchema, false);
|
||||||
|
}
|
||||||
|
case MapSchema mapSchema -> parseMapObject(mapSchema);
|
||||||
|
case Schema<?> items -> {
|
||||||
|
if (isRef(items, 0)) {
|
||||||
|
JsonSchemaItem arrayItem = new JsonSchemaItem();
|
||||||
|
arrayItem.setId(IDGenerator.nextStr());
|
||||||
|
arrayItem.setType(PropertyConstant.OBJECT);
|
||||||
|
yield arrayItem;
|
||||||
|
}
|
||||||
|
yield parseSchema(items);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,7 @@
|
||||||
b.num as num,
|
b.num as num,
|
||||||
b.title as name,
|
b.title as name,
|
||||||
b.handle_user handleUser,
|
b.handle_user handleUser,
|
||||||
|
b.create_user createUser,
|
||||||
b.`status`,
|
b.`status`,
|
||||||
bc.description as content,
|
bc.description as content,
|
||||||
brc.test_plan_id testPlanId,
|
brc.test_plan_id testPlanId,
|
||||||
|
@ -283,6 +284,7 @@
|
||||||
b.num as num,
|
b.num as num,
|
||||||
b.title as name,
|
b.title as name,
|
||||||
b.handle_user handleUser,
|
b.handle_user handleUser,
|
||||||
|
b.create_user createUser,
|
||||||
b.`status`,
|
b.`status`,
|
||||||
bc.description as content,
|
bc.description as content,
|
||||||
brc.test_plan_id testPlanId,
|
brc.test_plan_id testPlanId,
|
||||||
|
|
|
@ -15,14 +15,17 @@ import io.metersphere.request.AssociateBugPageRequest;
|
||||||
import io.metersphere.request.AssociateBugRequest;
|
import io.metersphere.request.AssociateBugRequest;
|
||||||
import io.metersphere.request.BugPageProviderRequest;
|
import io.metersphere.request.BugPageProviderRequest;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
|
import io.metersphere.system.service.UserLoginService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -40,6 +43,8 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
|
||||||
private BugRelateCaseCommonService bugRelateCaseCommonService;
|
private BugRelateCaseCommonService bugRelateCaseCommonService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtBugRelateCaseMapper extBugRelateCaseMapper;
|
private ExtBugRelateCaseMapper extBugRelateCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private UserLoginService userLoginService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,9 +117,12 @@ public class AssociateBugProvider implements BaseAssociateBugProvider {
|
||||||
public List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
|
public List<BugProviderDTO> buildAssociateBugs(List<BugProviderDTO> associateBugs, String projectId) {
|
||||||
List<SelectOption> headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
|
List<SelectOption> headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId);
|
||||||
List<SelectOption> statusOption = bugStatusService.getHeaderStatusOption(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 -> {
|
associateBugs.forEach(item -> {
|
||||||
headerHandlerOption.stream().filter(option -> StringUtils.equals(option.getValue(), item.getHandleUser())).findFirst().ifPresent(option -> item.setHandleUserName(option.getText()));
|
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()));
|
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;
|
return associateBugs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue