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