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

import com.microservices.common.core.utils.StringUtils;
import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
import com.microservices.system.api.domain.SysFileBytes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 制品输入对象
 *
 * @author otto
 * @date 2024-06-28
 */
@Data
@ApiModel("制品通用输入对象")
public class ComponentInputVo {
    @ApiModelProperty(value = "制品库标识", hidden = true)
    private String repoName;
    @ApiModelProperty(value = "快照库标识", hidden = true)
    private String snapshotName;
    @ApiModelProperty(value = "组织标识", hidden = true)
    private String enterpriseIdentifier;
    @ApiModelProperty(value = "制品文件标识")
    @NotNull
    private String fileIdentifier;
    @ApiModelProperty(value = "文件流", hidden = true)
    private SysFileBytes fileBytes;

    public String getNexusRepoName() {
        if (StringUtils.isEmpty(snapshotName)) {
            return PmsProductLibraryRepositories.getNexusRepositoriesName(
                    enterpriseIdentifier,
                    repoName
            );
        } else {
            return PmsProductLibraryRepositories.getNexusSnapshotRepositoriesName(
                    enterpriseIdentifier,
                    repoName,
                    snapshotName
            );
        }

    }
}
