package com.its.op.entity.its.cctv;

import com.its.op.dto.its.cctv.TbCctvCptnStupDto;
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;

/**
 * CCTV 자막 설정 정보 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("CCTV 자막 설정 정보")
@Entity
@Table(name = "TB_CCTV_CPTN_STUP")
@IdClass(TbCctvCptnStupKey.class)
public class TbCctvCptnStup implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("CCTV 관리 번호")  // N NUMBER(10)
    @Id
    @Column(name = "CCTV_CTLR_NMBR", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long cctvCtlrNmbr;

    @ApiModelProperty("자막 설정 번호")  // N NUMBER(3)
    @Id
    @Column(name = "STUP_NMBR", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer stupNmbr;

    @ApiModelProperty("시작 팬 값")  // Y NUMBER(5)
    @Column(name = "STRT_FAN_VAL", columnDefinition = "NUMBER", length = 5)
    private Integer strtFanVal;

    @ApiModelProperty("종료 팬 값")  // Y NUMBER(5)
    @Column(name = "END_FAN_VAL", columnDefinition = "NUMBER", length = 5)
    private Integer endFanVal;

    @ApiModelProperty("자막 크기 1")  // Y NUMBER(2)
    @Column(name = "CPTN_SIZE_1", columnDefinition = "NUMBER", length = 2)
    private Integer cptnSize1;

    @ApiModelProperty("자막 X 좌표 1")  // Y NUMBER(6)
    @Column(name = "CPTN_X_CRDN_1", columnDefinition = "NUMBER", length = 6)
    private Integer cptnXCrdn1;

    @ApiModelProperty("자막 Y 좌표 1")  // Y NUMBER(6)
    @Column(name = "CPTN_Y_CRDN_1", columnDefinition = "NUMBER", length = 6)
    private Integer cptnYCrdn1;

    @ApiModelProperty("자막 글꼴 1")  // Y NUMBER(2)
    @Column(name = "CPTN_FONT_1", columnDefinition = "NUMBER", length = 2)
    private Integer cptnFont1;

    @ApiModelProperty("자막 색상 1")  // Y NUMBER(2)
    @Column(name = "CPTN_HUE_1", columnDefinition = "NUMBER", length = 2)
    private Integer cptnHue1;

    @ApiModelProperty("자막 내용 1")  // Y VARCHAR2(100)
    @Column(name = "CPTN_CONT_1", length = 100)
    private String cptnCont1;

    @ApiModelProperty("자막 크기 2")  // Y NUMBER(2)
    @Column(name = "CPTN_SIZE_2", columnDefinition = "NUMBER", length = 2)
    private Integer cptnSize2;

    @ApiModelProperty("자막 X 좌표 2")  // Y NUMBER(6)
    @Column(name = "CPTN_X_CRDN_2", columnDefinition = "NUMBER", length = 6)
    private Integer cptnXCrdn2;

    @ApiModelProperty("자막 Y 좌표 2")  // Y NUMBER(6)
    @Column(name = "CPTN_Y_CRDN_2", columnDefinition = "NUMBER", length = 6)
    private Integer cptnYCrdn2;

    @ApiModelProperty("자막 글꼴 2")  // Y NUMBER(2)
    @Column(name = "CPTN_FONT_2", columnDefinition = "NUMBER", length = 2)
    private Integer cptnFont2;

    @ApiModelProperty("자막 색상 2")  // Y NUMBER(2)
    @Column(name = "CPTN_HUE_2", columnDefinition = "NUMBER", length = 2)
    private Integer cptnHue2;

    @ApiModelProperty("자막 내용 2")  // Y VARCHAR2(100)
    @Column(name = "CPTN_CONT_2", length = 100)
    private String cptnCont2;

    public TbCctvCptnStupDto toDto() {
        return TbCctvCptnStupDto.builder()
                .cctvCtlrNmbr(this.cctvCtlrNmbr)
                .stupNmbr(this.stupNmbr)
                .strtFanVal(this.strtFanVal)
                .endFanVal(this.endFanVal)
                .cptnSize1(this.cptnSize1)
                .cptnXCrdn1(this.cptnXCrdn1)
                .cptnYCrdn1(this.cptnYCrdn1)
                .cptnFont1(this.cptnFont1)
                .cptnHue1(this.cptnHue1)
                .cptnCont1(this.cptnCont1)
                .cptnSize2(this.cptnSize2)
                .cptnXCrdn2(this.cptnXCrdn2)
                .cptnYCrdn2(this.cptnYCrdn2)
                .cptnFont2(this.cptnFont2)
                .cptnHue2(this.cptnHue2)
                .cptnCont2(this.cptnCont2)
                .build();
    }

    public TbCctvCptnStup(Long cctvCtlrNmbr, Integer stupNmbr) {
        this.cctvCtlrNmbr = cctvCtlrNmbr;
        this.stupNmbr = stupNmbr;
    }

    public void updateInfo(TbCctvCptnStupDto.TbCctvCptnStupUpdReq req) {
        this.strtFanVal = req.getStrtFanVal();
        this.endFanVal = req.getEndFanVal();
        this.cptnSize1 = req.getCptnSize1();
        this.cptnXCrdn1 = req.getCptnXCrdn1();
        this.cptnYCrdn1 = req.getCptnYCrdn1();
        this.cptnFont1 = req.getCptnFont1();
        this.cptnHue1 = req.getCptnHue1();
        this.cptnCont1 = req.getCptnCont1();
        this.cptnSize2 = req.getCptnSize2();
        this.cptnXCrdn2 = req.getCptnXCrdn2();
        this.cptnYCrdn2 = req.getCptnYCrdn2();
        this.cptnFont2 = req.getCptnFont2();
        this.cptnHue2 = req.getCptnHue2();
        this.cptnCont2 = req.getCptnCont2();
    }

}
