package com.microservices.pms.productLibrary.domain.vo;

import com.microservices.common.core.utils.bean.BeanUtils;
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 制品Raw输入对象
 *
 * @author otto
 * @date 2024-07-04
 */
@Data
@ApiModel("产品制品输入对象")
public class ProductComponentInputVo {
    @ApiModelProperty(value = "产品库标识", hidden = true)
    private String productRepoName;
    @ApiModelProperty(value = "组织标识", hidden = true)
    private String enterpriseIdentifier;
    @ApiModelProperty(value = "制品格式", hidden = true)
    private String format = ProductLibraryRepositoriesFormatEnum.PRODUCT.getKey();
    @ApiModelProperty(value = "制品版本")
    @NotBlank(message = "制品版本不能为空")
    private String version;
    @ApiModelProperty(value = "文档列表")
    @Size(min = 1, message = "最少上传一个文档")
    @Valid
    private List<Long> docList;
    @ApiModelProperty(value = "目录：上传文件的目录（例如/path/to/files/）")
    @NotNull(message = "目录不能为空")
    private String directory;

    public ComponentRawInputVo toComponentRawInputVo(List<AssetRawInputVo> assetList) {
        ComponentRawInputVo target = new ComponentRawInputVo();
        BeanUtils.copyProperties(this, target);
        target.setRepoName(productRepoName);
        target.setAssetList(assetList);
        return target;
    }

}
