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 GroupRepositoriesInputVo extends GroupRepositoriesOperateVo {
    @ApiModelProperty(value = "虚拟仓库标识")
    @NotBlank(message = "虚拟仓库标识不能为空")
    @Pattern(regexp = "^[A-Za-z0-9](?!_)(?!\\.)[A-Za-z0-9_\\-.]*$", message = "虚拟仓库标识不符合规范")
    private String name;

    @ApiModelProperty(value = "虚拟仓库名称")
    @NotBlank(message = "虚拟仓库名称不能为空")
    private String alias;

    @Override
    public NexusGroupRepoInputVo toNexusGroupRepoInputVo() {
        NexusGroupRepoInputVo target = super.toNexusGroupRepoInputVo();
        target.setName(PmsProductLibraryRepositories.getNexusRepositoriesName(super.getEnterpriseIdentifier(), this.name));
        return target;
    }

    @Override
    public PmsProductLibraryRepositories toPmsProductLibraryRepositories() {
        PmsProductLibraryRepositories target = super.toPmsProductLibraryRepositories();
        target.setName(name);
        target.setAlias(alias);
        return target;
    }
}
