package com.leromro.common.enums;

/**
 * 结算申请方类型 1区域管理  2服务中心
 */
public enum ApplicantTypeEnum {
    AREA("1", "区域管理"),
    SERVICE_CENTER("2", "服务中心");

    private String code;
    private String message;

    ApplicantTypeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ApplicantTypeEnum getEnumByCode(Integer code) {
        for (ApplicantTypeEnum applicantTypeEnum : ApplicantTypeEnum.values()) {
            if (applicantTypeEnum.getCode().equals(code)) {
                return applicantTypeEnum;
            }
        }
        return null;
    }

    public static ApplicantTypeEnum getEnumByMessage(String message) {
        for (ApplicantTypeEnum applicantTypeEnum : ApplicantTypeEnum.values()) {
            if (applicantTypeEnum.getMessage().equals(message)) {
                return applicantTypeEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (ApplicantTypeEnum applicantTypeEnum : ApplicantTypeEnum.values()) {
            if (applicantTypeEnum.getCode().equals(code)) {
                return applicantTypeEnum.getMessage();
            }
        }
        return null;
    }

    /**
     * 根据部门类型转换为结算申请方类型
     */
    public static String getCodeByAreaType(String areaType) {
        if("3".equals(areaType)){
            return ApplicantTypeEnum.AREA.getCode();
        }
        if("4".equals(areaType)){
            return ApplicantTypeEnum.SERVICE_CENTER.getCode();
        }
        return null;
    }
}
