功能代码
This commit is contained in:
63
code.go
Normal file
63
code.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const (
|
||||
CodeSuccess = 0 // 成功
|
||||
CodeInternalServerError = 1 // 内部服务错误
|
||||
CodeUserNotExist = 2 // 用户不存在
|
||||
CodeUserExist = 3 // 用户存在
|
||||
CodeWrongPassword = 4 // 密码错误
|
||||
CodeNoLogIn = 5 // 未登录或非法访问
|
||||
CodeTokenExpired = 6 // token 过期
|
||||
CodeInvalidParam = 7 // 无效或未填参数
|
||||
CodePermissionAccess = 8 // 权限通过
|
||||
CodePermissionDenied = 9 // 权限拒绝
|
||||
CodeEmailExist = 10 // 邮箱已存在
|
||||
CodeAccountExist = 11 // 账号已存在
|
||||
CodePhoneExist = 12 // 电话号码已存在
|
||||
CodeEmailAccountPhoneNone = 13 // 邮箱、账号、电话不能都为空
|
||||
CodeParentIDShouldNotEqualID = 14 // 父节点的点不能等于自己的id
|
||||
CodeWrongOldPassword = 15 // 旧密码错误
|
||||
)
|
||||
|
||||
var (
|
||||
MsgSuccess = "成功"
|
||||
MsgInternalServerError = "内部服务错误"
|
||||
MsgUserNotExist = "用户不存在"
|
||||
MsgUserExist = "用户存在"
|
||||
MsgWrongPassword = "密码错误"
|
||||
MsgNoLogIn = "未登录或非法访问"
|
||||
MsgTokenExpired = "过期"
|
||||
MsgInvalidParam = "无效或未填参数"
|
||||
MsgPermissionAccess = "权限通过"
|
||||
MsgPermissionDenied = "权限拒绝"
|
||||
MsgEmailExist = "邮箱已存在"
|
||||
MsgAccountExist = "账号已存在"
|
||||
MsgPhoneExist = "电话号码已存在"
|
||||
MsgEmailAccountPhoneNone = "邮箱、账号、电话不能都为空"
|
||||
MsgParentIDShouldNotEqualID = "父节点的点不能等于自己的id"
|
||||
MsgWrongOldPassword = "旧密码错误"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrSuccess = status.Error(CodeSuccess, MsgSuccess)
|
||||
ErrInternalServerError = status.Error(CodeInternalServerError, MsgInternalServerError)
|
||||
ErrUserNotExist = status.Error(CodeUserNotExist, MsgUserNotExist)
|
||||
ErrUserExist = status.Error(CodeUserExist, MsgUserExist)
|
||||
ErrWrongPassword = status.Error(CodeWrongPassword, MsgWrongPassword)
|
||||
ErrNoLogIn = status.Error(CodeNoLogIn, MsgNoLogIn)
|
||||
ErrTokenExpired = status.Error(CodeTokenExpired, MsgTokenExpired)
|
||||
ErrInvalidParam = status.Error(CodeInvalidParam, MsgInvalidParam)
|
||||
ErrPermissionAccess = status.Error(CodePermissionAccess, MsgPermissionAccess)
|
||||
ErrPermissionDenied = status.Error(CodePermissionDenied, MsgPermissionDenied)
|
||||
ErrEmailExist = status.Error(CodeEmailExist, MsgEmailExist)
|
||||
ErrAccountExist = status.Error(CodeAccountExist, MsgAccountExist)
|
||||
ErrPhoneExist = status.Error(CodePhoneExist, MsgPhoneExist)
|
||||
ErrEmailAccountPhoneNone = status.Error(CodeEmailAccountPhoneNone, MsgEmailAccountPhoneNone)
|
||||
ErrParentIDShouldNotEqualID = status.Error(CodeParentIDShouldNotEqualID, MsgParentIDShouldNotEqualID)
|
||||
ErrWrongOldPassword = status.Error(CodeWrongOldPassword, MsgWrongOldPassword)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user