package com.snack.server.common;

import lombok.Getter;

/**
 * 统一响应状态码
 */
@Getter
public enum ResultCode {

    SUCCESS(200, "操作成功"),
    FAIL(400, "操作失败"),
    UNAUTHORIZED(401, "未登录或Token已过期"),
    FORBIDDEN(403, "无权限访问"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),

    // 业务错误码 (1xxx)
    PARAM_ERROR(1000, "请求参数错误"),
    USER_NOT_EXIST(1001, "用户不存在"),
    USER_DISABLED(1002, "账号已被禁用"),
    USERNAME_EXIST(1003, "用户名已存在"),
    PASSWORD_ERROR(1004, "密码错误"),
    OLD_PASSWORD_ERROR(1005, "原密码错误"),
    PRODUCT_NOT_EXIST(1010, "商品不存在"),
    PRODUCT_OFF_SHELF(1011, "商品已下架"),
    STOCK_INSUFFICIENT(1012, "库存不足"),
    CATEGORY_NOT_EXIST(1013, "分类不存在"),
    CATEGORY_HAS_CHILDREN(1014, "分类下存在子分类，无法删除"),
    CATEGORY_HAS_PRODUCTS(1015, "分类下存在商品，无法删除"),
    CATEGORY_LEVEL_INVALID(1016, "分类层级不合法"),
    CATEGORY_NAME_DUPLICATE(1017, "同级分类下已存在同名分类"),
    ORDER_NOT_EXIST(1020, "订单不存在"),
    ORDER_STATUS_ERROR(1021, "订单状态异常，无法操作"),
    COUPON_NOT_EXIST(1030, "优惠券不存在"),
    COUPON_EXPIRED(1031, "优惠券已过期"),
    COUPON_USED(1032, "优惠券已使用"),
    COUPON_CONDITION_NOT_MET(1033, "不满足优惠券使用条件"),
    COUPON_RECEIVE_LIMIT(1034, "已达到领取上限"),
    COUPON_STOCK_EMPTY(1035, "优惠券已被领完"),
    SECKILL_NOT_STARTED(1040, "抢购活动尚未开始"),
    SECKILL_ENDED(1041, "抢购活动已结束"),
    SECKILL_STOCK_EMPTY(1042, "商品已抢完"),
    SECKILL_LIMIT_EXCEEDED(1043, "超过每人限购数量"),
    FILE_UPLOAD_ERROR(1050, "文件上传失败"),
    FILE_TYPE_NOT_ALLOWED(1051, "不支持的文件类型");

    private final Integer code;
    private final String message;

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