// Package e -----------------------------
// @file      : chatCode.go
// @author    : JJXu
// @contact   : wavingbear@163.com
// @time      : 2025/6/12 16:57
// -------------------------------------------
package e

import "fmt"

type ErrorCodeType int

func (e ErrorCodeType) String() string {
	return GetCodeMsg(e)
}

func (e ErrorCodeType) Error() string {
	return GetCodeMsg(e)
}
func (e ErrorCodeType) Int() int {
	return int(e)
}
func GetCodeMsg(e ErrorCodeType) string {
	v, ok := msgFlags[e]
	if !ok {
		return fmt.Sprintf("未知错误:[%d]", e)
	}
	return v
}

var msgFlags = map[ErrorCodeType]string{
	SUCCESS:               "操作成功",
	UpdatePasswordSuccess: "修改密码成功",
	NotExistInentifier:    "该第三方账号未绑定",
	ERROR:                 "fail",
	InvalidParams:         "请求参数错误",
	BindError:             "参数绑定错误，类型不一致",
	JsonUnmarshal:         "Json解析错误",

	ErrorDatabase: "数据库操作出错,请重试",

	ErrorOss: "OSS配置错误",

	InvalidToken: "Token验证失败",

	ErrorUploadFile:       "上传失败",
	ErrorUploadVideoCover: "视频截取封面错误",
	ErrorUploadValidParam: "上传参数非法",
	ErrorFileReadErr:      "读取文件错误",
	ErrorFileNotExists:    "文件不存在",
	ErrorChunkNotGt:       "分块数量不一致",
	ErrorChunk:            "读取分块错误",
	ErrorUploadBos:        "上传bos错误",
	ErrorFileCreate:       "文件创建错误",
	ErrInvalidDataFormat:  "无效的数据格式",
	ErrInvalidClientId:    "无效的客户端ID",
	ErrRegisterFailed:     "注册失败",
	ErrUnRegistered:       "未注册客户端",
	PermissionDenied:      "拒绝访问",
	ErrChatSendErr:        "消息发送失败",
}
