fix(warehouse): 支持全部往来单位类型筛选

This commit is contained in:
2026-08-03 15:29:17 +08:00
parent fe5e3de9b1
commit 8f5201112d
2 changed files with 23 additions and 2 deletions
@@ -23,8 +23,9 @@ public final class MasterDataQueries {
@Min(1) @Max(200) long size,
@Schema(description = "编码、名称、联系人或联系电话关键字", example = "示例客户")
@Size(max = 128) String keyword,
@Schema(description = "往来单位类型", allowableValues = {"CUSTOMER", "SUPPLIER", "BOTH"})
@Pattern(regexp = "^(CUSTOMER|SUPPLIER|BOTH)$") String type,
@Schema(description = "往来单位类型", allowableValues = {
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE"})
@Pattern(regexp = "^(CUSTOMER|SUPPLIER|BOTH|CARRIER|CUSTOMS_BROKER|SHIPPER|CONSIGNEE)$") String type,
@Schema(description = "状态", allowableValues = {"ACTIVE", "INACTIVE"})
@Pattern(regexp = "^(ACTIVE|INACTIVE)$") String status
) {
@@ -2,6 +2,7 @@ package com.baiyue.warehouse.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validation;
import org.junit.jupiter.api.Test;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
@@ -15,6 +16,25 @@ import java.lang.reflect.Method;
import static org.assertj.core.api.Assertions.assertThat;
class PlatformMasterDataControllerContractTest {
@Test
void 往来单位分页支持全部业务类型并拒绝未知类型() {
try (var factory = Validation.buildDefaultValidatorFactory()) {
var validator = factory.getValidator();
for (String type : java.util.List.of(
"CUSTOMER", "SUPPLIER", "BOTH", "CARRIER", "CUSTOMS_BROKER", "SHIPPER", "CONSIGNEE")) {
var query = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
1, 20, null, type, null);
assertThat(validator.validate(query)).isEmpty();
}
var invalid = new com.baiyue.warehouse.dto.MasterDataQueries.PartnerPageQuery(
1, 20, null, "UNKNOWN", null);
assertThat(validator.validate(invalid))
.extracting(violation -> violation.getPropertyPath().toString())
.containsExactly("type");
}
}
@Test
void 仓库平台接口按读取新增编辑和启停权限隔离() {
RequestMapping mapping = PlatformWarehouseController.class.getAnnotation(RequestMapping.class);