package com.izouma.nineth.dto;

import com.izouma.nineth.converter.FileObjectListConverter;
import com.izouma.nineth.domain.Asset;
import com.izouma.nineth.domain.FileObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Convert;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class AssetDTO {

    @Convert(converter = FileObjectListConverter.class)
    private List<FileObject> pic;

    private String minter;

    private List<Asset> assets;

    private int num;

    private String prefixName;

    public static AssetDTO create(List<Asset> asset) {
        return AssetDTO.builder()
                .pic(asset.get(0).getPic())
                .minter(asset.get(0).getMinter())
                .assets(asset)
                .num(asset.size())
                .prefixName(asset.get(0).getPrefixName())
                .build();
    }
}
