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

import com.its.op.dto.its.rse.TbRseObuClctStatDdDto;
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 OBU 수집 일 통계 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("RSE OBU 수집 일 통계")
@Entity
@Table(name = "TB_RSE_OBU_CLCT_STAT_DD")
@IdClass(TbRseObuClctStatDdKey.class)
public class TbRseObuClctStatDd implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("통계 일시")  // N VARCHAR2(14)
    @Id
    @Column(name = "STAT_DT", nullable = false, length = 14)
    private String statDt;

    @ApiModelProperty("RSE 제어기 번호")  // N NUMBER(10)
    @Id
    @Column(name = "RSE_CTLR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long rseCtlrNmbr;

    @ApiModelProperty("요일 유형 코드")  // Y VARCHAR2(7)
    @Column(name = "DAY_TYPE_CD", length = 7)
    private String dayTypeCd;

    @ApiModelProperty("수집 개수")  // Y NUMBER(7)
    @Column(name = "CLCT_NUM", columnDefinition = "NUMBER", length = 7)
    private Integer clctNum;

    public TbRseObuClctStatDdDto toDto() {
        return TbRseObuClctStatDdDto.builder()
                .statDt(this.statDt)
                .rseCtlrNmbr(this.rseCtlrNmbr)
                .dayTypeCd(this.dayTypeCd)
                .clctNum(this.clctNum)
                .build();
    }

    public TbRseObuClctStatDd(String statDt, Long rseCtlrNmbr) {
        this.statDt = statDt;
        this.rseCtlrNmbr = rseCtlrNmbr;
    }

    public void updateInfo(TbRseObuClctStatDdDto.TbRseObuClctStatDdUpdReq req) {
        this.dayTypeCd = req.getDayTypeCd();
        this.clctNum = req.getClctNum();
    }

}
