package com.ga.core.vo.dict;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

@Data
public class DataDomainSaveReq {

    @NotBlank(message = "도메인코드는 필수입니다")
    @Size(max = 50)
    private String domainCode;

    @NotBlank(message = "도메인명은 필수입니다")
    @Size(max = 100)
    private String domainName;

    @NotBlank(message = "도메인 분류는 필수입니다")
    @Size(max = 50)
    private String domainCategory;

    @NotBlank(message = "데이터 타입은 필수입니다")
    @Size(max = 30)
    private String dataType;

    private Integer length;
    private Integer precision;
    private Integer scale;

    @Size(max = 100)
    private String formatPattern;

    @Size(max = 500)
    private String validationRegex;

    @Size(max = 200)
    private String exampleValue;

    @Size(max = 30)
    private String maskingType;

    private Boolean encrypted;

    @Size(max = 500)
    private String description;

    private Boolean isActive;

    public DataDomainVO toVO() {
        DataDomainVO vo = new DataDomainVO();
        vo.setDomainCode(domainCode);
        vo.setDomainName(domainName);
        vo.setDomainCategory(domainCategory);
        vo.setDataType(dataType);
        vo.setLength(length);
        vo.setPrecision(precision);
        vo.setScale(scale);
        vo.setFormatPattern(formatPattern);
        vo.setValidationRegex(validationRegex);
        vo.setExampleValue(exampleValue);
        vo.setMaskingType(maskingType);
        vo.setEncrypted(encrypted != null ? encrypted : Boolean.FALSE);
        vo.setDescription(description);
        vo.setIsActive(isActive != null ? isActive : Boolean.TRUE);
        return vo;
    }
}
