package cn.com.qmth.stmms.ms.core.domain.enums;

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

/**
 * 内置账号
 */
public enum BuiltInAccountEnum {

    /**
     * 纪检员
     */
    INSPECTION("INSPECTION", "纪检员"),
    /**
     * 质检员
     */
    QC("QC", "质检员"),
    /**
     * 采集账号
     */
    SCAN("SCAN", "采集员");

    private String code;

    private String name;

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

    public static BuiltInAccountEnum findById(String code) {
        for (BuiltInAccountEnum account : BuiltInAccountEnum.values()) {
            if (account.code == code) {
                return account;
            }
        }
        return null;
    }

    public static List<Map> listAccounts() {
        List<Map> list = new ArrayList<>();
        for (BuiltInAccountEnum account : BuiltInAccountEnum.values()) {
            Map map = new HashMap();
            map.put("code", account.code);
            map.put("name", account.name);
            map.put("type", findById(account.code).toString());
            list.add(map);
        }
        return list;
    }

}
