package com.test.bijihoudaun.common.response;

import lombok.Getter;

/**
 * 返回状态码枚举
 */
@Getter
public enum ResultCode {
    // 基础状态码
    SUCCESS(200, "操作成功"),
    FAILED(500, "操作失败"),
    VALIDATE_FAILED(400, "参数校验失败"),
    UNAUTHORIZED(401, "未授权"),
    TOKEN_EXPIRED(4011, "Token已过期"),
    TOKEN_INVALID(4012, "Token无效"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    
    // 参数相关错误
    PARAM_IS_INVALID(1001, "参数无效"),
    PARAM_IS_BLANK(1002, "参数为空"),
    PARAM_TYPE_BIND_ERROR(1003, "参数类型错误"),
    PARAM_NOT_COMPLETE(1004, "参数缺失"),
    
    // 加密相关错误
    ENCRYPTION_FAILED(2001, "加密失败"),
    DECRYPTION_FAILED(2002, "解密失败"),
    KEY_GENERATION_FAILED(2003, "密钥生成失败"),
    INVALID_KEY_FORMAT(2004, "密钥格式无效"),

    // 编码相关
    BASE64_ENCODE_FAILED(4001, "Base64编码失败"),
    BASE64_DECODE_FAILED(4002, "Base64解码失败"),



    // ID生成相关
    ID_GENERATION_FAILED(3001, "ID生成失败"),
    UUID_GENERATION_FAILED(3002, "UUID生成失败"),
    SNOWFLAKE_PARAM_INVALID(3003, "雪花ID参数无效"),  // 用于workerId/datacenterId越界
    CLOCK_BACKWARD_ERROR(3004, "系统时钟回拨异常"),   // 处理时钟回拨场景
    SEQUENCE_OVERFLOW(3005, "ID序列号溢出");        // 序列号超过4095时的异常


    private final Integer code;
    private final String msg;

    ResultCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
