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

import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import cn.stylefeng.team.generator.api.constants.GenerationConstants;
import lombok.Getter;

@Getter
public enum GenerationExceptionEnum implements AbstractExceptionEnum {

    CANT_FIND_TEMPLATE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "01",
            "找不到对应模板文件，无法进行代码生成"),

    TEMPLATE_INIT_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "02",
            "模板初始化错误！具体原因：{}"),

    TEMPLATE_RENDER_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "03",
            "模板渲染异常,{}"),

    MODEL_ID_LIST_NOT_EMPTY(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "04",
            "模型id列表不能为空"),

    FILE_DOWNLOAD_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "05",
            "文件下载错误，具体错误：{}"),

    TEMP_DIR_CREATE_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "06",
            "代码下载创建临时目录失败"),

    CANT_FIND_GEN_APP(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "07",
            "无法找到项目生成的应用"),

    CANT_FIND_MAIN_TABLE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "08",
            "业务生成无法找到主表，请必须选一个主表"),

    TOO_MANY_MAIN_TABLE(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "08",
            "业务生成，主表数量不能超过1个"),

    EMPTY_META_FIELD(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "09",
            "检测到字段为空，无法进行代码生成"),

    TARGET_PACKAGE_NAME_IS_SUB_PATH(RuleConstants.BUSINESS_ERROR_TYPE_CODE + GenerationConstants.GENERATION_EXCEPTION_STEP_CODE + "10",
            "请更换包名，目标包名不能为原始包名的子路径");

    private final String errorCode;

    private final String userTip;

    GenerationExceptionEnum(String errorCode, String userTip) {
        this.errorCode = errorCode;
        this.userTip = userTip;
    }

}
