package com.ruoyi.common.valid.face.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * @author wjh
 * 2024/9/23
 */
@Getter
@AllArgsConstructor
public enum FaceScoreResult {

    NOT_SAME("0", "不是同一个人"),
    UNKNOWN("1", "不确定是否为同一个人"),
    SAME("2", "同一个人");

    private final String code;
    private final String msg;

    public static final boolean isSame(FaceScoreResult result) {
        return SAME.equals(result);
    }

    public static final boolean isSame(BigDecimal score) {
        return isSame(getScoreCodeResult(score));
    }

    private static FaceScoreResult getScoreCodeResult(BigDecimal score) {
        if (score == null) {
            return NOT_SAME;
        }
        if (new BigDecimal("0.40").compareTo(score) > 0) {
            return NOT_SAME;
        }
        if (new BigDecimal("0.45").compareTo(score) > 0) {
            return UNKNOWN;
        }
        return SAME;
    }

}
