123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package e
- type Rescode int64
- const (
- SUCCESS Rescode = 200 + iota
- ERROR
- )
- const (
- TokenIsInvalid Rescode = 1001 + iota
- TokenIsExpired
- DELETEFAIL
- UPDATEFAIL
- ErrorFileReadFailed
- PaginationFailed
- JSONParsingFailed
- TheUserAlreadyExists
- AlreadyExists
- TheSystemIsAbnormal
- CodeIsError
- Theuseralreadyexists
- ThePhoneNumberIsWrong
- AnExceptionOccursWhenSendingAnSMSVerificationCode
- TokenIsFaild
- ThePasswordIsWrongOrThePhoneNumberIsIncorrect
- HasSend
- TheUserIsEmpty
- )
- var MsgFlags = map[Rescode]string{
- SUCCESS: "ok",
- ERROR: "fail",
- DELETEFAIL: "删除失败",
- TheUserAlreadyExists: "用户已存在",
- TheSystemIsAbnormal: "系统异常",
- CodeIsError: "验证码错误",
- UPDATEFAIL: "更新失败",
- Theuseralreadyexists: "用户已存在",
- JSONParsingFailed: "json解析失败",
- ThePhoneNumberIsWrong: "手机号错误",
- HasSend: "验证码已发送",
- AlreadyExists: "文件已存在",
- PaginationFailed: "分页查询失败",
- ErrorFileReadFailed: "文件获取失败",
- AnExceptionOccursWhenSendingAnSMSVerificationCode: "发送短信验证码出现异常",
- ThePasswordIsWrongOrThePhoneNumberIsIncorrect: "手机号或者密码错误",
- TokenIsInvalid: "Token 无效",
- TokenIsExpired: "Token 过期",
- TokenIsFaild: "Token 生成失败",
- TheUserIsEmpty: "用户为空",
- }
- func (c Rescode) GetMsg() string {
- // 检查Rescode是否在MsgFlags中定义,避免返回意外的消息
- msg, ok := MsgFlags[c]
- if ok {
- return msg
- } else {
- // 如果Rescode无效,则返回错误消息
- return MsgFlags[ERROR]
- }
- }
|