diff --git a/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java b/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java index 4bc1efeea..56523d82d 100644 --- a/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java +++ b/firstleg/src/main/java/com/baiyue/firstleg/dto/SmartLoadingDtos.java @@ -1,5 +1,5 @@ package com.baiyue.firstleg.dto; -import com.baiyue.firstleg.entity.LoadingPlanItemEntity; import jakarta.validation.constraints.*; import org.apache.ibatis.annotations.AutomapConstructor; import java.math.BigDecimal; import java.util.List; +import com.baiyue.firstleg.entity.LoadingPlanItemEntity; import jakarta.validation.constraints.*; import java.math.BigDecimal; import java.util.List; public final class SmartLoadingDtos { private SmartLoadingDtos(){} public record InboundCandidate(Long accountId, Long inboundId, Long orderId, String orderNo, String inboundCode, Long warehouseId, String channelCode, String channelName, Long destinationWarehouseId, @@ -8,21 +8,7 @@ public final class SmartLoadingDtos { private SmartLoadingDtos(){} BigDecimal averageUnitVolumeCbm, BigDecimal availableVolumeCbm) {} public record Candidate(Long accountId, Long inboundId, Long inboundDetailId, Long orderId, String orderNo, String inboundCode, Long warehouseId, String channelCode, String channelName, Long destinationWarehouseId, String destinationWarehouseCode, String destinationWarehouseName, String customerName, String goodsName, Integer availablePackageCount, - BigDecimal unitGrossWeightKg, BigDecimal unitNetWeightKg, BigDecimal unitVolumeCbm) { - @AutomapConstructor - public Candidate { } - public Candidate(Long accountId, Long inboundId, Long inboundDetailId, Long orderId, String orderNo, String inboundCode, - Long warehouseId, String destinationWarehouseCode, String customerName, String goodsName, Integer availablePackageCount, - BigDecimal unitGrossWeightKg, BigDecimal unitNetWeightKg, BigDecimal unitVolumeCbm) { - this(accountId,inboundId,inboundDetailId,orderId,orderNo,inboundCode,warehouseId,null,null,null,destinationWarehouseCode,null,customerName,goodsName,availablePackageCount,unitGrossWeightKg,unitNetWeightKg,unitVolumeCbm); - } - public Candidate(Long accountId, Long inboundId, Long inboundDetailId, Long orderId, String orderNo, String inboundCode, - Long warehouseId, Long destinationWarehouseId, String destinationWarehouseCode, String destinationWarehouseName, - String customerName, String goodsName, Integer availablePackageCount, BigDecimal unitGrossWeightKg, BigDecimal unitNetWeightKg, BigDecimal unitVolumeCbm) { - this(accountId,inboundId,inboundDetailId,orderId,orderNo,inboundCode,warehouseId,null,null,destinationWarehouseId, - destinationWarehouseCode,destinationWarehouseName,customerName,goodsName,availablePackageCount,unitGrossWeightKg,unitNetWeightKg,unitVolumeCbm); - } - } + BigDecimal unitGrossWeightKg, BigDecimal unitNetWeightKg, BigDecimal unitVolumeCbm) {} public record CreateRequest(@NotNull @Positive Long bookingId, @Size(max=500) String remark) {} public record AssignRequest(@NotNull @Positive Long inboundId,@NotNull @Positive Long inboundDetailId, @NotNull @Positive Integer packageCount,@NotNull @Min(0) Integer expectedVersion,@NotBlank @Size(max=128) String operationId) {} diff --git a/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingCandidateMapperContractTest.java b/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingCandidateMapperContractTest.java index 114087cce..813159fb4 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingCandidateMapperContractTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingCandidateMapperContractTest.java @@ -2,7 +2,6 @@ package com.baiyue.firstleg.repository; import com.baiyue.firstleg.mapper.SmartLoadingCandidateMapper; import com.baiyue.firstleg.dto.SmartLoadingDtos.Candidate; -import org.apache.ibatis.annotations.AutomapConstructor; import org.apache.ibatis.annotations.Select; import org.junit.jupiter.api.Test; @@ -12,15 +11,9 @@ import static org.assertj.core.api.Assertions.assertThat; class SmartLoadingCandidateMapperContractTest { @Test - void canonicalCandidateConstructorIsTheUniqueMybatisAutomapTarget() { - long annotated = java.util.Arrays.stream(Candidate.class.getDeclaredConstructors()) - .filter(constructor -> constructor.isAnnotationPresent(AutomapConstructor.class)) - .count(); - - assertThat(annotated).isEqualTo(1); - assertThat(java.util.Arrays.stream(Candidate.class.getDeclaredConstructors()) - .filter(constructor -> constructor.isAnnotationPresent(AutomapConstructor.class)) - .findFirst().orElseThrow().getParameterCount()).isEqualTo(18); + void candidateHasOnlyTheCanonicalMybatisConstructor() { + assertThat(Candidate.class.getDeclaredConstructors()).singleElement() + .satisfies(constructor -> assertThat(constructor.getParameterCount()).isEqualTo(18)); } @Test