package com.its.op.dto.its.oper;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.oper.TbUserInfr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 사용자정보 DTO Class
 */
@Data
@Builder
@ApiModel("TbUserInfrDto(사용자정보)")
public class TbUserInfrDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("사용자ID(사원번호)")  // N VARCHAR2(20)
    @JsonProperty("user_id")
    private String userId;

    @ApiModelProperty("비밀번호")  // Y VARCHAR2(64)
    @JsonProperty("pwd")
    private String pwd;

    @ApiModelProperty("이름")  // Y VARCHAR2(30)
    @JsonProperty("name")
    private String name;

    @ApiModelProperty("주민번호")  // Y VARCHAR2(14)
    @JsonProperty("resd_nmbr")
    private String resdNmbr;

    @ApiModelProperty("회사명")  // Y VARCHAR2(100)
    @JsonProperty("comp")
    private String comp;

    @ApiModelProperty("부서명")  // Y VARCHAR2(100)
    @JsonProperty("dept_name")
    private String deptName;

    @ApiModelProperty("직위(직급)명")  // Y VARCHAR2(14)
    @JsonProperty("pos_name")
    private String posName;

    @ApiModelProperty("이메일주소")  // Y VARCHAR2(128)
    @JsonProperty("email")
    private String email;

    @ApiModelProperty("전화번호")  // Y VARCHAR2(30)
    @JsonProperty("tel")
    private String tel;

    @ApiModelProperty("이동전화번호")  // Y VARCHAR2(30)
    @JsonProperty("mobile")
    private String mobile;

    @ApiModelProperty("입사일자")  // Y VARCHAR2(8)
    @JsonProperty("ent_dt")
    private String entDt;

    @ApiModelProperty("기타")  // Y VARCHAR2(512)
    @JsonProperty("emp_etc")
    private String empEtc;

    @ApiModelProperty("운영시스템ID")  // Y VARCHAR2(7)
    @JsonProperty("oper_syst_id")
    private String operSystId;

    @ApiModelProperty("시스템권한 그룹ID")  // Y VARCHAR2(7)
    @JsonProperty("grop_id")
    private String gropId;

    @ApiModelProperty("비밀번호힌트질문('HNT')")  // Y VARCHAR2(7)
    @JsonProperty("hint_ques")
    private String hintQues;

    @ApiModelProperty("비밀번호힌트질문답")  // Y VARCHAR2(100)
    @JsonProperty("hint_ans")
    private String hintAns;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    // Code Description Field
    @ApiModelProperty("삭제 여부 설명")
    @JsonProperty("del_desc")    // DEL_YN
    private String delDesc;

    @ApiModel("TbUserInfrUpdReq(사용자정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbUserInfrUpdReq {

        @ApiModelProperty("사용자ID(사원번호), Nullable = N, VARCHAR2(20)")  // N VARCHAR2(20)
        @JsonProperty("user_id")
        @Size(min=1, max=20)
        private String userId;

        @ApiModelProperty("비밀번호, Nullable = Y, VARCHAR2(64)")  // Y VARCHAR2(64)
        @JsonProperty("pwd")
        @Size(min=1, max=64)
        private String pwd;

        @ApiModelProperty("이름, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("name")
        @Size(min=1, max=30)
        private String name;

        @ApiModelProperty("주민번호, Nullable = Y, VARCHAR2(14)")  // Y VARCHAR2(14)
        @JsonProperty("resd_nmbr")
        @Size(max=14)
        private String resdNmbr;

        @ApiModelProperty("회사명, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("comp")
        @Size(max=100)
        private String comp;

        @ApiModelProperty("부서명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("dept_name")
        @Size(max=30)
        private String deptName;

        @ApiModelProperty("직위(직급)명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("pos_name")
        @Size(max=30)
        private String posName;

        @ApiModelProperty("이메일주소, Nullable = Y, VARCHAR2(128)")  // Y VARCHAR2(128)
        @JsonProperty("email")
        @Size(min=1, max=128)
        private String email;

        @ApiModelProperty("전화번호, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("tel")
        @Size(max=30)
        private String tel;

        @ApiModelProperty("이동전화번호, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("mobile")
        @Size(max=30)
        private String mobile;

        @ApiModelProperty("입사일자, Nullable = Y, VARCHAR2(8)")  // Y VARCHAR2(8)
        @JsonProperty("ent_dt")
        @Size(min=1, max=8)
        private String entDt;

        @ApiModelProperty("기타, Nullable = Y, VARCHAR2(512)")  // Y VARCHAR2(512)
        @JsonProperty("emp_etc")
        @Size(min=1, max=512)
        private String empEtc;

        @ApiModelProperty("운영시스템ID, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("oper_syst_id")
        @Size(min=1, max=7)
        private String operSystId;

        @ApiModelProperty("시스템권한 그룹ID, Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("grop_id")
        @Size(min=1, max=7)
        private String gropId;

        @ApiModelProperty("비밀번호힌트질문('HNT'), Nullable = Y, VARCHAR2(7)")  // Y VARCHAR2(7)
        @JsonProperty("hint_ques")
        @Size(max=7)
        private String hintQues;

        @ApiModelProperty("비밀번호힌트질문답, Nullable = Y, VARCHAR2(100)")  // Y VARCHAR2(100)
        @JsonProperty("hint_ans")
        @Size(max=100)
        private String hintAns;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @Builder
        public TbUserInfrUpdReq(String user_id, String pwd, String name, String resd_nmbr, String comp, String dept_name, String pos_name, String email, String tel, String mobile, String ent_dt, String emp_etc, String oper_syst_id, String grop_id, String hint_ques, String hint_ans, String del_yn) {
            this.userId = user_id;
            this.pwd = pwd;
            this.name = name;
            this.resdNmbr = resd_nmbr;
            this.comp = comp;
            this.deptName = dept_name;
            this.posName = pos_name;
            this.email = email;
            this.tel = tel;
            this.mobile = mobile;
            this.entDt = ent_dt;
            this.empEtc = emp_etc;
            this.operSystId = oper_syst_id;
            this.gropId = grop_id;
            this.hintQues = hint_ques;
            this.hintAns = hint_ans;
            this.delYn = del_yn;
        }

        public TbUserInfr toEntity() {
            return TbUserInfr.builder()
                    .userId(this.userId)
                    .pwd(this.pwd)
                    .name(this.name)
                    .resdNmbr(this.resdNmbr)
                    .comp(this.comp)
                    .deptName(this.deptName)
                    .posName(this.posName)
                    .email(this.email)
                    .tel(this.tel)
                    .mobile(this.mobile)
                    .entDt(this.entDt)
                    .empEtc(this.empEtc)
                    .operSystId(this.operSystId)
                    .gropId(this.gropId)
                    .hintQues(this.hintQues)
                    .hintAns(this.hintAns)
                    .delYn(this.delYn)
                    .build();
        }

    }

    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbUserPswdUpdReq {

        @NotEmpty
        @Size(min=1, max=64)
        @JsonProperty("old_pwd")
        private String oldPwd;

        @NotEmpty
        @Size(min=1, max=64)
        @JsonProperty("pwd")
        private String pwd;

        @Builder
        public TbUserPswdUpdReq(String oldPwd, String pwd) {
            this.oldPwd = oldPwd;
            this.pwd = pwd;
        }
    }

}
