package com.its.op.entity.its.rse;

import com.its.op.dto.its.rse.TbRseOffrSectTrafHsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

/**
 * RSE 제공구간 정보제공 이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("RSE 제공구간 정보제공 이력")
@Entity
@Table(name = "TB_RSE_OFFR_SECT_TRAF_HS")
@IdClass(TbRseOffrSectTrafHsKey.class)
public class TbRseOffrSectTrafHs implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("제공 구간 아이디")  // N NUMBER(10)
    @Id
    @Column(name = "OFFR_SECT_ID", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long offrSectId;

    @ApiModelProperty("제공 일시")  // N VARCHAR2(14)
    @Id
    @Column(name = "PRCN_DT", nullable = false, length = 14)
    private String prcnDt;

    @ApiModelProperty("제공 내용")  // Y VARCHAR2(100)
    @Column(name = "OFFR_CONT", length = 100)
    private String offrCont;

    public TbRseOffrSectTrafHsDto toDto() {
        return TbRseOffrSectTrafHsDto.builder()
                .offrSectId(this.offrSectId)
                .prcnDt(this.prcnDt)
                .offrCont(this.offrCont)
                .build();
    }

    public TbRseOffrSectTrafHs(Long offrSectId, String prcnDt) {
        this.offrSectId = offrSectId;
        this.prcnDt = prcnDt;
    }

    public void updateInfo(TbRseOffrSectTrafHsDto.TbRseOffrSectTrafHsUpdReq req) {
        this.offrCont = req.getOffrCont();
    }

}
