package com.ankaibei.workFlow.common.core.object;

/**
 * @ClassName: AgentCodeEnum
 * @Copyright: 2019
 */
public enum CodeEnum {
    //根据业务逻辑往下排
    OK("200", "请求成功"),
    NO_DATA("203", "无数据"),
    FAIL("204", "失败"),
    FEI_FA_QING_QIU("501", "参数为空"),
    TOKEN_IS_NULL("503", "令牌为空"),
    AUTH_CODE_EXP("505", "授权码失效"),
    SERVER_ERROR_UNKNOWN("500", "网络开小差"),
    LOGIN_FAIL("444", "请重新登录"),
    BLACK_LOGIN_FAIL_IP("445", "IP黑名单"),
    PERMISSION_DENIED("447", "该用户没有访问权限"),
    REGISTER_FAIL("90001", "注册失败"),
    ACCOUNT_UNREGISTER("90002", "用户名称错误，请重试"),
    USER_NAME_PWD_NULL_CODE("90003", "用户名或密码不能为空"),
    ACCOUNT_NO_PASSWORD_ERROR("90004", "用户名或密码错误"),
    MOBILE_PHONE_FORMAT_ILLEGAL("90005", "联系方式格式不正确"),
    ACCOUNT_NO_USED("90007", "用户名已经被使用"),
    INPUT_NULL_CODE("90008", "输入不能为空"),
    REVISE_PWD_FAIL("90009", "修改密码失败"),
    LOGOUT_FAIL("90010", "登出失败"),
    PARAM_NUll("90011", "参数为空"),
    USER_NOT_FIND("90012", "无此用户信息"),
    PWD_FAIL("90013", "密码错误"),
    NOT_LOGIN("90014", "未登录"),
    INVALID_USER_STATUS("90015", "用户状态错误，请刷新后重试！"),
    CODE_ERROR("90016", "数据验证失败，请重试！"),
    JUMP_LOGIN("90017", "请先登录"),
    IDENT_NOT_EXIT("90018", "身份信息不存在"),
    INSERT_FAIL("90019", "新增失败"),
    UPDATE_FAIL("90020", "更新失败"),
    DUPLICATE_DATA("90021", "数据重复"),
    EMAIL_FORMAT_ILLEGAL("90022", "邮箱不合法"),
    ID_EXISTED("90023", "编码已存在"),
    IMPORT_ERROR("90024", "导入数据有误，或已存在"),
    NO_ACCESS("90025", "无管理工作台权限"),
    PARAMETER_VALIDATE_ERROR("90026", "输入参数不合法"),
    IMPORT_IS_NULL("90027", "导入的数据为空"),
    OLD_PWD_ERROR("90028", "旧密码不正确"),
    CONFIRM_PWD_ERROR("90029", "两次密码输入不一致"),
    ID_NOTFOUND("90030", "ID不存在"),
    LOGIN_ACCT_ERROR("90031", "登录名不能为汉字"),
    VISIT_FREQUENTLY("90032", "访问过于频繁,请稍后重试"),
    NAME_EXISTED("90033", "名称已存在"),
    OBJECT_EXISTED("90034", "对象已存在"),
    EXPIRE_TIME_BEFORE_EFFECTIVE("90035", "生效失效日期不合规"),
    URL_EXISTED("90036", "地址已存在"),
    AUTH_METHOD_FAIL("90037", "获取认证方式信息失败"),
    PWD_DUPLICATE("90038", "密码不能同前五次密码相同"),
    VERIFICATION_CODE("90039", "验证码已失效"),
    BIZ_AUTH_SYS_ID("90040", "没有访问权限"),
    ACCOUNT_EXIST("90041", "账号已存在"),
    DELETE("90042", "账号已被注销"),
    ROLE_DELETE_ERROR("90043", "角色删除失败"),
    APP_RES_DELETE_ERROR("90044", "资源删除失败"),
    ROLE_NOT_FIND("90045", "角色没有找到！"),
    ACCOUNT_DISABLED("90046", "账号不可用"),
    DATA_NOT_EXIST("90051", "数据不存在，请刷新后重试！"),
    DATA_VALIDATED_FAILED("90052", "数据验证失败，请核对！"),
    ARGUMENT_NULL_EXIST("90053", "数据验证失败，接口调用参数存在空值，请核对！"),

    /**
     * 存在关联数据
     */
    DATA_IS_RELEVANCE("90050", "当前对象存在关联数据，请谨慎操作！"),
    /**
     * 查询到多个重复的用户
     */
    ACCOUNT_SEVERAL("90047", "查询到多个重复的用户"),

    /**
     * 账号状态异常
     */
    ACCOUNT_STATUS_ABNORMAL("90048", "账号状态异常"),
    /**
     * 账号状态异常
     */
    TOKEN_ABNORMAL("90049", "服务端token维护异常");


    private final String code;
    private final String reason;

    CodeEnum(final String statusCode, final String reasonPhrase) {
        this.code = statusCode;
        this.reason = reasonPhrase;
    }

    /**
     * Convert a numerical status code into the corresponding Status
     *
     * @param statusCode the numerical status code
     * @return the matching Status or null is no matching Status is defined
     */
    public static CodeEnum fromCode(final String statusCode) {
        for (CodeEnum s : CodeEnum.values()) {
            if (s.code.equals(statusCode)) {
                return s;
            }
        }
        return null;
    }

    /**
     * Get the associated status code
     *
     * @return the status code
     */
    public String getCode() {
        return code;
    }

    /**
     * Get the reason phrase
     *
     * @return the reason phrase
     */
    @Override
    public String toString() {
        return reason;
    }
}
