package com.its.op.entity.its.link;

import com.its.op.dto.its.link.TbClctSystSttsHsDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * 수집 시스템 상태 이력 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("수집 시스템 상태 이력")
@Entity
@Table(name = "TB_CLCT_SYST_STTS_HS")
@IdClass(TbClctSystSttsHsKey.class)
public class TbClctSystSttsHs implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("수집 시스템 코드")  // N VARCHAR(7)
    @Id
    @Column(name = "CLCT_SYST_CD", nullable = false, length = 7)
    private String clctSystCd;

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

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

    @ApiModelProperty("필터링 개수")  // Y NUMBER(7)
    @Column(name = "FLTR_NUM", columnDefinition = "NUMBER", length = 7)
    private Integer fltrNum;

    @ApiModelProperty("퓨전 개수")  // Y NUMBER(7)
    @Column(name = "FUSN_NUM", columnDefinition = "NUMBER", length = 7)
    private Integer fusnNum;

    public TbClctSystSttsHsDto toDto() {
        return TbClctSystSttsHsDto.builder()
                .clctSystCd(this.clctSystCd)
                .prcnDt(this.prcnDt)
                .clctNum(this.clctNum)
                .fltrNum(this.fltrNum)
                .fusnNum(this.fusnNum)
                .build();
    }

    public TbClctSystSttsHs(String clctSystCd, String prcnDt) {
        this.clctSystCd = clctSystCd;
        this.prcnDt = prcnDt;
    }

    public void updateInfo(TbClctSystSttsHsDto.TbClctSystSttsHsUpdReq req) {
        this.clctNum = req.getClctNum();
        this.fltrNum = req.getFltrNum();
        this.fusnNum = req.getFusnNum();
    }

}
