feat: product store

This commit is contained in:
zzw
2026-08-07 15:41:18 +08:00
parent 39fb09e7df
commit 089bdc9761
15 changed files with 1313 additions and 762 deletions
+77 -87
View File
@@ -3,25 +3,43 @@ syntax = "proto3";
package product;
option go_package="./product";
import "buf/validate/validate.proto";
import "google/api/annotations.proto";
service Product {
rpc Add(AddReq) returns (Response) {
rpc Create(CreateReq) returns (Response) {
option (google.api.http) = {
post: "/admin/v3/product"
post: "/admin/v3/product/create"
body: "*"
};
}
rpc Edit(EditReq) returns (Response) {
rpc Info(InfoReq) returns (Response) {
option (google.api.http) = {
put: "/admin/v3/product"
get: "/admin/v3/product/info"
body: "*"
};
}
rpc Items(ItemsReq) returns (Response) {
option (google.api.http) = {
get: "/admin/v3/product"
body: "*"
};
}
rpc Names(NamesReq) returns (Response) {
option (google.api.http) = {
get: "/admin/v3/product/names"
body: "*"
};
}
rpc Status(StatusReq) returns (Response) {
option (google.api.http) = {
put: "/admin/v3/product/status"
body: "*"
};
}
rpc Sort(SortReq) returns (Response) {
option (google.api.http) = {
put: "/admin/v3/product/sort"
body: "*"
};
}
}
@@ -32,16 +50,56 @@ message Response {
string data = 3;
}
message CreateReq {
string name = 1;
string subhead = 2;
string content = 3;
uint32 sales_model = 4;
string model_code = 5;
double price = 6;
double store_price = 7;
double sale_price = 8;
double share_price = 9;
double agent_price = 10;
string sale_reward = 11;
string images = 12;
double weight = 13;
string cubage = 14;
string waybill = 15;
int32 period_validity = 16;
uint32 norms_number = 17;
double box_number = 18;
uint32 type = 19;
uint32 number = 20;
uint32 try_number = 21;
string publish_time = 22;
string label = 23;
uint32 is_buy = 24;
uint32 is_index = 25;
string index_image = 26;
}
message InfoReq {
int64 id = 1;
}
message ItemsReq {
string name = 1 [(buf.validate.field).string = {max_len: 256}];
uint32 page = 2 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {gte: 1}
}];
uint32 page_size = 3 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {gte: 1, lte: 100}
}];
string name = 1;
uint32 page = 2;
uint32 page_size = 3;
}
message NamesReq {}
message StatusReq {
int64 id = 1;
uint32 status = 2;
string reason = 3;
}
message SortReq {
int64 id = 1;
uint32 sort = 2;
}
message ItemsData {
@@ -49,6 +107,11 @@ message ItemsData {
repeated Item items = 2;
}
message NameItem {
int64 id = 1;
string name = 2;
}
message Item {
int64 id = 1;
string name = 2;
@@ -87,76 +150,3 @@ message Item {
string admin_name = 35;
uint32 edit = 36;
}
message AddReq {
string name = 1 [(buf.validate.field).string = {min_len: 1, max_len: 256}];
string subhead = 2 [(buf.validate.field).string = {max_len: 255}];
string content = 3 [(buf.validate.field).string = {min_len: 1}];
uint32 sales_model = 4 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2]}
}];
string model_code = 5 [(buf.validate.field).string = {max_len: 255}];
double price = 6 [(buf.validate.field).double = {gte: 0}];
double store_price = 7 [(buf.validate.field) = {ignore: IGNORE_IF_ZERO_VALUE, double: {gte: 0}}];
double sale_price = 8 [(buf.validate.field).double = {gte: 0}];
double share_price = 9 [(buf.validate.field).double = {gte: 0}];
double agent_price = 10 [(buf.validate.field).double = {gte: 0}];
string sale_reward = 11 [(buf.validate.field).string = {max_len: 255}];
string images = 12 [(buf.validate.field).string = {min_len: 1, max_len: 512}];
double weight = 13 [(buf.validate.field).double = {gte: 0}];
string cubage = 14 [(buf.validate.field).string = {max_len: 255}];
string waybill = 15 [(buf.validate.field).string = {max_len: 255}];
int32 period_validity = 16 [(buf.validate.field).int32 = {gte: 0}];
uint32 norms_number = 17 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {gte: 1}
}];
double box_number = 18 [(buf.validate.field).double = {gte: 0}];
uint32 type = 19 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2, 3]}
}];
uint32 number = 20;
uint32 try_number = 21 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {gte: 1}
}];
string publish_time = 22 [(buf.validate.field).string = {max_len: 32}];
string label = 23 [(buf.validate.field).string = {max_len: 255}];
uint32 is_buy = 24 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2]}
}];
uint32 is_index = 25 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2]}
}];
string index_image = 26 [(buf.validate.field).string = {max_len: 255}];
// 删除字段方式
// reserved 2;
}
message EditReq {
int64 id = 1 [(buf.validate.field).int64 = {gt: 0}];
string name = 2 [(buf.validate.field).string = {min_len: 1, max_len: 256}];
string subhead = 3 [(buf.validate.field).string = {max_len: 255}];
string content = 4 [(buf.validate.field).string = {min_len: 1}];
string waybill = 5 [(buf.validate.field).string = {max_len: 255}];
float weight = 6 [(buf.validate.field).float = {gte: 0}];
string cubage = 7 [(buf.validate.field).string = {max_len: 255}];
string images = 8 [(buf.validate.field).string = {min_len: 1, max_len: 512}];
int32 period_validity = 9 [(buf.validate.field).int32 = {gte: 0}];
string publish_time = 10 [(buf.validate.field).string = {max_len: 32}];
string label = 11 [(buf.validate.field).string = {max_len: 255}];
uint32 is_buy = 12 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2]}
}];
uint32 is_index = 13 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE,
uint32: {in: [1, 2]}
}];
string index_image = 14 [(buf.validate.field).string = {max_len: 255}];
}