
package cn.orionsec.ops.entity.importer;

import cn.orionsec.kit.lang.utils.convert.TypeStore;
import cn.orionsec.kit.office.excel.annotation.ImportField;
import cn.orionsec.ops.entity.domain.ApplicationInfoDO;
import cn.orionsec.ops.entity.vo.data.DataImportCheckRowVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "应用信息导入")
public class ApplicationImportDTO extends BaseDataImportDTO {

    @ApiModelProperty(value = "应用名称")
    @ImportField(index = 0)
    private String name;

    @ApiModelProperty(value = "唯一标识")
    @ImportField(index = 1)
    private String tag;

    @ApiModelProperty(value = "应用仓库名称")
    @ImportField(index = 2)
    private String repositoryName;

    @ApiModelProperty(value = "描述")
    @ImportField(index = 3)
    private String description;

    @ApiModelProperty(value = "仓库id", hidden = true)
    private Long repositoryId;

    static {
        TypeStore.STORE.register(ApplicationImportDTO.class, DataImportCheckRowVO.class, p -> {
            DataImportCheckRowVO vo = new DataImportCheckRowVO();
            vo.setSymbol(p.tag);
            vo.setIllegalMessage(p.getIllegalMessage());
            vo.setId(p.getId());
            return vo;
        });
        TypeStore.STORE.register(ApplicationImportDTO.class, ApplicationInfoDO.class, p -> {
            ApplicationInfoDO d = new ApplicationInfoDO();
            d.setId(p.getId());
            d.setAppName(p.name);
            d.setAppTag(p.tag);
            d.setRepoId(p.repositoryId);
            d.setDescription(p.description);
            return d;
        });
    }

}
