This commit is contained in:
wujinliang
2026-08-26 18:12:55 +08:00
parent f2877df697
commit d736fdba1b
7 changed files with 63 additions and 18 deletions
@@ -29,16 +29,16 @@ public final class WarehouseRequests {
@NotBlank @Size(max = 50) String warehouseCode,
@Schema(description = "Warehouse name / 仓库名称", example = "Los Angeles Main Warehouse / 洛杉矶主仓", maxLength = 120, requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank @Size(max = 120) String warehouseName,
@Schema(description = "Warehouse type; defaults to DOMESTIC / 仓库类型,默认 DOMESTIC", example = "FBA", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS"}, defaultValue = "DOMESTIC")
@Pattern(regexp = "DOMESTIC|FBA|OVERSEAS") String warehouseType,
@Schema(description = "Warehouse type; defaults to DOMESTIC / 仓库类型,默认 DOMESTIC", example = "FBA", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS", "OVERSEAS_PARTNER"}, defaultValue = "DOMESTIC")
@Pattern(regexp = "DOMESTIC|FBA|OVERSEAS|OVERSEAS_PARTNER") String warehouseType,
@Schema(description = "ISO 3166-1 alpha-2 country code; DOMESTIC defaults to CN / ISO 两位国家代码,DOMESTIC 默认 CN", example = "US", pattern = "[A-Z]{2}")
@Pattern(regexp = "[A-Z]{2}") String countryCode,
@Schema(description = "UTC offset; DOMESTIC defaults to UTC+8 / UTC 偏移量,DOMESTIC 默认 UTC+8", example = "UTC-8")
String timezone,
@Schema(description = "Contact name / 联系人姓名", example = "Alex Chen", maxLength = 64)
@Size(max = 64) String contactName,
@Schema(description = "Contact phone / 联系电话", example = "+1-213-555-0100", maxLength = 32)
@Size(max = 32) String contactPhone,
@Schema(description = "Contact phone; digits only / 联系电话,仅允许数字", example = "12135550100", maxLength = 32)
@Pattern(regexp = "\\d*") @Size(max = 32) String contactPhone,
@Schema(description = "Contact email / 联系邮箱", example = "warehouse@example.com")
@Email String contactEmail,
@Schema(description = "Warehouse status; defaults to ACTIVE / 仓库状态,默认 ACTIVE", example = "ACTIVE", allowableValues = {"ACTIVE", "INACTIVE"}, defaultValue = "ACTIVE")
@@ -104,8 +104,8 @@ public final class WarehouseRequests {
String countryCode,
@Schema(description = "Enabled capability code filter / 已启用能力编码筛选", example = "STORAGE")
String capabilityCode,
@Schema(description = "Warehouse type filter / 仓库类型筛选", example = "DOMESTIC", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS"})
@Pattern(regexp = "DOMESTIC|FBA|OVERSEAS") String warehouseType,
@Schema(description = "Warehouse type filter / 仓库类型筛选", example = "DOMESTIC", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS", "OVERSEAS_PARTNER"})
@Pattern(regexp = "DOMESTIC|FBA|OVERSEAS|OVERSEAS_PARTNER") String warehouseType,
@Schema(description = "Status filter / 状态筛选", example = "ACTIVE", allowableValues = {"ACTIVE", "INACTIVE"})
@Pattern(regexp = "ACTIVE|INACTIVE") String status
) {
@@ -13,7 +13,7 @@ public record WarehouseSummaryResponse(
@Schema(description = "Platform public scope ID, fixed to 0 / 平台公共作用域,固定为 0") Long tenantId,
@Schema(description = "Warehouse code / 仓库编码") String warehouseCode,
@Schema(description = "Warehouse name / 仓库名称") String warehouseName,
@Schema(description = "Warehouse type / 仓库类型", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS"}) String warehouseType,
@Schema(description = "Warehouse type / 仓库类型", allowableValues = {"DOMESTIC", "FBA", "OVERSEAS", "OVERSEAS_PARTNER"}) String warehouseType,
@Schema(description = "ISO two-letter country code / 国家二字码") String countryCode,
@Schema(description = "UTC offset / UTC 偏移量") String timezone,
@Schema(description = "Contact name / 联系人") String contactName,
@@ -202,7 +202,7 @@ public class WarehouseImportService {
} else {
optionalLength(row, errors, "仓库名称", row.name(), 120);
}
if (!row.type().isBlank() && !row.type().matches("(?i)DOMESTIC|FBA|OVERSEAS")) {
if (!row.type().isBlank() && !row.type().matches("(?i)DOMESTIC|FBA|OVERSEAS|OVERSEAS_PARTNER")) {
errors.add(new WarehouseImportError(row.row(), "仓库类型", "只能填写 DOMESTIC、FBA 或 OVERSEAS"));
}
if (!row.countryCode().isBlank() && !row.countryCode().matches("(?i)[A-Z]{2}")) {
@@ -15,6 +15,8 @@ final class WarehouseSaveNormalizer {
static final long PUBLIC_TENANT_ID = 0L;
static final String TYPE_DOMESTIC = "DOMESTIC";
static final String TYPE_FBA = "FBA";
static final String TYPE_OVERSEAS = "OVERSEAS";
static final String TYPE_OVERSEAS_PARTNER = "OVERSEAS_PARTNER";
static final String STATUS_ACTIVE = "ACTIVE";
static final String DEFAULT_ADDRESS_TYPE = "WAREHOUSE";
static final String DEFAULT_DOMESTIC_COUNTRY = "CN";
@@ -68,8 +70,8 @@ final class WarehouseSaveNormalizer {
static NormalizedSaveRequest normalize(WarehouseRequests.SaveRequest request, long tenantId) {
String warehouseType = upperOrDefault(request.warehouseType(), TYPE_DOMESTIC);
if (!TYPE_DOMESTIC.equals(warehouseType) && !TYPE_FBA.equals(warehouseType) && !"OVERSEAS".equals(warehouseType)) {
throw new BizException(ResultCode.VALIDATION_FAILED, "Warehouse type must be DOMESTIC, FBA or OVERSEAS / 仓库类型只能为 DOMESTIC、FBA 或 OVERSEAS");
if (!Set.of(TYPE_DOMESTIC, TYPE_FBA, TYPE_OVERSEAS, TYPE_OVERSEAS_PARTNER).contains(warehouseType)) {
throw new BizException(ResultCode.VALIDATION_FAILED, "Warehouse type must be DOMESTIC, FBA, OVERSEAS or OVERSEAS_PARTNER / 仓库类型只能为 DOMESTIC、FBA、OVERSEAS 或 OVERSEAS_PARTNER");
}
String status = upperOrDefault(request.status(), STATUS_ACTIVE);
if (!STATUS_ACTIVE.equals(status) && !"INACTIVE".equals(status)) {
@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS wh_warehouse (
tenant_id BIGINT UNSIGNED NOT NULL COMMENT '平台公共仓库固定使用 tenant_id=0',
warehouse_code VARCHAR(50) NOT NULL COMMENT '平台内唯一仓库编码',
warehouse_name VARCHAR(120) NOT NULL COMMENT '仓库名称',
warehouse_type VARCHAR(32) NOT NULL DEFAULT 'DOMESTIC' COMMENT '公共仓库类型:DOMESTIC、FBA、OVERSEAS',
warehouse_type VARCHAR(32) NOT NULL DEFAULT 'DOMESTIC' COMMENT '公共仓库类型:DOMESTIC、FBA、OVERSEAS、OVERSEAS_PARTNER',
country_code CHAR(2) NOT NULL COMMENT '所在国家二字码',
timezone VARCHAR(64) NOT NULL COMMENT '仓库所在地UTC偏移量',
contact_name VARCHAR(64) DEFAULT NULL COMMENT '仓库联系人',