diff --git a/backend/framework/provider/src/main/java/io/metersphere/dto/BugProviderDTO.java b/backend/framework/provider/src/main/java/io/metersphere/dto/BugProviderDTO.java index 5f3b59e9b6..f8812d4f01 100644 --- a/backend/framework/provider/src/main/java/io/metersphere/dto/BugProviderDTO.java +++ b/backend/framework/provider/src/main/java/io/metersphere/dto/BugProviderDTO.java @@ -34,6 +34,9 @@ public class BugProviderDTO implements Serializable { @Schema(description = "创建人") private String createUser; + @Schema(description = "创建人名称") + private String createUserName; + @Schema(description = "处理人名称") private String handleUserName; diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java index c86db9e8b7..0b6de64834 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java @@ -475,24 +475,23 @@ public class Swagger3Parser extends ApiImportAbstractParser jsonSchemaProperties = new LinkedHashMap<>(); - if (MapUtils.isNotEmpty(modelByRef.getProperties())) { - modelByRef.getProperties().forEach((key, value) -> { - JsonSchemaItem item = parseProperty(value, false); - jsonSchemaProperties.put(key, item); - }); + return switch (modelByRef) { + case ArraySchema arraySchema -> parseArraySchema(arraySchema.getItems(), false); + case ObjectSchema objectSchema -> parseObject(objectSchema, false); + default -> { + JsonSchemaItem jsonSchemaItem = new JsonSchemaItem(); + Map jsonSchemaProperties = new LinkedHashMap<>(); + if (MapUtils.isNotEmpty(modelByRef.getProperties())) { + modelByRef.getProperties().forEach((key, value) -> { + JsonSchemaItem item = parseProperty(value, false); + jsonSchemaProperties.put(key, item); + }); + } + jsonSchemaItem.setProperties(jsonSchemaProperties); + yield jsonSchemaItem; } - jsonSchemaItem.setProperties(jsonSchemaProperties); - return jsonSchemaItem; - } + }; } - } return null; } @@ -541,56 +540,49 @@ public class Swagger3Parser extends ApiImportAbstractParser 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)) { return parseNull(); } - if (value instanceof MapSchema mapSchema) { - return parseMapObject(mapSchema); - } - if (value instanceof Schema items) { - if (isRef(items, 0)) { - JsonSchemaItem arrayItem = new JsonSchemaItem(); - arrayItem.setId(IDGenerator.nextStr()); - arrayItem.setType(PropertyConstant.OBJECT); - return arrayItem; + + 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()); + yield arrayItem; + } + yield isRef(arraySchema.getItems(), 0) ? parseArraySchema(arraySchema.getItems(), true) : + parseArraySchema(arraySchema.getItems(), false); } - return parseSchema(items); - } - return new JsonSchemaItem(); + case ObjectSchema objectSchema -> { + if (onlyOnce) { + 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); + } + }; + } diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml index f7b33f5a3f..e306bdac87 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/mapper/ExtBugRelateCaseMapper.xml @@ -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, diff --git a/backend/services/bug-management/src/main/java/io/metersphere/bug/provider/AssociateBugProvider.java b/backend/services/bug-management/src/main/java/io/metersphere/bug/provider/AssociateBugProvider.java index dd5c37e501..bf704efbaf 100644 --- a/backend/services/bug-management/src/main/java/io/metersphere/bug/provider/AssociateBugProvider.java +++ b/backend/services/bug-management/src/main/java/io/metersphere/bug/provider/AssociateBugProvider.java @@ -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 buildAssociateBugs(List associateBugs, String projectId) { List headerHandlerOption = bugCommonService.getHeaderHandlerOption(projectId); List statusOption = bugStatusService.getHeaderStatusOption(projectId); + List createUserList = associateBugs.stream().map(BugProviderDTO::getCreateUser).distinct().toList(); + Map 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; }