package cn.iocoder.foodnexus.module.erp.controller.admin.purchase.vo.supplier;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : yanghao
 * create at:  2026/1/5  15:12
 * @description:
 */
@Data
@Schema(description = "供应商后台发货")
public class SupplierPurchaseOrderDeliveryReqVO {

    @Schema(description = "ids", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "ids不能为空")
    private List<Item> ids;

    @Data
    public static class Item {
        @Schema(description = "id" , requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "id不能为空")
        private Long id;

        @Valid
        private List<ProductFile> productFiles;
    }

    @Data
    public static class ProductFile {

        @Schema(description = "商品id")
        @NotNull(message = "商品id不能为空")
        private Long productId;

        @Schema(description = "附件")
        private String annex;
    }

    public static SupplierPurchaseOrderDeliveryReqVO transform(List<Long> ids) {
        SupplierPurchaseOrderDeliveryReqVO data = new SupplierPurchaseOrderDeliveryReqVO();
        List<Item> items = new ArrayList<>(ids.size());
        for (Long id : ids) {
            Item item = new Item();
            item.setId(id);
            items.add(item);
        }
        data.setIds(items);
        return data;
    }

}
