-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.proto
157 lines (145 loc) · 5.68 KB
/
user.proto
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
149
150
151
152
153
154
155
156
157
syntax = "proto3";
package begonia.org.sdk;
option go_package = "github.com/begonia-org/go-sdk/api/v1";
import "google/protobuf/timestamp.proto";
import "begonia/api/v1/options.proto";
import "google/protobuf/field_mask.proto";
import "google/api/annotations.proto";
enum Role {
ADMIN = 0;
}
enum USER_STATUS {
ACTIVE = 0;
INACTIVE = 1;
LOCKED = 2;
DELETED = 3;
}
enum UserSvrCode{
USER_UNKNOWN = 0;
USER_LOGIN_ERR=4107[(.begonia.api.v1.msg) = "login fail"];
USER_TOKEN_EXPIRE_ERR=4108[(.begonia.api.v1.msg) = "token expire"];
USER_DISABLED_ERR=4119[(.begonia.api.v1.msg) = "user disabled"];
// 非法的token
USER_TOKEN_INVALIDATE_ERR=4109[(.begonia.api.v1.msg) = "invalidate token"];
USER_TOKEN_NOT_ACTIVTE_ERR=4114[(.begonia.api.v1.msg) = "invaildate token"];
USER_AUTH_DECRYPT_ERR=4110[(.begonia.api.v1.msg) = "invaildate token"];
USER_ACCOUNT_ERR=4111[(.begonia.api.v1.msg) = "username or password error"];
USER_PASSWORD_ERR=4112[(.begonia.api.v1.msg) = "username or password error"];
USER_NOT_FOUND_ERR=4113[(.begonia.api.v1.msg) = "username or password error"];
USER_AUTH_MISSING_ERR=4115[(.begonia.api.v1.msg) = "authorization header missing"];
USER_IDENTITY_MISSING_ERR=4116[(.begonia.api.v1.msg) = "identity missing"];
USER_APIKEY_NOT_MATCH_ERR=4117[(.begonia.api.v1.msg) = "apikey not match"];
USER_USERNAME_DUPLICATE_ERR=4118[(.begonia.api.v1.msg) = "username duplicate"];
}
message Users {
// @gotags: gorm:"primaryKey;autoIncrement;comment:自增id"
int64 ID = 1;
// @gotags: json:"uid" primary:"uid" gorm:"column:uid;type:varchar(36);not null;unique;comment:uid"
string uid = 2;
// @gotags: json:"group" owner:"owner" gorm:"column:group;type:varchar(36);comment:group"
string owner = 13;
// @gotags: json:"dept" gorm:"column:dept;type:varchar(36);comment:部门"
string dept = 14;
// @gotags: json:"name" ondeleted:"rename" gorm:"column:name;type:varchar(128);not null;unique;comment:username" aes:"true"
string name = 3;
// @gotags: json:"email" ondeleted:"rename" gorm:"column:email;type:varchar(128);not null;unique;comment:Users Email" aes:"true"
string email = 4;
// @gotags: doc:"phone number" ondeleted:"rename" gorm:"type:varchar(128);not null;unique;comment:Users Phone Number" aes:"true"
string phone = 5;
// @gotags: doc:"account password" gorm:"type:varchar(128);comment:Users account password" aes:"true"
string password = 6;
// @gotags: doc:"account avatar" gorm:"type:varchar(512);comment:Users account avatar"
string avatar = 7;
// @gotags: doc:"account role" gorm:"comment:Users account Role"
Role role = 8;
// @gotags: doc:"account status" gorm:"comment:Users account status"
USER_STATUS status = 9;
// @gotags: json:"tenant_id" gorm:"column:tenant_id;type:varchar(36);not null;comment:tenant_id"
string tenant_id=15[json_name="tenant_id"];
// @gotags: json:"is_deleted" gorm:"column:is_deleted;type:tinyint;comment:proto服务是否删除"
bool is_deleted=12 [json_name="is_deleted"];
// @gotags: doc:"完成时间" gorm:"column:created_at;type:datetime;serializer:timepb;comment:定时任务的最近一次完成时间"
google.protobuf.Timestamp created_at = 10[json_name="created_at"];
// @gotags: doc:"更新时间" gorm:"column:updated_at;type:datetime;serializer:timepb;comment:定时任务的更新时间"
google.protobuf.Timestamp updated_at = 11[json_name="updated_at"];
// @gotags: gorm:"-" json:"-"
google.protobuf.FieldMask update_mask = 18[json_name="update_mask"];
}
message BasicAuth{
string uid = 1;
string name = 2;
Role role =3;
string audience = 4;
string issuer = 5;
int64 not_before = 6 [json_name="nbf"];
int64 expiration = 7 [json_name="exp"];
int64 issued_at = 8 [json_name="iat"];
bool is_keep_login=9 [json_name="is_keep_login"];
string token = 10;
}
message PostUserRequest{
string name = 1;
string password = 2;
string email = 3;
string phone = 4;
Role role = 5;
USER_STATUS status = 6;
string dept = 7;
string owner = 8;
// @gotags: doc:"account avatar" gorm:"type:varchar(512);comment:Users account avatar"
string avatar = 9;
// @gotags: validate:"required"
string tenant_id=10[json_name="tenant_id"];
// @gotags: gorm:"-" json:"-"
google.protobuf.FieldMask update_mask = 18;
}
message GetUserRequest{
string uid=1;
}
message DeleteUserRequest{
string uid=1;
}
message DeleteUserResponse{
string uid=1;
}
message PatchUserRequest{
string uid=1[(.begonia.api.v1.un_updatable)=true];
string name = 2;
string password = 3;
string email = 4;
string phone = 5;
Role role = 6;
USER_STATUS status = 7;
string dept = 8;
string owner = 9;
// @gotags: doc:"account avatar" gorm:"type:varchar(512);comment:Users account avatar"
string avatar = 10;
// @gotags: gorm:"-" json:"-"
google.protobuf.FieldMask update_mask = 18;
}
service UserService{
option (.begonia.api.v1.auth_reqiured)=true;
option (.begonia.api.v1.http_response)="begonia.api.v1.HttpResponse";
rpc Register(PostUserRequest) returns (Users){
option (google.api.http)={
post:"/api/v1/users"
body:"*"
};
};
rpc Update(PatchUserRequest) returns (Users){
option (google.api.http)={
put:"/api/v1/users/{uid}"
body:"*"
};
};
rpc Get(GetUserRequest) returns (Users){
option (google.api.http)={
get:"/api/v1/users/{uid}"
};
};
rpc Delete(DeleteUserRequest) returns (DeleteUserResponse){
option (google.api.http)={
delete:"/api/v1/users/{uid}"
};
};
}