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

import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 制品库-仓库对象 pms_product_library_repositories
 *
 * @author otto
 * @date 2024-06-20
 */
@Data
@ApiModel("产品库输入对象")
public class ProductRepositoriesInputVo extends ProductRepositoriesOperateVo {
    // 必填，以字母、数字开头，由字母、数字、下划线(_)、短横线(-)、点(.)组成；
    @ApiModelProperty(value = "产品版本标签", required = true)
    @NotBlank(message = "产品版本标签不能为空")
    @Pattern(regexp = "^[A-Za-z0-9][A-Za-z0-9_\\-.]*$", message = "产品版本标签不符合规范")
    private String tag;

    @ApiModelProperty(value = "产品库名称", required = true)
    @NotBlank(message = "产品库名称不能为空")
    private String alias;


    @ApiModelProperty(value = "关联产品标识", required = true)
    @NotBlank(message = "关联产品标识不能为空")
    private String productIdentifier;

    @ApiModelProperty(value = "产品版本号", required = true)
    @NotBlank(message = "产品版本号不能为空")
    private String version;

    @Override
    public NexusHostedRepoInputVo toNexusRepoDataVo() {
        NexusHostedRepoInputVo target = super.toNexusRepoDataVo();
        target.setName(PmsProductLibraryRepositories.getNexusProductRepositoriesName(super.getEnterpriseIdentifier(), this.name));
        return target;
    }

    @Override
    public PmsProductLibraryRepositories toPmsProductLibraryRepositories() {
        PmsProductLibraryRepositories target = super.toPmsProductLibraryRepositories();
        target.setTag(tag);
        target.setName(name);
        target.setAlias(alias);
        target.setProductIdentifier(productIdentifier);
        target.setVersion(version);
        return target;
    }
}
