package e type Rescode int64 func (c Rescode) Error() string { //TODO implement me panic("implement me") } const ( SUCCESS Rescode = 200 + iota ERROR ) const ( TokenIsInvalid Rescode = 1001 + iota TokenIsExpired DELETEFAIL UPDATEFAIL FINDFAIL DeleteFail PaginationFailed JSONParsingFailed TheUserAlreadyExists AlreadyExists TheSystemIsAbnormal CodeIsError Theuseralreadyexists ThePhoneNumberIsWrong AnExceptionOccursWhenSendingAnSMSVerificationCode TokenIsFaild ThePasswordIsWrongOrThePhoneNumberIsIncorrect HasSend TheUserIsEmpty TheParameterCannotBeEmpty ) var MsgFlags = map[Rescode]string{ SUCCESS: "ok", ERROR: "fail", DELETEFAIL: "删除失败", TheUserAlreadyExists: "用户已存在", TheSystemIsAbnormal: "系统异常", CodeIsError: "验证码错误", UPDATEFAIL: "更新失败", Theuseralreadyexists: "用户已存在", JSONParsingFailed: "json解析失败", ThePhoneNumberIsWrong: "手机号错误", HasSend: "验证码已发送", AlreadyExists: "手机号已存在", PaginationFailed: "分页查询失败", FINDFAIL: "查询失败", DeleteFail: "删除失败", TheParameterCannotBeEmpty: "参数不能为空", 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] } }