/
warehouse.go
241 lines (193 loc) · 6.93 KB
/
warehouse.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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package domain
import "google.golang.org/protobuf/runtime/protoimpl"
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// DeliveredStatus 待交付商品的状态
type DeliveredStatus int32
const (
DeliveredStatus_DECREASE DeliveredStatus = 0
DeliveredStatus_INCREASE DeliveredStatus = 1
DeliveredStatus_FROZEN DeliveredStatus = 2
DeliveredStatus_THAWED DeliveredStatus = 3
)
// Enum value maps for DeliveredStatus.
var (
DeliveredStatus_name = map[int32]string{
0: "DECREASE",
1: "INCREASE",
2: "FROZEN",
3: "THAWED",
}
DeliveredStatus_value = map[string]int32{
"DECREASE": 0,
"INCREASE": 1,
"FROZEN": 2,
"THAWED": 3,
}
)
// Advertisement 广告对象模型
type Advertisement struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
ProductId int64 `protobuf:"varint,2,opt,name=productId,proto3" json:"productId,omitempty"`
}
// Specification 商品规格
type Specification struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Item string `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
ProductId int64 `protobuf:"varint,3,opt,name=productId,proto3" json:"productId,omitempty"`
}
// Product 商品对象
type Product struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" valid:"required"`
Price float64 `protobuf:"fixed64,2,opt,name=price,proto3" json:"price,omitempty" valid:"required"`
Rate float32 `protobuf:"fixed32,3,opt,name=rate,proto3" json:"rate,omitempty" valid:"range(0|10)"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
Cover string `protobuf:"bytes,5,opt,name=cover,proto3" json:"cover,omitempty"`
Detail string `protobuf:"bytes,6,opt,name=detail,proto3" json:"detail,omitempty"`
Specifications []*Specification `protobuf:"bytes,7,rep,name=specifications,proto3" json:"specifications,omitempty"`
Id int64 `protobuf:"bytes,8,opt,name=id,proto3" json:"id,omitempty"`
}
// Stockpile 商品库存
type Stockpile struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Amount int64 `protobuf:"varint,1,opt,name=amount,proto3" json:"amount,omitempty"`
Frozen int64 `protobuf:"varint,2,opt,name=frozen,proto3" json:"frozen,omitempty"`
Product *Product `protobuf:"bytes,3,opt,name=product,proto3" json:"product,omitempty"`
}
type Empty struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
type GetAllAdvertisementsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Advertisements []*Advertisement `protobuf:"bytes,1,rep,name=advertisements,proto3" json:"advertisements,omitempty"`
}
type GetAllProductResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Products []*Product `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"`
}
type GetProductRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
type RemoveProductRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
type GetProductResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"`
}
type ChangeProductRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"`
}
type UpdateStockpileRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductId int64 `protobuf:"varint,1,opt,name=productId,proto3" json:"productId,omitempty"`
Amount int64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"`
}
type QueryStockpileRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductId int64 `protobuf:"varint,1,opt,name=productId,proto3" json:"productId,omitempty"`
}
type QueryStockpileResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Stockpile *Stockpile `protobuf:"bytes,1,opt,name=stockpile,proto3" json:"stockpile,omitempty"`
}
type SetDeliveredStatusRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductId int64 `protobuf:"varint,1,opt,name=productId,proto3" json:"productId,omitempty"`
Amount int64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"`
Status DeliveredStatus `protobuf:"varint,3,opt,name=status,proto3,enum=warehouse.DeliveredStatus" json:"status,omitempty"`
}
type QueryStockpileResult struct {
Success *QueryStockpileResponse
}
type GetAllAdvertisementsArgs struct {
Req *Empty
}
type GetAllAdvertisementsResult struct {
Success *GetAllAdvertisementsResponse
}
type GetAllProductsResult struct {
Success *GetAllProductResponse
}
type GetAllProductsArgs struct {
Req *Empty
}
type GetProductArgs struct {
Req *GetProductRequest
}
type GetProductResult struct {
Success *GetProductResponse
}
type CreateProductArgs struct {
Req *ChangeProductRequest
}
type CreateProductResult struct {
Success *Empty
}
type UpdateProductArgs struct {
Req *ChangeProductRequest
}
type QueryStockpileArgs struct {
Req *QueryStockpileRequest
}
type SetDeliveredStatusArgs struct {
Req *SetDeliveredStatusRequest
}
type SetDeliveredStatusResult struct {
Success *Empty
}
type RemoveProductArgs struct {
Req *RemoveProductRequest
}
type RemoveProductResult struct {
Success *Empty
}
type UpdateStockpileArgs struct {
Req *UpdateStockpileRequest
}
type UpdateStockpileResult struct {
Success *Empty
}
type UpdateProductResult struct {
Success *Empty
}