package com.cloudhandson.vpdbackoffice.domain.masking;

public record UserMaskingRule(
    long userId,
    String username,
    long columnId,
    String owner,
    String objectName,
    String columnName,
    String ruleName,
    String templateCode,
    String decision,
    String activeYn
) {

  public boolean unmasked() {
    return "UNMASK".equalsIgnoreCase(decision);
  }

  public boolean active() {
    return "Y".equalsIgnoreCase(activeYn);
  }

  public String decisionLabel() {
    return unmasked() ? "원문 표시 허용" : "기본값과 동일 · 마스킹";
  }

  public String targetLabel() {
    return owner + "." + objectName + "." + columnName;
  }

  public String ruleLabel() {
    return ruleName + " · " + MaskingTemplate.from(templateCode).label();
  }
}
