package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.tunnelFacility;

import com.alibaba.fastjson2.JSONArray;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.HorizontalChannelDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelFacilityDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV1DO;
import com.cico.nest.lcdp.framework.common.util.object.BeanUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;

@Schema(description = "管理后台 - 隧道设施新增/修改 Request VO")
@Data
public class TunnelFacilitySaveReqVO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29458")
    private String id;

    @Schema(description = "设施名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @NotEmpty(message = "设施名称不能为空")
    private String facilityName;

    @Schema(description = "所属路段", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "所属路段不能为空")
    private String belongSections;

    @Schema(description = "管理中心", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "管理中心不能为空")
    private String managementCenter;

    @Schema(description = "隧道所", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "隧道所不能为空")
    private String tunnelDept;

    @Schema(description = "隧道类型 0双洞双向1单洞双向2单洞单向", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "隧道类型 0双洞双向1单洞双向2单洞单向不能为空")
    private Integer tunnelType;

    @Schema(description = "排序")
    private Integer sort;

    @Schema(description = "上行路")
    private TunnelHoleV1DO uplinkRoad;

    @Schema(description = "下行路")
    private TunnelHoleV1DO downlinkRoad;

    @Schema(description = "设施编码")
    private String facilityEncode;

    @Schema(description = "横通道")
    private List<HorizontalChannelDO> horizontalChannel;

    @Schema(description = "创建人")
    private String createBy;

    @Schema(description = "更新人")
    private String updateBy;


    public static TunnelFacilityDO convert2DO(TunnelFacilitySaveReqVO saveReqVO) {
        TunnelFacilityDO tunnelFacility = BeanUtils.toBean(saveReqVO, TunnelFacilityDO.class);
        tunnelFacility.setHorizontalChannel(JSONArray.from(saveReqVO.getHorizontalChannel()));
        return tunnelFacility;
    }



}
