package com.jeesharp.business.modules.contentsecurity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 内容安全检测结论，与厂商 suggest 映射后的统一语义。
 *
 * @author jeesharp
 * @since 2026-06-27
 */
@Getter
@AllArgsConstructor
public enum CheckDecisionEnum {

    PASS("PASS", "通过"),
    REJECT("REJECT", "拒绝"),
    REVIEW("REVIEW", "疑似，转人工或待审"),
    PENDING("PENDING", "异步检测中");

    private final String code;
    private final String desc;

    public static CheckDecisionEnum fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (CheckDecisionEnum e : values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }

    /**
     * 微信 msgSecCheck / wxa_media_check 的 suggest 字段映射。
     */
    public static CheckDecisionEnum fromWechatSuggest(String suggest) {
        if (suggest == null || suggest.isBlank()) {
            return PASS;
        }
        if ("risky".equalsIgnoreCase(suggest)) {
            return REJECT;
        }
        if ("review".equalsIgnoreCase(suggest)) {
            return REVIEW;
        }
        return PASS;
    }
}
