diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonEncryptionController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonEncryptionController.java index 428ab36e..33fa09f0 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonEncryptionController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonEncryptionController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +@Deprecated @Controller @RequestMapping("/api/config/comparison/encryption") public class ComparisonEncryptionController extends diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonExclusionsController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonExclusionsController.java index e9a0ca8b..afc41168 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonExclusionsController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonExclusionsController.java @@ -5,6 +5,7 @@ import com.arextest.web.core.business.config.ConfigurableHandler; import com.arextest.web.core.business.config.replay.ComparisonExclusionsConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonExclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import java.util.List; import org.apache.commons.lang3.StringUtils; @@ -73,4 +74,13 @@ public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType re return ResponseUtils.successResponse(configs); } + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + exclusionsHandler.pageQueryComparisonConfig(request) + ); + } + + } \ No newline at end of file diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonIgnoreCategoryController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonIgnoreCategoryController.java index 098c1d77..f46c8237 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonIgnoreCategoryController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonIgnoreCategoryController.java @@ -5,6 +5,7 @@ import com.arextest.web.core.business.config.ConfigurableHandler; import com.arextest.web.core.business.config.replay.ComparisonIgnoreCategoryConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import java.util.List; import org.apache.commons.lang3.StringUtils; @@ -60,4 +61,13 @@ public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType re ignoreCategoryHandler.removeDetailsExpired(configs, request.getFilterExpired()); return ResponseUtils.successResponse(configs); } + + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + ignoreCategoryHandler.pageQueryComparisonConfig(request) + ); + } + } diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonInclusionsController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonInclusionsController.java index fe5a190b..c1aadcab 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonInclusionsController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonInclusionsController.java @@ -5,6 +5,7 @@ import com.arextest.web.core.business.config.ConfigurableHandler; import com.arextest.web.core.business.config.replay.ComparisonInclusionsConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonInclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import jakarta.annotation.Resource; import lombok.Getter; @@ -64,4 +65,12 @@ public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType re request.getOperationName())); } + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + comparisonInclusionsConfigurableHandler.pageQueryComparisonConfig(request) + ); + } + } diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonListSortController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonListSortController.java index 555ee44a..c7681d96 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonListSortController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonListSortController.java @@ -5,6 +5,7 @@ import com.arextest.web.core.business.config.ConfigurableHandler; import com.arextest.web.core.business.config.replay.ComparisonListSortConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonListSortConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import jakarta.annotation.Resource; import lombok.Getter; @@ -67,4 +68,12 @@ public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType re request.getAppId(), request.getOperationId(), request.getOperationType(), request.getOperationName())); } + + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + comparisonListSortConfigurableHandler.pageQueryComparisonConfig(request) + ); + } } diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonReferenceController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonReferenceController.java index a57e4fb9..0cb87942 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonReferenceController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonReferenceController.java @@ -5,6 +5,7 @@ import com.arextest.web.core.business.config.ConfigurableHandler; import com.arextest.web.core.business.config.replay.ComparisonReferenceConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonReferenceConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import jakarta.annotation.Resource; import lombok.Getter; @@ -68,4 +69,12 @@ public Response queryComparisonConfig(@RequestBody QueryComparisonRequestType re request.getOperationName())); } + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + comparisonReferenceConfigurableHandler.pageQueryComparisonConfig(request) + ); + } + } diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonRootTransformController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonRootTransformController.java index 108721e1..d1082606 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonRootTransformController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonRootTransformController.java @@ -7,6 +7,7 @@ import com.arextest.web.core.business.config.replay.ComparisonTransformConfigurableHandler; import com.arextest.web.model.contract.contracts.config.replay.ComparisonRootTransformConfiguration; import com.arextest.web.model.contract.contracts.config.replay.ComparisonTransformConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; import com.arextest.web.model.contract.contracts.config.replay.QueryComparisonRequestType; import com.arextest.web.model.mapper.ConfigComparisonTransformMapper; import java.util.List; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @RestController @@ -68,5 +70,13 @@ public Response modify(@PathVariable ModifyType modifyType, return ResponseUtils.resourceNotFoundResponse(); } + @PostMapping("/pageQueryComparisonConfig") + @ResponseBody + public Response pageQueryComparisonConfig(@RequestBody PageQueryComparisonRequestType request) { + return ResponseUtils.successResponse( + comparisonTransformConfigurableHandler.pageQueryComparisonConfig(request) + ); + } + } diff --git a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonSummaryController.java b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonSummaryController.java index 4cd68f9b..3c3e119e 100644 --- a/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonSummaryController.java +++ b/arex-web-api/src/main/java/com/arextest/web/api/service/controller/config/ComparisonSummaryController.java @@ -28,6 +28,9 @@ public class ComparisonSummaryController { @Resource ComparisonSummaryService comparisonSummaryService; +// @Resource +// PageComparisonSummaryService pageComparisonSummaryService; + @RequestMapping("/queryByInterfaceId") @ResponseBody public final Response queryByInterfaceId(@RequestParam String interfaceId) { @@ -64,4 +67,11 @@ public Response queryCompareConfig(@RequestBody QueryCompareConfigRequestType re return ResponseUtils.successResponse(replayCompareConfig); } +// @PostMapping("/{category}/queryCompareConfigByCategory") +// public Response queryCompareConfigByCategory(@PathVariable ComparisonCategoryType category, +// @Valid @RequestBody PageQueryComparisonRequestType request) { +// return ResponseUtils.successResponse( +// pageComparisonSummaryService.queryCompareConfigByCategory(category, request); +// } + } \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/application/ApplicationOperationConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/application/ApplicationOperationConfigurableHandler.java index 0575bb69..78e22cf0 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/application/ApplicationOperationConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/application/ApplicationOperationConfigurableHandler.java @@ -7,8 +7,6 @@ import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.business.config.AbstractConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; -import com.arextest.web.model.dao.mongodb.AppContractCollection; -import com.arextest.web.model.dao.mongodb.AppContractCollection.Fields; import com.arextest.web.model.dto.AppContractDto; import com.arextest.web.model.enums.ContractTypeEnum; import java.util.ArrayList; @@ -22,7 +20,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import software.amazon.awssdk.services.sso.endpoints.internal.Value.Str; /** * @author jmo @@ -91,5 +88,46 @@ public List queryOperationByName(String appId return applicationOperationConfigurations; } +// public List queryByOperationIds(String appId, +// List operationIds) { +// List applicationOperationConfigurations = +// applicationOperationConfigurationRepository.listBy(appId); +// +// List queryOperationIds = new ArrayList<>(); +// List result = new ArrayList<>(); +// Set operationSet = new HashSet<>(operationIds); +// for (ApplicationOperationConfiguration applicationOperationConfiguration : applicationOperationConfigurations) { +// if (CollectionUtils.isEmpty(operationSet) || operationSet.contains( +// applicationOperationConfiguration.getId())) { +// queryOperationIds.add(applicationOperationConfiguration.getId()); +// result.add(applicationOperationConfiguration); +// } +// } +// +// List appContractDtoList = +// appContractRepository.queryAppContractListByOpIds(queryOperationIds, null); +// +// Map> dependenciesByOperationId = appContractDtoList.stream() +// .filter( +// item -> Objects.equals(item.getContractType(), ContractTypeEnum.DEPENDENCY.getCode())) +// .collect(Collectors.groupingBy( +// AppContractDto::getOperationId, +// Collectors.mapping( +// item -> { +// Dependency dependency = new Dependency(); +// dependency.setDependencyId(item.getId()); +// dependency.setOperationType(item.getOperationType()); +// dependency.setOperationName(item.getOperationName()); +// return dependency; +// }, +// Collectors.toList() +// ) +// )); +// for (ApplicationOperationConfiguration applicationOperationConfiguration : result) { +// applicationOperationConfiguration.setDependencyList( +// dependenciesByOperationId.get(applicationOperationConfiguration.getId())); +// } +// return result; +// } } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/AbstractComparisonConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/AbstractComparisonConfigurableHandler.java index 8787f529..4e46b68b 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/AbstractComparisonConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/AbstractComparisonConfigurableHandler.java @@ -1,6 +1,9 @@ package com.arextest.web.core.business.config.replay; +import com.arextest.config.model.dto.application.ApplicationOperationConfiguration; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.business.config.AbstractConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.model.contract.contracts.config.replay.AbstractComparisonDetailsConfiguration; @@ -17,6 +20,7 @@ import java.util.stream.Stream; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; /** * @author jmo @@ -114,6 +118,40 @@ public boolean removeByAppId(String appId) { return repositoryProvider.listBy(appId).isEmpty() || repositoryProvider.removeByAppId(appId); } + protected Pair, Map> getOperationAndDependencyInfos( + List configs, + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository, + AppContractRepository appContractRepository) { + Map operationInfos = new HashMap<>(); + Map dependencyInfos = new HashMap<>(); + for (T item : configs) { +// if (StringUtils.isNotEmpty(item.getOperationId())) { +// operationInfos.put(item.getOperationId(), null); +// } + operationInfos.put(item.getOperationId(), null); + dependencyInfos.put(item.getDependencyId(), null); +// if (StringUtils.isNotEmpty(item.getDependencyId())) { +// dependencyInfos.put(item.getDependencyId(), null); +// } + } + List operationConfigurations = + applicationOperationConfigurationRepository.queryByOperationIdList(operationInfos.keySet()); + for (ApplicationOperationConfiguration operationConfiguration : operationConfigurations) { + operationInfos.put(operationConfiguration.getId(), operationConfiguration.getOperationName()); + } + + List appContractDtos = appContractRepository.queryAppContractsByIds( + dependencyInfos.keySet()); + for (AppContractDto appContractDto : appContractDtos) { + Dependency dependency = new Dependency(); + dependency.setDependencyId(appContractDto.getId()); + dependency.setOperationType(appContractDto.getOperationType()); + dependency.setOperationName(appContractDto.getOperationName()); + dependencyInfos.put(appContractDto.getId(), dependency); + } + return Pair.of(operationInfos, dependencyInfos); + } + void addDependencyId(List comparisonDetails) { Map notFoundAppContractMap = new HashMap<>(); for (T comparisonDetail : comparisonDetails) { diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonEncryptionConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonEncryptionConfigurableHandler.java index f8f71c44..9241586d 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonEncryptionConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonEncryptionConfigurableHandler.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +@Deprecated @Component public class ComparisonEncryptionConfigurableHandler extends AbstractComparisonConfigurableHandler { diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonExclusionsConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonExclusionsConfigurableHandler.java index fc0e6b6d..3f96e525 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonExclusionsConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonExclusionsConfigurableHandler.java @@ -1,16 +1,26 @@ package com.arextest.web.core.business.config.replay; import com.arextest.config.model.dto.application.ApplicationOperationConfiguration; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.business.config.application.ApplicationOperationConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; import com.arextest.web.core.repository.mongo.ComparisonExclusionsConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.config.replay.ComparisonExclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; -import java.util.List; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; import jakarta.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -27,6 +37,10 @@ public class ComparisonExclusionsConfigurableHandler ApplicationOperationConfigurableHandler applicationOperationConfigurableHandler; @Resource ComparisonExclusionsConfigurationRepositoryImpl comparisonExclusionsConfigurationRepository; + @Resource + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + AppContractRepository appContractRepository; protected ComparisonExclusionsConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @@ -63,4 +77,43 @@ public List queryByInterfaceId(String interfa } return result; } + + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + comparisonExclusionsConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setExclusions(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonExclusionsConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo)); + } + return result; + } + } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonIgnoreCategoryConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonIgnoreCategoryConfigurableHandler.java index 395b4d37..1b6f256e 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonIgnoreCategoryConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonIgnoreCategoryConfigurableHandler.java @@ -1,17 +1,27 @@ package com.arextest.web.core.business.config.replay; import com.arextest.config.model.dto.application.ApplicationOperationConfiguration; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.model.mock.MockCategoryType; import com.arextest.web.core.business.config.application.ApplicationOperationConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; +import com.arextest.web.core.repository.mongo.ComparisonIgnoreCategoryConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.compare.CategoryDetail; import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; +import java.util.ArrayList; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -32,6 +42,10 @@ public class ComparisonIgnoreCategoryConfigurableHandler ApplicationOperationConfigurableHandler applicationOperationConfigurableHandler; @Resource private ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + ComparisonIgnoreCategoryConfigurationRepositoryImpl ignoreCategoryConfigurationRepository; + @Resource + AppContractRepository appContractRepository; protected ComparisonIgnoreCategoryConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @@ -85,4 +99,47 @@ public boolean update(ComparisonIgnoreCategoryConfiguration configuration) { checkBeforeModify(configuration); return super.update(configuration); } + + + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + ignoreCategoryConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setIgnoreCategories(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonIgnoreCategoryConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo) + ); + } + return result; + } + + + } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonInclusionsConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonInclusionsConfigurableHandler.java index ed6c7614..7dc55c88 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonInclusionsConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonInclusionsConfigurableHandler.java @@ -1,15 +1,26 @@ package com.arextest.web.core.business.config.replay; import com.arextest.config.model.dto.application.ApplicationOperationConfiguration; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.business.config.application.ApplicationOperationConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; +import com.arextest.web.core.repository.mongo.ComparisonInclusionsConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.config.replay.ComparisonInclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; -import java.util.List; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; import jakarta.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,6 +35,13 @@ public class ComparisonInclusionsConfigurableHandler FSInterfaceRepository fsInterfaceRepository; @Resource ApplicationOperationConfigurableHandler applicationOperationConfigurableHandler; + @Resource + ComparisonInclusionsConfigurationRepositoryImpl inclusionsConfigurationRepository; + @Resource + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + AppContractRepository appContractRepository; + protected ComparisonInclusionsConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @@ -52,4 +70,43 @@ public List queryByInterfaceId(String interfa return result; } + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + inclusionsConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setInclusions(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonInclusionsConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo) + ); + } + return result; + } + } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonListSortConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonListSortConfigurableHandler.java index 6a9640c8..29160544 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonListSortConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonListSortConfigurableHandler.java @@ -1,12 +1,23 @@ package com.arextest.web.core.business.config.replay; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; +import com.arextest.web.core.repository.mongo.ComparisonListSortConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.config.replay.ComparisonListSortConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; -import java.util.List; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; import jakarta.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -25,6 +36,12 @@ public class ComparisonListSortConfigurableHandler ComparisonReferenceConfigurableHandler referenceHandler; @Resource ListKeyCycleDetectionHandler listKeyCycleDetectionHandler; + @Resource + ComparisonListSortConfigurationRepositoryImpl listSortConfigurationRepository; + @Resource + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + AppContractRepository appContractRepository; protected ComparisonListSortConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @@ -59,4 +76,44 @@ public boolean insertList(List configurationLis } return super.insertList(configurationList); } + + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + listSortConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setListSorts(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonListSortConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo) + ); + } + return result; + } + } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonReferenceConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonReferenceConfigurableHandler.java index a25accfa..7633760e 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonReferenceConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonReferenceConfigurableHandler.java @@ -1,13 +1,26 @@ package com.arextest.web.core.business.config.replay; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; +import com.arextest.web.core.repository.mongo.ComparisonListSortConfigurationRepositoryImpl; +import com.arextest.web.core.repository.mongo.ComparisonReferenceConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.config.replay.ComparisonReferenceConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonReferenceConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; +import java.util.ArrayList; import java.util.List; import jakarta.annotation.Resource; +import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -25,6 +38,13 @@ public class ComparisonReferenceConfigurableHandler ComparisonListSortConfigurableHandler listSortHandler; @Resource ListKeyCycleDetectionHandler listKeyCycleDetectionHandler; + @Resource + ComparisonReferenceConfigurationRepositoryImpl referenceConfigurationRepository; + @Resource + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + AppContractRepository appContractRepository; + protected ComparisonReferenceConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @@ -59,4 +79,44 @@ public boolean insertList(List configurationLi } return super.insertList(configurationList); } + + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + referenceConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setReferenceInfos(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonReferenceConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo) + ); + } + return result; + } + } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonTransformConfigurableHandler.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonTransformConfigurableHandler.java index 72e2443b..0c193245 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonTransformConfigurableHandler.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/ComparisonTransformConfigurableHandler.java @@ -2,19 +2,31 @@ import com.arextest.config.model.dao.config.SystemConfigurationCollection.KeySummary; import com.arextest.config.model.dto.application.ApplicationOperationConfiguration; +import com.arextest.config.model.dto.application.Dependency; import com.arextest.config.model.dto.system.SystemConfiguration; import com.arextest.config.repository.ConfigRepositoryProvider; +import com.arextest.config.repository.impl.ApplicationOperationConfigurationRepositoryImpl; import com.arextest.web.core.business.SystemConfigurationService; import com.arextest.web.core.business.config.application.ApplicationOperationConfigurableHandler; import com.arextest.web.core.repository.AppContractRepository; import com.arextest.web.core.repository.FSInterfaceRepository; import com.arextest.web.core.repository.mongo.ComparisonTransformConfigurationRepositoryImpl; import com.arextest.web.model.contract.contracts.config.replay.ComparisonTransformConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonTransformConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType.RootTransformInfo; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.dto.filesystem.FSInterfaceDto; +import com.arextest.web.model.mapper.PageQueryComparisonMapper; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import jakarta.annotation.Resource; +import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -35,6 +47,11 @@ public class ComparisonTransformConfigurableHandler @Resource SystemConfigurationService systemConfigurationService; + @Resource + ApplicationOperationConfigurationRepositoryImpl applicationOperationConfigurationRepository; + @Resource + AppContractRepository appContractRepository; + protected ComparisonTransformConfigurableHandler( @Autowired ConfigRepositoryProvider repositoryProvider, @Autowired AppContractRepository appContractRepository) { @@ -78,4 +95,43 @@ public List getTransformMethodList() { ? Collections.emptyList() : comparePluginInfoConfig.getComparePluginInfo().getTransMethodList(); } + + public PageQueryComparisonResponseType pageQueryComparisonConfig( + PageQueryComparisonRequestType requestType) { + PageQueryComparisonDto pageQueryComparisonDto = PageQueryComparisonMapper.INSTANCE.dtoFromContract( + requestType); + PageQueryComparisonResultDto queryResult = + comparisonTransformConfigurationRepository.pageQueryComparisonConfig( + pageQueryComparisonDto); + + // get the information of interface and dependency involved in the configuration + List configs = queryResult.getConfigs(); + Pair, Map> operationAndDependencyInfos = + getOperationAndDependencyInfos(configs, applicationOperationConfigurationRepository, + appContractRepository); + Map operationInfos = operationAndDependencyInfos.getLeft(); + Map dependencyInfos = operationAndDependencyInfos.getRight(); + PageQueryComparisonResponseType result = new PageQueryComparisonResponseType(); + result.setTotalCount(queryResult.getTotalCount()); + result.setRootTransformInfos(contractFromDto(configs, operationInfos, dependencyInfos)); + return result; + } + + private List contractFromDto( + List dto, Map operationInfo, + Map dependencyInfo) { + List result = new ArrayList<>(); + for (ComparisonTransformConfiguration item : dto) { + if (item.getOperationId() != null && operationInfo.get(item.getOperationId()) == null) { + continue; + } + if (item.getDependencyId() != null && dependencyInfo.get(item.getDependencyId()) == null) { + continue; + } + result.add( + PageQueryComparisonMapper.INSTANCE.contractFromDto(item, operationInfo, dependencyInfo) + ); + } + return result; + } } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/PageComparisonSummaryService.java b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/PageComparisonSummaryService.java new file mode 100644 index 00000000..78c9a5e0 --- /dev/null +++ b/arex-web-core/src/main/java/com/arextest/web/core/business/config/replay/PageComparisonSummaryService.java @@ -0,0 +1,99 @@ +//package com.arextest.web.core.business.config.replay; +// +//import com.arextest.web.core.repository.mongo.ComparisonExclusionsConfigurationRepositoryImpl; +//import com.arextest.web.core.repository.mongo.ComparisonIgnoreCategoryConfigurationRepositoryImpl; +//import com.arextest.web.core.repository.mongo.ComparisonInclusionsConfigurationRepositoryImpl; +//import com.arextest.web.core.repository.mongo.ComparisonListSortConfigurationRepositoryImpl; +//import com.arextest.web.core.repository.mongo.ComparisonReferenceConfigurationRepositoryImpl; +//import com.arextest.web.core.repository.mongo.ComparisonTransformConfigurationRepositoryImpl; +//import com.arextest.web.model.contract.contracts.config.replay.ComparisonCategoryType; +//import com.arextest.web.model.contract.contracts.config.replay.QueryConfigByTypeRequestType; +//import com.arextest.web.model.contract.contracts.config.replay.QueryConfigByTypeResponseType; +//import jakarta.annotation.Resource; +//import lombok.extern.slf4j.Slf4j; +// +//@Slf4j +//public class PageComparisonSummaryService { +// +// @Resource +// private ComparisonExclusionsConfigurationRepositoryImpl comparisonExclusionsConfigurationRepository; +// +// @Resource +// private ComparisonInclusionsConfigurationRepositoryImpl comparisonInclusionsConfigurationRepository; +// +// @Resource +// private ComparisonIgnoreCategoryConfigurationRepositoryImpl comparisonIgnoreCategoryConfigurationRepository; +// +// @Resource +// private ComparisonListSortConfigurationRepositoryImpl comparisonListSortConfigurationRepository; +// +// @Resource +// private ComparisonReferenceConfigurationRepositoryImpl comparisonReferenceConfigurationRepository; +// +// @Resource +// private ComparisonTransformConfigurationRepositoryImpl comparisonTransformConfigurationRepository; +// +// +// public QueryConfigByTypeResponseType queryCompareConfigByCategory(ComparisonCategoryType category, +// QueryConfigByTypeRequestType request) { +// switch (category) { +// case EXCLUSION: +// return comparisonExclusionsConfigurationRepository.findByAppId(appId); +// case INCLUSION: +// return comparisonInclusionsConfigurationRepository.findByAppId(appId); +// case IGNORE_CATEGORY: +// return comparisonIgnoreCategoryConfigurationRepository.findByAppId(appId); +// case LIST_SORT: +// return comparisonListSortConfigurationRepository.findByAppId(appId); +// case REFERENCE: +// return comparisonReferenceConfigurationRepository.findByAppId(appId); +// case ROOT_TRANSFORM: +// return comparisonTransformConfigurationRepository.findByAppId(appId); +// default: +// log.warn("Unknown category: {}", category); +// return Collections.emptyList(); +// } +// +// return new QueryConfigByTypeResponseType(); +// } +// +// protected QueryConfigByTypeResponseType queryExclusionConfig(QueryConfigByTypeRequestType request) { +//// return queryCompareConfigByCategory(ComparisonCategoryType.EXCLUSION, request); +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryInclusionConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryIgnoreCategoryConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryListSortConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryReferenceConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryRootTransformConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryConfigOfCategory(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// protected QueryConfigByTypeResponseType queryCompareConfig(QueryConfigByTypeRequestType request) { +// return null; +// } +// +// +// +// +// +// +// +//} \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/AppContractRepository.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/AppContractRepository.java index 87f0a4f6..c4131909 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/AppContractRepository.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/AppContractRepository.java @@ -1,6 +1,7 @@ package com.arextest.web.core.repository; import com.arextest.web.model.dto.AppContractDto; +import java.util.Collection; import java.util.List; public interface AppContractRepository extends RepositoryProvider { @@ -28,4 +29,6 @@ List queryAppContractListByOpIds(List operationList, List queryDependencyWithAppId(String appId, String operationName, String operationType); + + List queryAppContractsByIds(Collection ids); } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/AppContractRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/AppContractRepositoryImpl.java index 4fb8df16..efa790d5 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/AppContractRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/AppContractRepositoryImpl.java @@ -7,11 +7,13 @@ import com.arextest.web.model.dto.AppContractDto; import com.arextest.web.model.enums.ContractTypeEnum; import com.arextest.web.model.mapper.AppContractMapper; +import jakarta.annotation.Resource; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -205,10 +207,21 @@ public List queryAppContracts(String appId) { @Override public List queryDependencyWithAppId(String appId, String operationName, String operationType) { - Query query = Query.query(Criteria.where(AppContractCollection.Fields.appId).is(appId) - .and(AppContractCollection.Fields.operationName).is(operationName) - .and(AppContractCollection.Fields.operationType).is(operationType)); - List daos = mongoTemplate.find(query, AppContractCollection.class); - return daos.stream().map(AppContractMapper.INSTANCE::dtoFromDao).collect(Collectors.toList()); + Query query = Query.query(Criteria.where(AppContractCollection.Fields.appId).is(appId) + .and(AppContractCollection.Fields.operationName).is(operationName) + .and(AppContractCollection.Fields.operationType).is(operationType)); + List daos = mongoTemplate.find(query, AppContractCollection.class); + return daos.stream().map(AppContractMapper.INSTANCE::dtoFromDao).collect(Collectors.toList()); + } + + @Override + public List queryAppContractsByIds(Collection ids) { + if (CollectionUtils.isEmpty(ids)) { + return Collections.emptyList(); + } + Query query = new Query(Criteria.where(DASH_ID).in(ids)); + return mongoTemplate.find(query, AppContractCollection.class) + .stream().map(AppContractMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); } } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonEncryptionConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonEncryptionConfigurationRepositoryImpl.java index d9ca68c9..58dd2b34 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonEncryptionConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonEncryptionConfigurationRepositoryImpl.java @@ -24,6 +24,7 @@ import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Component; +@Deprecated @Component @Slf4j public class ComparisonEncryptionConfigurationRepositoryImpl diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonExclusionsConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonExclusionsConfigurationRepositoryImpl.java index a2d17353..f90d8a28 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonExclusionsConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonExclusionsConfigurationRepositoryImpl.java @@ -8,16 +8,20 @@ import com.arextest.web.model.dao.mongodb.ConfigComparisonExclusionsCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.mapper.ConfigComparisonExclusionsMapper; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.BulkOperations; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; @@ -229,4 +233,43 @@ public List queryConfigOfCategory( return daos.stream().map(ConfigComparisonExclusionsMapper.INSTANCE::dtoFromDao) .collect(Collectors.toList()); } + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ConfigComparisonExclusionsCollection.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonExclusionsCollection.class) + .stream() + .map(ConfigComparisonExclusionsMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } } \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonIgnoreCategoryConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonIgnoreCategoryConfigurationRepositoryImpl.java index 7dc212fd..f4b99bb3 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonIgnoreCategoryConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonIgnoreCategoryConfigurationRepositoryImpl.java @@ -4,13 +4,22 @@ import com.arextest.web.core.repository.mongo.util.MongoHelper; import com.arextest.web.model.contract.contracts.common.enums.CompareConfigType; import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration; +import com.arextest.web.model.dao.mongodb.ConfigComparisonIgnoreCategoryCollection; import com.arextest.web.model.dao.mongodb.ConfigComparisonIgnoreCategoryCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails; +import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; +import com.arextest.web.model.mapper.ConfigComparisonExclusionsMapper; import com.arextest.web.model.mapper.ConfigComparisonIgnoreCategoryMapper; import com.mongodb.client.result.UpdateResult; +import java.util.Objects; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; @@ -130,4 +139,43 @@ public boolean insert(ComparisonIgnoreCategoryConfiguration configuration) { ConfigComparisonIgnoreCategoryCollection.class); return dao != null; } + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ConfigComparisonIgnoreCategoryCollection.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonIgnoreCategoryCollection.class) + .stream() + .map(ConfigComparisonIgnoreCategoryMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } } diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonInclusionsConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonInclusionsConfigurationRepositoryImpl.java index cbac4d12..dec10417 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonInclusionsConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonInclusionsConfigurationRepositoryImpl.java @@ -4,18 +4,26 @@ import com.arextest.web.common.LogUtils; import com.arextest.web.core.repository.mongo.util.MongoHelper; import com.arextest.web.model.contract.contracts.common.enums.CompareConfigType; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonExclusionsConfiguration; import com.arextest.web.model.contract.contracts.config.replay.ComparisonInclusionsConfiguration; +import com.arextest.web.model.dao.mongodb.ConfigComparisonExclusionsCollection; import com.arextest.web.model.dao.mongodb.ConfigComparisonInclusionsCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails; +import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; +import com.arextest.web.model.mapper.ConfigComparisonExclusionsMapper; import com.arextest.web.model.mapper.ConfigComparisonInclusionsMapper; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.BulkOperations; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; @@ -180,4 +188,44 @@ public ComparisonInclusionsConfiguration queryById(String id) { mongoTemplate.findOne(query, ConfigComparisonInclusionsCollection.class); return ConfigComparisonInclusionsMapper.INSTANCE.dtoFromDao(dao); } + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ConfigComparisonInclusionsCollection.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonInclusionsCollection.class) + .stream() + .map(ConfigComparisonInclusionsMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } + } \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonListSortConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonListSortConfigurationRepositoryImpl.java index 11af0c41..b60dd17d 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonListSortConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonListSortConfigurationRepositoryImpl.java @@ -5,17 +5,23 @@ import com.arextest.web.core.repository.mongo.util.MongoHelper; import com.arextest.web.model.contract.contracts.common.enums.CompareConfigType; import com.arextest.web.model.contract.contracts.config.replay.ComparisonListSortConfiguration; +import com.arextest.web.model.dao.mongodb.ConfigComparisonInclusionsCollection; import com.arextest.web.model.dao.mongodb.ConfigComparisonListSortCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails; +import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.mapper.ConfigComparisonListSortMapper; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.BulkOperations; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; @@ -183,4 +189,43 @@ public ComparisonListSortConfiguration queryById(String id) { ConfigComparisonListSortCollection.class); return ConfigComparisonListSortMapper.INSTANCE.dtoFromDao(dao); } + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ConfigComparisonListSortCollection.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonListSortCollection.class) + .stream() + .map(ConfigComparisonListSortMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } } \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonReferenceConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonReferenceConfigurationRepositoryImpl.java index 9df42b97..d53cbacd 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonReferenceConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonReferenceConfigurationRepositoryImpl.java @@ -7,15 +7,20 @@ import com.arextest.web.model.contract.contracts.config.replay.ComparisonReferenceConfiguration; import com.arextest.web.model.dao.mongodb.ConfigComparisonReferenceCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails; +import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.mapper.ConfigComparisonReferenceMapper; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.BulkOperations; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; @@ -188,4 +193,44 @@ public ComparisonReferenceConfiguration queryById(String id) { mongoTemplate.findOne(query, ConfigComparisonReferenceCollection.class); return ConfigComparisonReferenceMapper.INSTANCE.dtoFromDao(dao); } + + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ComparisonReferenceConfiguration.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonReferenceCollection.class) + .stream() + .map(ConfigComparisonReferenceMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } } \ No newline at end of file diff --git a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonTransformConfigurationRepositoryImpl.java b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonTransformConfigurationRepositoryImpl.java index a4d652e5..04c0f859 100644 --- a/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonTransformConfigurationRepositoryImpl.java +++ b/arex-web-core/src/main/java/com/arextest/web/core/repository/mongo/ComparisonTransformConfigurationRepositoryImpl.java @@ -8,16 +8,21 @@ import com.arextest.web.model.dao.mongodb.ConfigComparisonTransformCollection; import com.arextest.web.model.dao.mongodb.entity.AbstractComparisonDetails.Fields; import com.arextest.web.model.dao.mongodb.entity.TransformDetailDao; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import com.arextest.web.model.dto.config.PageQueryComparisonResultDto; import com.arextest.web.model.mapper.ConfigComparisonTransformMapper; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.BulkOperations; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.MongoTemplate; @@ -224,4 +229,49 @@ public List queryConfigOfCategory( return daos.stream().map(ConfigComparisonTransformMapper.INSTANCE::dtoFromDao) .collect(Collectors.toList()); } + + public PageQueryComparisonResultDto pageQueryComparisonConfig( + PageQueryComparisonDto pageQueryComparisonDto) { + PageQueryComparisonResultDto resultDto + = new PageQueryComparisonResultDto<>(); + + Query query = new Query(); + query.addCriteria(Criteria.where(Fields.appId).is(pageQueryComparisonDto.getAppId())); + query.addCriteria(Criteria.where(Fields.compareConfigType) + .is(CompareConfigType.REPLAY_MAIN.getCodeValue())); + query.addCriteria(Criteria.where( + MongoHelper.appendDot(ConfigComparisonTransformCollection.Fields.transformDetail, + TransformDetailDao.Fields.nodePath)) + .is(Collections.singletonList(ConfigComparisonTransformMapper.ROOT_NODE_PATH))); + List operationIds = pageQueryComparisonDto.getOperationIds(); + if (CollectionUtils.isNotEmpty(operationIds)) { + query.addCriteria(Criteria.where(Fields.operationId).in(operationIds)); + } + if (CollectionUtils.isNotEmpty(pageQueryComparisonDto.getDependencyIds())) { + query.addCriteria(Criteria.where(Fields.dependencyId) + .in(pageQueryComparisonDto.getDependencyIds())); + } + if (Objects.equals(pageQueryComparisonDto.getNeedTotal(), true)) { + resultDto.setTotalCount( + mongoTemplate.count(query, ConfigComparisonTransformCollection.class) + ); + } + Integer pageSize = pageQueryComparisonDto.getPageSize(); + Integer pageIndex = pageQueryComparisonDto.getPageIndex(); + query.skip((long) (pageIndex - 1) * pageSize).limit(pageSize); + + query.with( + Sort.by(Sort.Direction.ASC, Fields.operationId) + .and(Sort.by(Sort.Direction.ASC, Fields.dependencyId)) + ); + List configs = mongoTemplate.find(query, + ConfigComparisonTransformCollection.class) + .stream() + .map(ConfigComparisonTransformMapper.INSTANCE::dtoFromDao) + .collect(Collectors.toList()); + resultDto.setConfigs(configs); + return resultDto; + } + + } \ No newline at end of file diff --git a/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/ComparisonCategoryType.java b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/ComparisonCategoryType.java new file mode 100644 index 00000000..7fad6d1c --- /dev/null +++ b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/ComparisonCategoryType.java @@ -0,0 +1,15 @@ +//package com.arextest.web.model.contract.contracts.config.replay; +// +//public enum ComparisonCategoryType { +// +// EXCLUSION, +// INCLUSION, +// IGNORE_CATEGORY, +// LIST_SORT, +// REFERENCE, +// ROOT_TRANSFORM +// ; +// +// ComparisonCategoryType() { +// } +//} diff --git a/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonRequestType.java b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonRequestType.java new file mode 100644 index 00000000..a6f1c9e1 --- /dev/null +++ b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonRequestType.java @@ -0,0 +1,24 @@ +package com.arextest.web.model.contract.contracts.config.replay; + +import com.arextest.web.model.contract.PagingRequest; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import java.util.List; +import lombok.Data; + +@Data +public class PageQueryComparisonRequestType implements PagingRequest { + + @NotBlank + private String appId; + + private List operationId; + + private List dependencyIds; + + @NotNull + private Integer pageIndex; + @NotNull + private Integer pageSize; + private Boolean needTotal; +} diff --git a/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonResponseType.java b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonResponseType.java new file mode 100644 index 00000000..9fa8b835 --- /dev/null +++ b/arex-web-model-contract/src/main/java/com/arextest/web/model/contract/contracts/config/replay/PageQueryComparisonResponseType.java @@ -0,0 +1,83 @@ +package com.arextest.web.model.contract.contracts.config.replay; + +import com.arextest.web.model.contract.PagingResponse; +import com.arextest.web.model.contract.contracts.compare.CategoryDetail; +import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; +import lombok.Data; + +@Data +public class PageQueryComparisonResponseType implements PagingResponse { + + private Long totalCount; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List exclusions; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List inclusions; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List ignoreCategories; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List listSorts; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List referenceInfos; + + @JsonInclude(JsonInclude.Include.NON_NULL) + List rootTransformInfos; + + + @Data + public static class ExclusionInfo extends BaseConfigInfo { + + private List exclusionPath; + } + + @Data + public static class InclusionInfo extends BaseConfigInfo { + + private List inclusionPath; + } + + @Data + public static class IgnoreCategoryInfo extends BaseConfigInfo { + + private CategoryDetail ignoreCategoryDetail; + } + + @Data + public static class ListSortInfo extends BaseConfigInfo { + + private List listPath; + private List> keys; + } + + @Data + public static class ReferenceInfo extends BaseConfigInfo { + + private List pkPath; + private List fkPath; + } + + @Data + public static class RootTransformInfo extends BaseConfigInfo { + + private String transformMethodName; + } + + @Data + public static class BaseConfigInfo { + + private String id; + private String operationName; + private String dependencyName; + private String dependencyType; + private Long expirationDate; + private Integer expirationType; + } + + +} diff --git a/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonDto.java b/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonDto.java new file mode 100644 index 00000000..3e359077 --- /dev/null +++ b/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonDto.java @@ -0,0 +1,20 @@ +package com.arextest.web.model.dto.config; + +import jakarta.validation.constraints.NotBlank; +import java.util.List; +import lombok.Data; + +@Data +public class PageQueryComparisonDto { + + @NotBlank + private String appId; + + private List operationIds; + + private List dependencyIds; + + private Integer pageIndex; + private Integer pageSize; + private Boolean needTotal; +} diff --git a/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonResultDto.java b/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonResultDto.java new file mode 100644 index 00000000..7cd963de --- /dev/null +++ b/arex-web-model/src/main/java/com/arextest/web/model/dto/config/PageQueryComparisonResultDto.java @@ -0,0 +1,12 @@ +package com.arextest.web.model.dto.config; + +import java.util.List; +import lombok.Data; + +@Data +public class PageQueryComparisonResultDto { + + Long totalCount; + + List configs; +} diff --git a/arex-web-model/src/main/java/com/arextest/web/model/mapper/PageQueryComparisonMapper.java b/arex-web-model/src/main/java/com/arextest/web/model/mapper/PageQueryComparisonMapper.java new file mode 100644 index 00000000..193368fe --- /dev/null +++ b/arex-web-model/src/main/java/com/arextest/web/model/mapper/PageQueryComparisonMapper.java @@ -0,0 +1,136 @@ +package com.arextest.web.model.mapper; + +import com.arextest.config.model.dto.application.Dependency; +import com.arextest.web.model.contract.contracts.compare.TransformDetail; +import com.arextest.web.model.contract.contracts.config.replay.AbstractComparisonDetailsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonExclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonInclusionsConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonListSortConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonReferenceConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.ComparisonTransformConfiguration; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonRequestType; +import com.arextest.web.model.contract.contracts.config.replay.PageQueryComparisonResponseType; +import com.arextest.web.model.dto.config.PageQueryComparisonDto; +import java.util.Map; +import org.mapstruct.Context; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.Named; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface PageQueryComparisonMapper { + + + PageQueryComparisonMapper INSTANCE = Mappers.getMapper(PageQueryComparisonMapper.class); + + PageQueryComparisonDto dtoFromContract(PageQueryComparisonRequestType contract); + + @Mappings({ + @Mapping(target = "exclusionPath", source = "dto.exclusions"), + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.ExclusionInfo contractFromDto( + ComparisonExclusionsConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + @Mappings({ + @Mapping(target = "inclusionPath", source = "dto.inclusions"), + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.InclusionInfo contractFromDto( + ComparisonInclusionsConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + + @Mappings({ + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.IgnoreCategoryInfo contractFromDto( + ComparisonIgnoreCategoryConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + @Mappings({ + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.ListSortInfo contractFromDto( + ComparisonListSortConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + @Mappings({ + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.ReferenceInfo contractFromDto( + ComparisonReferenceConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + @Mappings({ + @Mapping(target = "transformMethodName", source = "dto.transformDetail", qualifiedByName = "toTransformMethodName"), + @Mapping(target = "operationName", source = "dto", qualifiedByName = "getOperationName"), + @Mapping(target = "dependencyName", source = "dto", qualifiedByName = "getDependencyName"), + @Mapping(target = "dependencyType", source = "dto", qualifiedByName = "getDependencyType"), + @Mapping(target = "expirationDate", expression = "java(dto.getExpirationDate() != null ? dto.getExpirationDate().getTime() : null)"), + }) + PageQueryComparisonResponseType.RootTransformInfo contractFromDto( + ComparisonTransformConfiguration dto, @Context Map operationInfo, + @Context Map dependencyInfo); + + + @Named("getOperationName") + default String getOperationName(T dto, + @Context Map operationInfo) { + return operationInfo.get(dto.getOperationId()); + } + + @Named("getDependencyName") + default String getDependencyName(T dto, + @Context Map dependencyInfo) { + String dependencyId = dto.getDependencyId(); + if (dependencyId == null) { + return null; + } + Dependency dependency = dependencyInfo.get(dependencyId); + if (dependency == null) { + return null; + } + return dependency.getOperationName(); + } + + @Named("getDependencyType") + default String getDependencyType(T dto, + @Context Map dependencyInfo) { + String dependencyId = dto.getDependencyId(); + if (dependencyId == null) { + return null; + } + Dependency dependency = dependencyInfo.get(dependencyId); + if (dependency == null) { + return null; + } + return dependency.getOperationType(); + } + + @Named("toTransformMethodName") + default String toTransformMethodName(TransformDetail transformDetail) { + return transformDetail.getTransformMethods().get(0).getMethodName(); + } + + +} diff --git a/pom.xml b/pom.xml index 7cf95cda..415ce880 100644 --- a/pom.xml +++ b/pom.xml @@ -493,7 +493,7 @@ 0.7.0.0 1.0.1 0.0.1 - 1.2.24 + 2.0.2-SNAPSHOT 1.1.27 0.0.1 2.9.3