package com.oqpo.api.web.dto.request.rtnmng;

import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
import com.oqpo.api.entity.rtnmng.RtnOdrDtlPtclEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class RtnReqOrdInitRequest {

    @ApiModelProperty(value = "CRUD")
    private String viewCd;

    @ApiModelProperty(value = "브랜드아이디")
    private String brandId;

    @ApiModelProperty(value = "반품요청상세항번 리스트")
    private List<RtnReqOrdInitRequest.RtnReqOrdTarget> gridUpdateData;


    public List<RtnOdrDtlPtclEntity> toCodeEntities(List< RtnReqOrdInitRequest.RtnReqOrdTarget > gridData) {
        List<RtnOdrDtlPtclEntity> entities = new ArrayList<>();
        if (gridData == null || gridData.size() == 0)
            return entities;

        gridData.forEach(x -> {
            RtnOdrDtlPtclEntity entity = new RtnOdrDtlPtclEntity();
            entity.setRtnReqUnqNo(x.getRtnReqUnqNo());
            entity.setRtnReqDtlNo(x.getRtnReqDtlNo());
            entities.add(entity);
        });
        return entities;
    }

    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class RtnReqOrdTarget {

        @ApiModelProperty(value = "반품요청번호")
        private String rtnReqUnqNo;

        @ApiModelProperty(value = "반품요청항번")
        private String rtnReqDtlNo;

    }
}
