package com.xunmei.system.api.enums;

/**
 * @author :LuoWei
 * @date : 2023/8/14
 */

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.EnumSerializer;
import com.xunmei.common.core.utils.StringUtils;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 机构类型
 */
@Slf4j
@JsonSerialize(using = EnumSerializer.class)
public enum OrgType {
    YJFX("一级分行", "5a6a1ca2-c55b-4473-abb7-44ae302caf8c"),
    EJFX("二级分行", "e226dd02-cb0d-45aa-9034-59fa6566239e"),
    YJZX("一级支行", "87a6b4a5-cd72-4beb-b136-2299d6a85add"),
    WD("营业网点", "28f4be66-af08-4064-9407-b5b8346bb5af"),
    ZZ("离行式自助nh", ""),
    JK("金库", ""),
    BGDL("办公大楼", ""),
    JKZX("视频监控中心", ""),
    YQ("园区", ""),
    OTHER("其他", ""),
    XJZX("现金中心","");
    @Getter
    private final String text;

    private final String guid;

    OrgType(final String text, final String guid) {
        this.text = text;
        this.guid = guid;
    }

    public static OrgType findByGuid(final String guid) {
        if (StringUtils.isBlank(guid)) {
            return null;
        }
        for (final OrgType orgType : OrgType.values()) {
            if (StringUtils.equalsIgnoreCase(orgType.name(), guid)) {
                return orgType;
            }
            if (StringUtils.equalsIgnoreCase(orgType.guid, guid)) {
                return orgType;
            }
        }
        //ORGLOG.warn("[ {} ]没有对应机构类型", guid);
        return null;
    }
}
