package com.tofly.feesapi.common.enums;

import com.baomidou.mybatisplus.annotation.IEnum;

public enum CblyEnum  implements IEnum {

     APP抄表(2,"APP抄表"),

     营业大厅(1,"营销系统录入");


    private Integer value;
    private String name;
    CblyEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    /**
     * 根据code查找
     * @param code 枚举code
     * @return 枚举对象
     */
    public static CblyEnum findEnumByCode(Integer code) {
        for (CblyEnum statusEnum : CblyEnum.values()) {
            if (statusEnum.getValue().equals(code)) {
                //如果需要直接返回name则更改返回类型为String,return statusEnum.name;
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("code is invalid");
    }

    /**
     * 根据name查找
     * @param name 枚举name
     * @return 枚举对象
     */
    public static CblyEnum findEnumByName(String name) {
        for (CblyEnum statusEnum : CblyEnum.values()) {
            if (statusEnum.name().equals(name)) {
                //如果需要直接返回code则更改返回类型为String,return statusEnum.code;
                return statusEnum;
            }
        }
        throw new IllegalArgumentException("name is invalid");
    }

}
