package com.cool.store.enums.wechat;

import com.fasterxml.jackson.annotation.JsonValue;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;

import static com.cool.store.enums.wechat.WechatTemplateDetailEnum.*;

/**
 * @Author suzhuhong
 * @Date 2025/10/10 14:39
 * @Version 1.0
 */
public enum WechatTemplateEnum {

    QUESTION_NOTICE("QUESTION_NOTICE", "T3sp5gBItHKD8oCeEiQMjn7JXpngFiz3dDcaArk84xY", "收到工单通知",
            Arrays.asList(CHARACTER_STRING2,THING10,TIME14,THING25,THING60)),

    NEW_QUESTION_NOTICE("new_question_notice", "35rmoQ5wEHvUgCgSIJ2CpOb1DOJgWOiy8J7DXT_e4_Y", "新工单提醒",
            Arrays.asList(THING6,TIME33,CHARACTER_STRING14)),

    ;


    private final String code;
    private final String templateId;
    private final String title;
    private final List<WechatTemplateDetailEnum> contentList;

    WechatTemplateEnum(String code, String templateId, String title, List<WechatTemplateDetailEnum> contentList) {
        this.code = code;
        this.templateId = templateId;
        this.title = title;
        this.contentList = contentList;
    }

    @JsonValue
    public String getCode() {
        return code;
    }

    public String getTemplateId() {
        return templateId;
    }

    public String getTitle() {
        return title;
    }

    public List<WechatTemplateDetailEnum> getContentList() {
        return contentList;
    }

    /**
     * 根据code获取枚举
     */
    public static WechatTemplateEnum getByCode(String code) {
        for (WechatTemplateEnum template : values()) {
            if (template.getCode().equals(code)) {
                return template;
            }
        }
        return null;
    }

    /**
     * 根据模板ID获取枚举
     */
    public static WechatTemplateEnum getByTemplateId(String templateId) {
        for (WechatTemplateEnum template : values()) {
            if (template.getTemplateId().equals(templateId)) {
                return template;
            }
        }
        return null;
    }
}
