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

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

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class SaveRtnSteamlineOdrRequest {
    @NotBlank
    @ApiModelProperty(value = "CRUD")
    private String viewCd;

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

    @ApiModelProperty(value = "등록 반품요청번호 리스트")
    private List<SaveRtnSteamlineOdrItemList> gridInsertData;


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

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

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

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