package com.hzya.frame.basedao.entity;

import com.fasterxml.jackson.annotation.JsonCreator;

public enum DataSourceType {

    //数据库类型
    MYSQL("MYSQL", "MYSQL"),
    ORACLE("ORACLE", "ORACLE");


    //类型
    private String type;
    //描述
    private String desc;

    private DataSourceType(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 增加映射方法，并为方法添加@JsonCreator
     */
    @JsonCreator
    public static DataSourceType getDataSourceTypeFromCodeName(String value) {
        for (DataSourceType dep : DataSourceType.values()) {
            if (dep.getType().equals(value)) {
                return dep;
            }
        }
        return null;
    }
}
