package e type Rescode int64 const ( SUCCESS Rescode = 200 + iota ERROR NOTTABLE ) const ( TokenIsInvalid Rescode = 1001 + iota TokenIsExpired DELETEFAIL UPDATEFAIL PaginationFailed JSONParsingFailed TheUserAlreadyExists AlreadyExists TheSystemIsAbnormal CodeIsError TheVerificationCodeWasNotSent AccountExists Theuseralreadyexists ThePhoneNumberIsWrong AnExceptionOccursWhenSendingAnSMSVerificationCode TokenIsFaild ThePasswordIsWrongOrThePhoneNumberIsIncorrect HasSend TheUserIsEmpty Repeat AddAppUserFail RegistrationFailed TheSystemCannotBeRegistered INSERTFAIL PleaseCheckTherRquiredFields TheParametersAreRepeated CAPISNOT ThereAreNoFeatures FINDFAIL LOGINFAIL NOTREGIST CollectionFAIL ) var MsgFlags = map[Rescode]string{ SUCCESS: "ok", ERROR: "fail", NOTTABLE: "该资源不存在", DELETEFAIL: "删除失败", TheUserAlreadyExists: "用户已存在", TheSystemIsAbnormal: "系统异常", CodeIsError: "验证码错误", UPDATEFAIL: "更新失败", Theuseralreadyexists: "用户已存在", JSONParsingFailed: "json解析失败", ThePhoneNumberIsWrong: "手机号格式错误", HasSend: "验证码已发送", AlreadyExists: "手机号已存在", AccountExists: "账号已存在", PaginationFailed: "分页查询失败", TheVerificationCodeWasNotSent: "验证码未发送", AnExceptionOccursWhenSendingAnSMSVerificationCode: "发送短信验证码出现异常", ThePasswordIsWrongOrThePhoneNumberIsIncorrect: "手机号或者密码错误", TokenIsInvalid: "Token 无效", TokenIsExpired: "Token 过期", TokenIsFaild: "Token 生成失败", TheUserIsEmpty: "用户为空", Repeat: "重复命名", AddAppUserFail: "添加用户失败", RegistrationFailed: "注册失败", TheSystemCannotBeRegistered: "该系统未开放注册", INSERTFAIL: "添加失败", PleaseCheckTherRquiredFields: "请检查必填项", TheParametersAreRepeated: "参数重复", CAPISNOT: "该功能不存在", ThereAreNoFeatures: "该系统未配置功能项,请前往添加", FINDFAIL: "查询失败", LOGINFAIL: "登录失败", NOTREGIST: "未注册请前往注册", CollectionFAIL: "收藏失败", } func (c Rescode) GetMsg() string { // 检查Rescode是否在MsgFlags中定义,避免返回意外的消息 msg, ok := MsgFlags[c] if ok { return msg } else { // 如果Rescode无效,则返回错误消息 return MsgFlags[ERROR] } }