-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.enumext.pb.go
148 lines (126 loc) · 2.87 KB
/
user.enumext.pb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package user
import (
errors "errors"
errcode "github.com/hopeio/protobuf/errcode"
log "github.com/hopeio/utils/log"
strings "github.com/hopeio/utils/strings"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
)
func (x Gender) String() string {
switch x {
case GenderPlaceholder:
return "占位"
case GenderUnfilled:
return "未填"
case GenderMale:
return "男"
case GenderFemale:
return "女"
}
return ""
}
func (x Gender) MarshalGQL(w io.Writer) {
w.Write(strings.QuoteToBytes(x.String()))
}
func (x *Gender) UnmarshalGQL(v interface{}) error {
if i, ok := v.(int32); ok {
*x = Gender(i)
return nil
}
return errors.New("enum need integer type")
}
func (x Role) String() string {
switch x {
case PlaceholderRole:
return "占位"
case RoleNormal:
return "普通用户"
case RoleAdmin:
return "管理员"
case RoleSuperAdmin:
return "超级管理员"
}
return ""
}
func (x Role) MarshalGQL(w io.Writer) {
w.Write(strings.QuoteToBytes(x.String()))
}
func (x *Role) UnmarshalGQL(v interface{}) error {
if i, ok := v.(int32); ok {
*x = Role(i)
return nil
}
return errors.New("enum need integer type")
}
func (x UserStatus) String() string {
switch x {
case UserStatusPlaceholder:
return "占位"
case UserStatusInActive:
return "未激活"
case UserStatusActivated:
return "已激活"
case UserStatusFrozen:
return "已冻结"
case UserStatusDeleted:
return "已注销"
}
return ""
}
func (x UserStatus) MarshalGQL(w io.Writer) {
w.Write(strings.QuoteToBytes(x.String()))
}
func (x *UserStatus) UnmarshalGQL(v interface{}) error {
if i, ok := v.(int32); ok {
*x = UserStatus(i)
return nil
}
return errors.New("enum need integer type")
}
func (x UserErr) String() string {
switch x {
case UserErrPlaceholder:
return "占位"
case UserErrLogin:
return "用户名或密码错误"
case UserErrNoActive:
return "未激活账号"
case UserErrNoAuthority:
return "无权限"
case UserErrLoginTimeout:
return "登录超时"
case UserErrInvalidToken:
return "Token错误"
case UserErrNoLogin:
return "未登录"
}
return ""
}
func (x UserErr) Error() string {
return x.String()
}
func (x UserErr) ErrRep() *errcode.ErrRep {
return &errcode.ErrRep{Code: errcode.ErrCode(x), Message: x.String()}
}
func (x UserErr) Message(msg string) error {
return &errcode.ErrRep{Code: errcode.ErrCode(x), Message: msg}
}
func (x UserErr) ErrorLog(err error) error {
log.Error(err)
return &errcode.ErrRep{Code: errcode.ErrCode(x), Message: x.String()}
}
func (x UserErr) GrpcStatus() *status.Status {
return status.New(codes.Code(x), x.String())
}
func (x UserErr) MarshalGQL(w io.Writer) {
w.Write(strings.QuoteToBytes(x.String()))
}
func (x *UserErr) UnmarshalGQL(v interface{}) error {
if i, ok := v.(int32); ok {
*x = UserErr(i)
return nil
}
return errors.New("enum need integer type")
}