package com.ga.api.service.upload;

import com.ga.common.excel.ExcelErrorRow;
import lombok.Builder;
import lombok.Data;

import java.util.List;

/**
 * 업로드 처리 결과 응답.
 */
@Data
@Builder
public class UploadResultResp {

    private Long historyId;
    private int totalCount;
    private int successCount;
    private int errorCount;
    private int skipCount;
    private Long errorFileId;
    private int durationSec;

    /** 에러 행 목록 (최대 maxErrorCount 까지) */
    private List<UploadErrorRow> errors;

    @Data
    @Builder
    public static class UploadErrorRow {
        private int rowNumber;
        private String fieldName;
        private String value;
        private String errorMessage;

        public static UploadErrorRow from(ExcelErrorRow e) {
            return UploadErrorRow.builder()
                    .rowNumber(e.getRowNumber())
                    .fieldName(e.getFieldName())
                    .value(e.getValue())
                    .errorMessage(e.getErrorMessage())
                    .build();
        }
    }
}
