package com.its.op.entity.its.code;

import com.its.op.dto.its.code.TbClctSystStupDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 수집 시스템 설정 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("수집 시스템 설정")
@Entity
@Table(name = "TB_CLCT_SYST_STUP")
public class TbClctSystStup 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("수집 시스템 번호")  // Y NUMBER(2)
    @Column(name = "CLCT_SYST_NMBR", columnDefinition = "NUMBER", length = 2)
    private Short clctSystNmbr;

    @ApiModelProperty("수집 시스템 명")  // N VARCHAR(30)
    @Column(name = "CLCT_SYST_NM", nullable = false, length = 30)
    private String clctSystNm;

    @ApiModelProperty("수집 시스템 설명")  // Y VARCHAR(100)
    @Column(name = "CLCT_SYST_EXPL", length = 100)
    private String clctSystExpl;

    @ApiModelProperty("수집 최대 개수")  // Y NUMBER(7)
    @Column(name = "CLCT_MAX_NUM", columnDefinition = "NUMBER", length = 7)
    private Short clctMaxNum;

    @ApiModelProperty("사용 여부")  // Y CHAR(1)
    @Column(name = "USE_YN", columnDefinition = "CHAR", length = 1)
    private String useYn;

    public TbClctSystStupDto toDto() {
        return TbClctSystStupDto.builder()
                .clctSystCd(this.clctSystCd)
                .clctSystNmbr(this.clctSystNmbr)
                .clctSystNm(this.clctSystNm)
                .clctSystExpl(this.clctSystExpl)
                .clctMaxNum(this.clctMaxNum)
                .useYn(this.useYn)
                .build();
    }

    public TbClctSystStup(String clctSystCd) {
        this.clctSystCd = clctSystCd;
    }

    public void updateInfo(TbClctSystStupDto.TbClctSystStupUpdReq req) {
        this.clctSystNmbr = req.getClctSystNmbr();
        this.clctSystNm = req.getClctSystNm();
        this.clctSystExpl = req.getClctSystExpl();
        this.clctMaxNum = req.getClctMaxNum();
        this.useYn = req.getUseYn();
    }

}
