-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtenant.proto
194 lines (181 loc) · 8.33 KB
/
tenant.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
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 TENANTS_STATUS {
TENANTS_ACTIVE = 0;
TENANTS_INACTIVE = 1;
TENANTS_LOCKED = 2;
TENANTS_DELETED = 3;
}
message Tenants {
// @gotags: json:"tenant_id" primary:"tenant_id" gorm:"primaryKey;column:tenant_id;type:varchar(36);not null;unique;comment:tenant_id"
string tenant_id=1[json_name="tenant_id"];
// @gotags: json:"tenant_name" gorm:"column:tenant_name;type:varchar(128);not null;unique;comment:tenant_name"
string tenant_name=2[json_name="tenant_name"];
// @gotags: json:"description" gorm:"column:description;type:text;comment:tenant描述"
string description=3;
// @gotags: gorm:"column:tags;type:json;serializer:json;comment:tags"
repeated string tags=4;
// @gotags: json:"status" gorm:"column:status;type:tinyint;comment:tenant服务状态"
TENANTS_STATUS status = 5;
// @gotags: json:"email" ondeleted:"rename" gorm:"column:email;type:varchar(128);not null;unique;comment:Users Email" aes:"true"
string email = 6;
// @gotags: json:"created_by" gorm:"column:created_by;type:varchar(36);not null;comment:创建者"
string created_by=7[json_name="created_by"];
// @gotags: json:"is_deleted" gorm:"column:is_deleted;type:tinyint;comment:proto服务是否删除"
bool is_deleted=12 [json_name="is_deleted"];
// @gotags: json:"admin_id" gorm:"column:admin_id;type:varchar(36);comment:关联管理员用户id"
string admin_id=13[json_name="admin_id"];
// @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 TenantsBusiness {
// @gotags: json:"tenant_id" primary:"tenant_id" gorm:"primaryKey;column:tenant_id;type:varchar(36);not null;comment:tenant_id"
string tenant_id=1[json_name="tenant_id"];
// @gotags: json:"tenant_name" gorm:"column:tenant_name;type:varchar(128);not null;comment:tenant_name"
string tenant_name=2[json_name="tenant_name"];
// @gotags: json:"business_id" primary:"business_id" gorm:"primaryKey;column:business_id;type:varchar(36);not null;comment:business_id"
string business_id=3[json_name="business_id"];
// @gotags: json:"business_name" gorm:"column:business_name;type:varchar(128);not null;comment:business_name"
string business_name=4[json_name="business_name"];
// @gotags: json:"plan" gorm:"column:plan;type:varchar(36);comment:plan"
string plan=5;
// @gotags: json:"created_by" gorm:"column:created_by;type:varchar(36);not null;comment:创建者"
string created_by=6[json_name="created_by"];
// @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 PostTenantRequest{
// @gotags: validate:"required" json:"tenant_name" gorm:"column:tenant_name;type:varchar(128);not null;unique;comment:business名称"
string tenant_name = 1[json_name="tenant_name"];
// @gotags: json:"description" gorm:"column:description;type:text;comment:business描述"
string description = 2;
// @gotags: json:"tags" gorm:"column:tags;type:json;comment:business服务标签"
repeated string tags = 3;
// @gotags: validate:"required" json:"email" gorm:"column:email;type:varchar(128);not null;unique;comment:Users Email" aes:"true"
string email = 4;
}
message PatchTenantRequest{
// @gotags: json:"tenant_name" gorm:"column:tenant_name;type:varchar(128);not null;unique;comment:business名称"
string tenant_name = 1[json_name="tenant_name"];
// @gotags: json:"description" gorm:"column:description;type:text;comment:business描述"
string description = 2;
// @gotags: json:"tags" gorm:"column:tags;type:json;comment:business服务标签"
repeated string tags = 3;
// @gotags: json:"email" gorm:"column:email;type:varchar(128);not null;unique;comment:Users Email" aes:"true"
string email = 4;
// @gotags: validate:"required" json:"tenant_id"
string tenant_id=5[json_name="tenant_id",(.begonia.api.v1.un_updatable)=true];
string admin_id=6[json_name="admin_id"];
TENANTS_STATUS status = 7;
google.protobuf.FieldMask update_mask = 18[json_name="update_mask"];
}
message GetTenantRequest{
// @gotags: validate:"required" json:"tenant_id"
string tenant=1[json_name="tenant"];
}
message DeleteTenantRequest{
// @gotags: validate:"required" json:"tenant"
string tenant=1[json_name="tenant"];
}
message DeleteTenantResponse{
}
message ListTenantsRequest{
repeated string tags = 1;
// @gotags: validate:"gte=1" doc:"每页数量"
int32 page = 2;
// @gotags: validate:"gte=1" doc:"每页数量"
int32 page_size = 3[json_name="page_size"];
repeated TENANTS_STATUS status=4;
}
message ListTenantsResponse{
repeated Tenants tenants = 1;
}
message AddTenantBusinessRequest{
// @gotags: validate:"required" json:"tenant_id"
string tenant_id=1[json_name="tenant_id"];
// @gotags: validate:"required" json:"business_id"
string business_id=2[json_name="business_id"];
// @gotags: validate:"required" json:"plan"
string plan=4;
}
message DeleteTenantBusinessRequest{
// @gotags: validate:"required" json:"tenant_id"
string tenant_id=1[json_name="tenant_id"];
// @gotags: validate:"required" json:"business_id"
string business_id=2[json_name="business_id"];
}
message DeleteTenantBusinessResponse{
}
message ListTenantBusinessRequest{
// @gotags: validate:"required" json:"tenant"
string tenant=1;
// @gotags: validate:"gte=1" doc:"每页数量"
int32 page = 2;
// @gotags: validate:"gte=1" doc:"每页数量"
int32 page_size = 3[json_name="page_size"];
}
message ListTenantBusinessResponse{
repeated TenantsBusiness tenants_business = 1;
}
service TenantsService{
option (.begonia.api.v1.auth_reqiured)=true;
option (.begonia.api.v1.http_response)="begonia.api.v1.HttpResponse";
rpc Register(PostTenantRequest) returns (Tenants){
option (google.api.http)={
post:"/api/v1/tenants"
body:"*"
};
};
rpc Update(PatchTenantRequest) returns (Tenants){
option (google.api.http)={
put:"/api/v1/tenants/{tenant_id}"
body:"*"
};
};
rpc Get(GetTenantRequest) returns (Tenants){
option (google.api.http)={
get:"/api/v1/tenants/{tenant}"
};
};
rpc Delete(DeleteTenantRequest) returns (DeleteTenantResponse){
option (google.api.http)={
delete:"/api/v1/tenants/{tenant}"
};
};
rpc List(ListTenantsRequest) returns (ListTenantsResponse){
option (google.api.http)={
get:"/api/v1/tenants"
};
};
rpc AddTenantBusiness(AddTenantBusinessRequest) returns (TenantsBusiness){
option (google.api.http)={
post:"/api/v1/tenants/business"
body:"*"
};
};
rpc ListTenantBusiness(ListTenantBusinessRequest) returns (ListTenantBusinessResponse){
option (google.api.http)={
get:"/api/v1/tenants/business/{tenant}"
};
};
rpc DeleteTenantBusiness(DeleteTenantBusinessRequest) returns (DeleteTenantBusinessResponse){
option (google.api.http)={
delete:"/api/v1/tenants/business/{tenant_id}/{business_id}"
};
};
}