package errx import ( "git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code" "git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg" "net/http" ) // Common const ( StatusUnauthorized code.Code = http.StatusUnauthorized ) // Auth const ( WrongCode code.Code = iota + 1000 // 验证码错误 WrongPassword // 密码错误 UserNotFound // 用户不存在 NeedPhoneOrEmail // 请输入正确的手机号或邮箱 UnsupportedLoginType // 暂未支持此类型登录方式 JwtTokenGenerateErr // JwtToken生成失败 ProviderNotInit // 服务提供商未进行初始化 ) // User register const ( UsernameAlreadyExists code.Code = iota + 1100 // 用户名已注册 PasswordInvalidArgument // 密码格式错误 UserPhoneNumberAlreadyExists // 手机号码已被绑定 UserExists // 用户已存在 UserNicknameAlreadyExists // 用户昵称已存在 UserEmailAlreadyExists // 此邮箱已被注册 ) // User const ( UpdateUserMetaErr code.Code = iota + 1200 ) // Role const ( RoleCodeNotEmpty code.Code = iota + 1300 RoleCodeInUsed ) // OAuthProvider const ( OAuthProviderNameNotEmpty code.Code = iota + 1400 OAuthProviderNameInUsed ) // UserSocial const ( UserSocialUserIdNotEmpty code.Code = iota + 1500 ) // Dictionary const ( DictionaryNameNotEmpty code.Code = iota + 1600 DictionaryNameInUsed ) // DictionaryDetail const ( DictionaryDetailPIDNotEmpty code.Code = iota + 1700 DictionaryDetailKeyNotEmpty DictionaryDetailExists DictionaryDetailIdNotEmpty ) // Captcha const ( InvalidCaptchaErr code.Code = iota + 1800 CaptchaGenerateErr ) func init() { // Common msg.Add(StatusUnauthorized, "unauthorized") // Auth msg.Add(WrongCode, "auth.wrongCode") msg.Add(WrongPassword, "auth.wrongPassword") msg.Add(UserNotFound, "auth.userNotFound") msg.Add(NeedPhoneOrEmail, "auth.needPhoneOrEmail") msg.Add(UnsupportedLoginType, "auth.unsupportedLoginType") msg.Add(JwtTokenGenerateErr, "auth.jwtTokenGenerateErr") msg.Add(ProviderNotInit, "auth.providerNotInit") // User Register msg.Add(UsernameAlreadyExists, "register.user.usernameExists") msg.Add(PasswordInvalidArgument, "register.user.passwordInvalid") msg.Add(UserPhoneNumberAlreadyExists, "register.user.phoneNumberExists") msg.Add(UserExists, "register.user.exists") msg.Add(UserNicknameAlreadyExists, "register.user.nicknameExists") msg.Add(UserEmailAlreadyExists, "register.user.emailExists") // User msg.Add(UpdateUserMetaErr, "user.updateMetaErr") // Role msg.Add(RoleCodeNotEmpty, "role.codeNotEmpty") msg.Add(RoleCodeInUsed, "role.codeInUsed") // OAuthProvider msg.Add(OAuthProviderNameNotEmpty, "oauthProvider.nameNotEmpty") msg.Add(OAuthProviderNameInUsed, "oauthProvider.nameInUsed") // UserSocial msg.Add(UserSocialUserIdNotEmpty, "userSocial.userIdNotEmpty") // Dictionary msg.Add(DictionaryNameNotEmpty, "dictionary.nameNotEmpty") msg.Add(DictionaryNameInUsed, "dictionary.nameInUsed") // DictionaryDetail msg.Add(DictionaryDetailPIDNotEmpty, "dictionary.detail.pidNotEmpty") msg.Add(DictionaryDetailKeyNotEmpty, "dictionary.detail.keyNotEmpty") msg.Add(DictionaryDetailExists, "dictionary.detail.exists") msg.Add(DictionaryDetailIdNotEmpty, "dictionary.detail.idNotEmpty") // Captcha msg.Add(InvalidCaptchaErr, "captcha.invalid") msg.Add(CaptchaGenerateErr, "captcha.generateErr") }