package com.erp.product.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 更新商品请求DTO
 */
@Data
public class UpdateGoodsRequest {
    
    @NotBlank(message = "商品名称不能为空")
    @Size(max = 255, message = "商品名称不能超过255个字符")
    private String name;
    
    @Size(max = 100, message = "商品编码不能超过100个字符")
    private String code;
    
    @Size(max = 100, message = "条形码不能超过100个字符")
    private String barcode;
    
    @Pattern(regexp = "^(normal|combo)$", message = "商品类型只能是normal或combo")
    private String type;
    
    @Size(max = 20, message = "商品单位不能超过20个字符")
    private String unit;
    
    @DecimalMin(value = "0", message = "零售价格不能小于0")
    private BigDecimal retailPrice;
    
    @DecimalMin(value = "0", message = "成本价格不能小于0")
    private BigDecimal costPrice;
    
    @DecimalMin(value = "0", message = "重量不能小于0")
    private BigDecimal weight;
    
    @DecimalMin(value = "0", message = "包装成本不能小于0")
    private BigDecimal packagingCost;
    
    @DecimalMin(value = "0", message = "配送包装成本不能小于0")
    private BigDecimal shippingPackagingCost;
    
    @DecimalMin(value = "0", message = "体积不能小于0")
    private BigDecimal volume;
    
    @DecimalMin(value = "0", message = "长度不能小于0")
    private BigDecimal length;
    
    @DecimalMin(value = "0", message = "宽度不能小于0")
    private BigDecimal width;
    
    @DecimalMin(value = "0", message = "高度不能小于0")
    private BigDecimal height;
    
    private Long brandId;
    
    private List<Long> supplierIds;
    
    private Boolean batchManagement;
    
    @Size(max = 100, message = "自定义ID不能超过100个字符")
    private String customId;
    
    @Size(max = 50, message = "分类不能超过50个字符")
    private String category;
    
    @Min(value = 0, message = "库存预警值不能小于0")
    private Integer stockWarning;
    
    /**
     * 组套商品子项（仅combo类型需要）
     */
    @Valid
    private List<ComboItemRequest> comboItems;
    
    /**
     * 组套子项请求
     */
    @Data
    public static class ComboItemRequest {
        @NotNull(message = "子商品ID不能为空")
        private Long goodsId;
        
        @NotNull(message = "子商品数量不能为空")
        @Min(value = 1, message = "子商品数量至少为1")
        private Integer quantity;
    }
}
