fix(warehouse): keep partner query record bindable
This commit is contained in:
@@ -27,17 +27,11 @@ public final class MasterDataQueries {
|
|||||||
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE"})
|
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE"})
|
||||||
@Pattern(regexp = "^(CUSTOMER|SUPPLIER|BOTH|CARRIER|CUSTOMS_BROKER|SHIPPER|CONSIGNEE)$") String type,
|
@Pattern(regexp = "^(CUSTOMER|SUPPLIER|BOTH|CARRIER|CUSTOMS_BROKER|SHIPPER|CONSIGNEE)$") String type,
|
||||||
@Schema(description = "状态", allowableValues = {"ACTIVE", "INACTIVE"})
|
@Schema(description = "状态", allowableValues = {"ACTIVE", "INACTIVE"})
|
||||||
@Pattern(regexp = "^(ACTIVE|INACTIVE)$") String status
|
@Pattern(regexp = "^(ACTIVE|INACTIVE)$") String status,
|
||||||
,
|
|
||||||
@Schema(description = "往来单位类型集合(可重复传参)", allowableValues = {
|
@Schema(description = "往来单位类型集合(可重复传参)", allowableValues = {
|
||||||
"CUSTOMER", "SUPPLIER", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE"})
|
"CUSTOMER", "SUPPLIER", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE"})
|
||||||
@Size(max = 6) List<@Pattern(regexp = "^(CUSTOMER|SUPPLIER|CARRIER|CUSTOMS_BROKER|SHIPPER|CONSIGNEE)$") String> types
|
@Size(max = 6) List<@Pattern(regexp = "^(CUSTOMER|SUPPLIER|CARRIER|CUSTOMS_BROKER|SHIPPER|CONSIGNEE)$") String> types
|
||||||
) {
|
) {
|
||||||
/** 保持旧版五参数构造契约兼容。 */
|
|
||||||
public PartnerPageQuery(long page, long size, String keyword, String type, String status) {
|
|
||||||
this(page, size, keyword, type, status, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartnerPageQuery {
|
public PartnerPageQuery {
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|||||||
+2
-2
@@ -27,12 +27,12 @@ class PlatformMasterDataControllerContractTest {
|
|||||||
for (String type : java.util.List.of(
|
for (String type : java.util.List.of(
|
||||||
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE")) {
|
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE")) {
|
||||||
var query = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
|
var query = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
|
||||||
1, 20, null, type, null);
|
1, 20, null, type, null, null);
|
||||||
assertThat(validator.validate(query)).isEmpty();
|
assertThat(validator.validate(query)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
var invalid = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
|
var invalid = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
|
||||||
1, 20, null, "UNKNOWN", null);
|
1, 20, null, "UNKNOWN", null, null);
|
||||||
assertThat(validator.validate(invalid))
|
assertThat(validator.validate(invalid))
|
||||||
.extracting(violation -> violation.getPropertyPath().toString())
|
.extracting(violation -> violation.getPropertyPath().toString())
|
||||||
.containsExactly("type");
|
.containsExactly("type");
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class PartnerRepositoryTest {
|
|||||||
eq("ACTIVE"), eq("示例"))).thenAnswer(invocation -> invocation.getArgument(0));
|
eq("ACTIVE"), eq("示例"))).thenAnswer(invocation -> invocation.getArgument(0));
|
||||||
|
|
||||||
repository.page(10001L,
|
repository.page(10001L,
|
||||||
new PartnerPageQuery(1, 20, "示例", "CUSTOMER", "ACTIVE"));
|
new PartnerPageQuery(1, 20, "示例", "CUSTOMER", "ACTIVE", null));
|
||||||
|
|
||||||
verify(mapper).selectPartnerPageByType(any(Page.class), eq(10001L), eq("CUSTOMER"),
|
verify(mapper).selectPartnerPageByType(any(Page.class), eq(10001L), eq("CUSTOMER"),
|
||||||
eq("ACTIVE"), eq("示例"));
|
eq("ACTIVE"), eq("示例"));
|
||||||
@@ -77,7 +77,7 @@ class PartnerRepositoryTest {
|
|||||||
eq("ACTIVE"), isNull())).thenAnswer(invocation -> invocation.getArgument(0));
|
eq("ACTIVE"), isNull())).thenAnswer(invocation -> invocation.getArgument(0));
|
||||||
|
|
||||||
repository.page(null,
|
repository.page(null,
|
||||||
new PartnerPageQuery(1, 20, null, "CARRIER", "ACTIVE"));
|
new PartnerPageQuery(1, 20, null, "CARRIER", "ACTIVE", null));
|
||||||
|
|
||||||
verify(mapper).selectPartnerPageByType(any(Page.class), isNull(), eq("CARRIER"),
|
verify(mapper).selectPartnerPageByType(any(Page.class), isNull(), eq("CARRIER"),
|
||||||
eq("ACTIVE"), isNull());
|
eq("ACTIVE"), isNull());
|
||||||
@@ -102,7 +102,7 @@ class PartnerRepositoryTest {
|
|||||||
when(mapper.selectTypes(List.of(10001L, 10002L), List.of(7L, 7L)))
|
when(mapper.selectTypes(List.of(10001L, 10002L), List.of(7L, 7L)))
|
||||||
.thenReturn(List.of(typeA, typeB));
|
.thenReturn(List.of(typeA, typeB));
|
||||||
|
|
||||||
repository.page(null, new PartnerPageQuery(1, 20, null, null, null));
|
repository.page(null, new PartnerPageQuery(1, 20, null, null, null, null));
|
||||||
|
|
||||||
assertThat(customerA.getTypes()).containsExactly("CUSTOMER");
|
assertThat(customerA.getTypes()).containsExactly("CUSTOMER");
|
||||||
assertThat(customerB.getTypes()).containsExactly("SUPPLIER");
|
assertThat(customerB.getTypes()).containsExactly("SUPPLIER");
|
||||||
|
|||||||
Reference in New Issue
Block a user