package com.yd.csf.service.dto;

import com.yd.csf.service.model.*;
import com.yd.csf.service.vo.PolicyVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

import java.io.Serializable;
import java.util.List;

@Data
public class PolicyDto implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 产品计划(保单信息)
     */
    @Schema(description = "产品计划(保单信息)")
    private PolicyVO apiProductPlanMainInfoDto;

    /**
     * 保单附加险列表
     */
    @Schema(description = "保单附加险列表")
    private List<PolicyAdditional> apiProductPlanAdditionalInfoDtoList;

    public static PolicyDto convertToDto(Policy policy, List<PolicyAdditional> policyAdditionals) {
        PolicyDto dto = new PolicyDto();
        if (ObjectUtils.isEmpty(policy)) {
            return dto;
        }

        // 产品计划主信息
        dto.setApiProductPlanMainInfoDto(PolicyVO.objToVo(policy));

        // 附加险列表
        dto.setApiProductPlanAdditionalInfoDtoList(policyAdditionals);

        return dto;
    }
}
