118 lines
6.9 KiB
Java
118 lines
6.9 KiB
Java
package com.baiyue.warehouse.dto;
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.constraints.Email;
|
|
import jakarta.validation.constraints.Max;
|
|
import jakarta.validation.constraints.Min;
|
|
import jakarta.validation.constraints.NotBlank;
|
|
import jakarta.validation.constraints.NotNull;
|
|
import jakarta.validation.constraints.Pattern;
|
|
import jakarta.validation.constraints.Size;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.time.LocalTime;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 仓库接口请求模型容器,集中定义仓库保存、地址、服务能力、查询和状态变更请求契约。
|
|
*/
|
|
public final class WarehouseRequests {
|
|
private WarehouseRequests() {
|
|
}
|
|
|
|
@Schema(name = "WarehouseSaveRequest", description = "Warehouse create or update request / 仓库新增或更新请求")
|
|
public record SaveRequest(
|
|
@Schema(description = "Target tenant ID / 目标租户 ID", example = "10001", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotNull Long customerId,
|
|
@Schema(description = "Tenant-unique warehouse code / 租户内唯一仓库编码", example = "US-LAX-01", maxLength = 50, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@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 / 仓库类型", example = "OVERSEAS", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank String warehouseType,
|
|
@Schema(description = "ISO 3166-1 alpha-2 country code / ISO 两位国家代码", example = "US", pattern = "[A-Z]{2}", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Pattern(regexp = "[A-Z]{2}") String countryCode,
|
|
@Schema(description = "IANA timezone / IANA 时区", example = "America/Los_Angeles", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank 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 email / 联系邮箱", example = "warehouse@example.com")
|
|
@Email String contactEmail,
|
|
@Schema(description = "Warehouse status / 仓库状态", example = "ACTIVE", allowableValues = {"ACTIVE", "INACTIVE"}, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank String status,
|
|
@Schema(description = "Remark / 备注", example = "Supports appointment receiving / 支持预约入库", maxLength = 500)
|
|
@Size(max = 500) String remark,
|
|
@Schema(description = "Primary warehouse address / 仓库主地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@Valid @NotNull AddressRequest address,
|
|
@Schema(description = "Supported service capabilities / 支持的服务能力")
|
|
@Valid List<CapabilityRequest> capabilities
|
|
) {
|
|
}
|
|
|
|
@Schema(name = "WarehouseAddressRequest", description = "Warehouse address / 仓库地址")
|
|
public record AddressRequest(
|
|
@Schema(description = "Address type / 地址类型", example = "WAREHOUSE", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank String addressType,
|
|
@Schema(description = "ISO two-letter country code / ISO 两位国家代码", example = "US", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Pattern(regexp = "[A-Z]{2}") String countryCode,
|
|
@Schema(description = "State or province / 州或省", example = "California", maxLength = 100)
|
|
@Size(max = 100) String stateProvince,
|
|
@Schema(description = "City / 城市", example = "Los Angeles", maxLength = 100, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Size(max = 100) String city,
|
|
@Schema(description = "District / 区县", example = "Commerce", maxLength = 100)
|
|
@Size(max = 100) String district,
|
|
@Schema(description = "Postal code / 邮政编码", example = "90040", maxLength = 20)
|
|
@Size(max = 20) String postalCode,
|
|
@Schema(description = "Address line 1 / 地址第一行", example = "123 Logistics Ave", maxLength = 255, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Size(max = 255) String addressLine1,
|
|
@Schema(description = "Address line 2 / 地址第二行", example = "Building A", maxLength = 255)
|
|
@Size(max = 255) String addressLine2,
|
|
@Schema(description = "Latitude / 纬度", example = "34.052235")
|
|
BigDecimal latitude,
|
|
@Schema(description = "Longitude / 经度", example = "-118.243683")
|
|
BigDecimal longitude
|
|
) {
|
|
}
|
|
|
|
@Schema(name = "WarehouseCapabilityRequest", description = "Warehouse service capability / 仓库服务能力")
|
|
public record CapabilityRequest(
|
|
@Schema(description = "Capability code / 能力编码", example = "STORAGE", maxLength = 50, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Size(max = 50) String capabilityCode,
|
|
@Schema(description = "Capability name / 能力名称", example = "Storage / 仓储", maxLength = 100, requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@NotBlank @Size(max = 100) String capabilityName,
|
|
@Schema(description = "Whether enabled / 是否启用", example = "true", defaultValue = "true")
|
|
Boolean enabled,
|
|
@Schema(description = "Daily cutoff time / 每日截单时间", example = "16:00:00", type = "string", format = "time")
|
|
LocalTime cutoffTime,
|
|
@Schema(description = "Capability description / 能力说明", example = "Standard pallet storage / 标准托盘仓储", maxLength = 500)
|
|
@Size(max = 500) String description
|
|
) {
|
|
}
|
|
|
|
@Schema(name = "WarehouseQueryRequest", description = "Warehouse page query / 仓库分页查询条件")
|
|
public record QueryRequest(
|
|
@Schema(description = "Page number, starting at 1 / 页码,从 1 开始", example = "1", defaultValue = "1", minimum = "1")
|
|
@Min(1) long page,
|
|
@Schema(description = "Page size / 每页条数", example = "20", defaultValue = "20", minimum = "1", maximum = "200")
|
|
@Min(1) @Max(200) long size,
|
|
@Schema(description = "Country filter / 国家筛选", example = "US")
|
|
String countryCode,
|
|
@Schema(description = "Enabled capability code filter / 已启用能力编码筛选", example = "STORAGE")
|
|
String capabilityCode,
|
|
@Schema(description = "Status filter / 状态筛选", example = "ACTIVE", allowableValues = {"ACTIVE", "INACTIVE"})
|
|
String status
|
|
) {
|
|
public QueryRequest {
|
|
if (page == 0) {
|
|
page = 1;
|
|
}
|
|
if (size == 0) {
|
|
size = 20;
|
|
}
|
|
}
|
|
}
|
|
}
|