package com.sckw.core.model.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author czh
 * @desc 审批状态枚举
 * @date 2023/6/15
 */
@Getter
public enum ApprovalEnum {

    //未审批
    NO(0, "待认证"),
    //通过
    OK(1, "已认证"),
    //未通过
    PASS(2, "已驳回"),
    //审批中
    PROCESS(3, "待审批"),
    //更新中，待审批
    REFRESH(4, "更新中");

    private final int code;

    private final String name;

    ApprovalEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getName(int code) {
        for (ApprovalEnum approvalEnum : values()) {
            if (approvalEnum.getCode() == code) {
                return approvalEnum.getName();
            }
        }
        return null;
    }

    public static List<Map<String, String>> getDefaultApprovalEnum() {
        List<Map<String, String>> list = new ArrayList<>();
        for (ApprovalEnum approvalEnum : ApprovalEnum.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("code", String.valueOf(approvalEnum.getCode()));
            map.put("name", approvalEnum.getName());
            list.add(map);
        }
        return list;
    }

}
