package cn.stylefeng.team.generator.api.enums;

import lombok.Getter;

@Getter
public enum GeneratorTypeEnum {

    SINGLE_TABLE_FRONT(1, "单表-前端代码生成"),

    SINGLE_TABLE_BACKEND(2, "单表-后端代码生成"),

    BIZ_BACKEND_GENERATE(3, "业务代码-后端生成"),

    BIZ_FRONT_GENERATE(4, "业务代码-前端生成"),

    TEMP_FORM_COMPONENTS(10, "前端代码生成，用在表单处理上，非前端直接生成"),

    CREAT_SQL(20, "建表语句生成"),

    INSERT_SYS_DICT_SQL(30, "基于用户字典创建系统字典插入sql"),

    JAVA_ENUM(31, "根据用户字典，创建枚举类"),

    ALTER_TABLE(40, "alter语句的模板，针对表结构进行更新的语句");

    private final Integer code;

    private final String name;

    GeneratorTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static GeneratorTypeEnum getByCode(Integer code) {
        for (GeneratorTypeEnum value : GeneratorTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

}
