package com.enums;

public enum SourceEnum {
    czy(15,"业务"),
    pzy(16,"配置"),
    sjy(17,"审计");

    private int code;
    private String decription;

    public int getCode() {
        return code;
    }

    private SourceEnum(int code, String decription) {
        this.code = code;
        this.decription = decription;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getDecription() {
        return decription;
    }

    public void setDecription(String decription) {
        this.decription = decription;
    }

    public static String  getNameByCode(int code){
        if(code == 0){
            return "";
        }
        for(SourceEnum enums : SourceEnum.values()){
            if(code == enums.getCode()){
                return  enums.getDecription();
            }
        }
        return "";
    }

    public static int  getCodeByName(String name){
        if(name == null){
            return 0;
        }
        for(SourceEnum enums : SourceEnum.values()){
            if(name.equals(enums.getDecription())){
                return  enums.code;
            }
        }
        return 0 ;
    }
}
