package com.fs.enums;

import lombok.Getter;

@Getter
public enum ExceptionCodeEnum {

    // ============ 用户相关错误 (400-419) ============
    USER_NOT_FOUND(401, "当前用户信息不存在，请重新授权"),

    // ============ 会员相关错误 (420-439) ============
    USER_BLACKLISTED(421, "已被拉黑,请联系管理员"),

    // ============ 销售相关错误 (440-459) ============
    SALES_NOT_FOUND(441, "当前销售不存在"),
    SALES_FORBIDDEN_BIND(442, "当前销售禁止绑定会员，请联系销售！"),
    CONTACT_SALES_FOR_INVITATION(443, "请联系销售发送邀请链接成为会员！"),

    // ============ 会员关系错误 (460-479) ============
    MEMBER_DISABLED(461, "当前学习通道访问限流，暂时无法观看！"),
    USER_ALREADY_OTHER_SALES_MEMBER(462, "该用户(%s)已成为其他销售会员"),
    USER_COMPANY_OTHER_SALES_MEMBER(463, "该用户(%s)已在公司%s成为其他销售会员"),

    // ============ 课程相关错误 (480-499) ============
    COURSE_CONFIG_ERROR(481, "课程配置错误,项目归属为空,课程ID: %s"),
    WATCH_LATEST_COURSE(482, "请观看最新的课程项目"),
    EXCEED_COURSE_LIMIT(483, "超过项目看课数量限制"),
    ALREADY_WATCHED_OTHER_SALES_COURSE(484, "已看过其他销售分享的此课程，不能重复观看"),
    USER_PROJECT_OTHER_SALES_BOUND(485, "您已在其他伴学助手处观看过该项目课程，请联系原助手继续学习"),

    // ============ 参数相关错误 (500-519) ============
    PARAM_ERROR(501, "参数错误！"),
    GROUP_PARAM_ERROR(502, "群参数异常"),
    LIVE_PARAM_ERROR(503, "直播参数错误"),

    // ============ 系统相关错误 (520-539) ============
    SERVICE_UNAVAILABLE(521, "服务暂时不可用，请联系管理员");

    private final Integer code;
    private final String description;

    ExceptionCodeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 获取格式化后的描述信息
     * @param args 格式化参数
     * @return 格式化后的描述
     */
    public String getFormattedDescription(Object... args) {
        return String.format(description, args);
    }
}
