package com.ga.core.vo.dict;

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

@Data
public class DataDictionarySaveReq {

    @NotBlank(message = "테이블명은 필수입니다")
    @Size(max = 100)
    private String tableName;

    @NotBlank(message = "컬럼명은 필수입니다")
    @Size(max = 100)
    private String columnName;

    @Size(max = 50)
    private String domainCode;

    @Size(max = 200)
    private String columnLabel;

    @Size(max = 500)
    private String description;

    private Boolean isPk;
    private Boolean isFk;

    @Size(max = 200)
    private String fkReference;

    private Boolean isRequired;

    @Size(max = 200)
    private String defaultValue;

    @Size(max = 1000)
    private String businessRule;

    @Size(max = 200)
    private String sampleValue;

    private Integer sortOrder;

    public DataDictionaryVO toVO() {
        DataDictionaryVO vo = new DataDictionaryVO();
        vo.setTableName(tableName);
        vo.setColumnName(columnName);
        vo.setDomainCode(domainCode);
        vo.setColumnLabel(columnLabel);
        vo.setDescription(description);
        vo.setIsPk(isPk != null ? isPk : Boolean.FALSE);
        vo.setIsFk(isFk != null ? isFk : Boolean.FALSE);
        vo.setFkReference(fkReference);
        vo.setIsRequired(isRequired != null ? isRequired : Boolean.FALSE);
        vo.setDefaultValue(defaultValue);
        vo.setBusinessRule(businessRule);
        vo.setSampleValue(sampleValue);
        vo.setSortOrder(sortOrder != null ? sortOrder : 0);
        return vo;
    }
}
