package com.its.pis.entity;

import com.its.pis.websocket.message.c2f.PrkPlceRlTimeResponseInfo;
import lombok.*;

import java.io.Serializable;

/**
 * 주차장 실시간 정보 Entity Class
 */
@Getter
@Setter
@ToString
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
public class TbPrkPlceRt implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long    prkPlceNmbr;
    private String  dataColctTime;
    private Integer parkingCgsSttus;
    private Integer prkCmprtCo;
    private Integer remndrPrkCmprtCo;
    private Integer prkResveAvailCmprtCo;
    private String  partclrMatter;

    public static TbPrkPlceRt toEntity(String PIS_NMBR, String DATA_COLCT_TIME, PrkPlceRlTimeResponseInfo info) {
        TbPrkPlceRt entity = TbPrkPlceRt.builder()
                .prkPlceNmbr(Long.valueOf(PIS_NMBR))
                .dataColctTime(DATA_COLCT_TIME)
                .parkingCgsSttus(info.getParking_cgs_sttus())
                .prkCmprtCo(info.getPrk_cmprt_co())
                .remndrPrkCmprtCo(info.getRemndr_prk_cmprt_co())
                .prkResveAvailCmprtCo(info.getPrk_resve_avail_cmprt_co())
                .partclrMatter(info.getPartclr_matter())
                .build();
        if (entity.getPrkResveAvailCmprtCo() == null) {
            entity.setPrkResveAvailCmprtCo(0);
        }
        return entity;
    }
}
