From 72d55d396d1424e5c8c1fc452451aaca9dbf481a Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Wed, 26 Aug 2026 16:53:50 +0800 Subject: [PATCH] feat: product number --- pkg/rpcclient/client.go | 69 +++ rpc/chore/chore.pb | Bin 13919 -> 14061 bytes rpc/chore/chore.proto | 12 + rpc/chore/pb/chore.pb.go | 82 +++- rpc/chore/pb/chore_grpc.pb.go | 38 ++ rpc/product/pb/product.pb.go | 428 ++++++++++++------ rpc/product/pb/product_grpc.pb.go | 87 +++- rpc/product/product.pb | Bin 19011 -> 19471 bytes rpc/product/product.proto | 24 +- services/chore/choreclient/chore.go | 7 + services/chore/internal/logic/testLogic.go | 73 +++ services/chore/internal/server/choreServer.go | 5 + services/chore/internal/svc/servicecontext.go | 14 +- services/chore/run.toml | 27 +- services/order/internal/server/orderServer.go | 99 ---- services/product/internal/dao/product.go | 46 +- services/product/internal/logic/convert.go | 46 +- .../product/internal/logic/createlogic.go | 12 +- .../internal/logic/editApplyPassLogic.go | 31 ++ .../product/internal/logic/editapplylogic.go | 4 +- .../product/internal/logic/editbaselogic.go | 13 +- .../internal/logic/editsusceptiblelogic.go | 6 +- .../product/internal/logic/infoByIdLogic.go | 54 +++ services/product/internal/logic/infologic.go | 2 +- .../product/internal/logic/itemsByIdsLogic.go | 60 +++ services/product/internal/logic/itemslogic.go | 2 +- services/product/internal/logic/nameslogic.go | 2 +- .../product/internal/logic/numberAddLogic.go | 25 +- .../product/internal/logic/numberLogic.go | 34 +- services/product/internal/logic/sortlogic.go | 2 +- .../product/internal/logic/statuslogic.go | 4 +- .../internal/logic/verifyFirstLogic.go | 31 ++ .../internal/logic/verifySecondLogic.go | 31 ++ .../product/internal/logic/verifylogic.go | 4 +- .../internal/logic/verifystatuslogic.go | 10 +- .../product/internal/model/product_model.go | 4 +- .../product/internal/server/productserver.go | 40 +- services/product/productClient/product.go | 176 +++++++ services/product/validator/validator.go | 43 +- 39 files changed, 1284 insertions(+), 363 deletions(-) create mode 100644 pkg/rpcclient/client.go create mode 100644 services/chore/internal/logic/testLogic.go delete mode 100644 services/order/internal/server/orderServer.go create mode 100644 services/product/internal/logic/editApplyPassLogic.go create mode 100644 services/product/internal/logic/infoByIdLogic.go create mode 100644 services/product/internal/logic/itemsByIdsLogic.go create mode 100644 services/product/internal/logic/verifyFirstLogic.go create mode 100644 services/product/internal/logic/verifySecondLogic.go create mode 100644 services/product/productClient/product.go diff --git a/pkg/rpcclient/client.go b/pkg/rpcclient/client.go new file mode 100644 index 0000000..92c7b1e --- /dev/null +++ b/pkg/rpcclient/client.go @@ -0,0 +1,69 @@ +package rpcclient + +import ( + "fmt" + "net" + "strconv" + "sync" + "time" + + "lone-services/pkg/discovery" + "lone-services/pkg/utils" + + "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/zrpc" +) + +type cacheEntry struct { + cli zrpc.Client + target string + expireAt time.Time +} + +const cacheTTL = 30 * time.Second + +var ( + cacheLock sync.Mutex + cache = make(map[string]*cacheEntry) +) + +func Get(serviceName string) (zrpc.Client, error) { + if serviceName == utils.StringEmpty { + err := fmt.Errorf("rpc serviceName is empty") + logx.Error(err) + return nil, err + } + + cacheLock.Lock() + entry, ok := cache[serviceName] + if ok && time.Now().Before(entry.expireAt) { + cacheLock.Unlock() + return entry.cli, nil + } + delete(cache, serviceName) + cacheLock.Unlock() + + inst, err := discovery.Pick(serviceName) + if err != nil { + err = fmt.Errorf("discovery pick %s failed: %w", serviceName, err) + logx.Error(err) + return nil, err + } + + target := net.JoinHostPort(inst.IP, strconv.FormatUint(inst.Port, utils.NumberTen)) + + cli := zrpc.MustNewClient(zrpc.RpcClientConf{ + Target: target, + Timeout: utils.RpcTimeOut, + }) + + cacheLock.Lock() + cache[serviceName] = &cacheEntry{ + cli: cli, + target: target, + expireAt: time.Now().Add(cacheTTL), + } + cacheLock.Unlock() + + return cli, nil +} diff --git a/rpc/chore/chore.pb b/rpc/chore/chore.pb index 0a2e9f5ac40ba3001d6820c02f8beecf57fb4b19..896cfa54f6869d38738d9eae41e78fe36d11b0d7 100644 GIT binary patch delta 165 zcmcbg^EP*blPS|m=E*Lmb3K%tx!6Nei%Wu13x)W&m@-o&7!?>bSc8BpAptJt%#>mY zCIw~<<{%JLNQ{duuQWF)wMc>)sERiT$}?KXIQg+@q^pn{7YoQRAwIq2jQpZhJ*df2 s{7`;SYH>k+UU90DY}4f@lbOVog!B^&GWE-h^}*`(OMsduTbii>01vG&_W%F@ delta 25 hcmaExdp~D`lPS||rpYd*bD4}HCu^ETPCjL(3;>E-38Mf2 diff --git a/rpc/chore/chore.proto b/rpc/chore/chore.proto index 20f4c88..66de98d 100644 --- a/rpc/chore/chore.proto +++ b/rpc/chore/chore.proto @@ -11,6 +11,12 @@ service Chore { body: "*" }; } + rpc Test(TestReq) returns (Response) { + option (google.api.http) = { + post: "/api/v3/chore/test" + body: "*" + }; + } } message Response { @@ -21,4 +27,10 @@ message Response { message PolicyReq { string key = 1; +} + +message TestReq { + int32 id = 1; + repeated int64 ids = 2; + uint32 number = 3; } \ No newline at end of file diff --git a/rpc/chore/pb/chore.pb.go b/rpc/chore/pb/chore.pb.go index a8629a9..b688f13 100644 --- a/rpc/chore/pb/chore.pb.go +++ b/rpc/chore/pb/chore.pb.go @@ -126,6 +126,66 @@ func (x *PolicyReq) GetKey() string { return "" } +type TestReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Ids []int64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"ids,omitempty"` + Number uint32 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TestReq) Reset() { + *x = TestReq{} + mi := &file_chore_chore_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TestReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestReq) ProtoMessage() {} + +func (x *TestReq) ProtoReflect() protoreflect.Message { + mi := &file_chore_chore_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TestReq.ProtoReflect.Descriptor instead. +func (*TestReq) Descriptor() ([]byte, []int) { + return file_chore_chore_proto_rawDescGZIP(), []int{2} +} + +func (x *TestReq) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *TestReq) GetIds() []int64 { + if x != nil { + return x.Ids + } + return nil +} + +func (x *TestReq) GetNumber() uint32 { + if x != nil { + return x.Number + } + return 0 +} + var File_chore_chore_proto protoreflect.FileDescriptor const file_chore_chore_proto_rawDesc = "" + @@ -136,9 +196,14 @@ const file_chore_chore_proto_rawDesc = "" + "\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" + "\x04data\x18\x03 \x01(\tR\x04data\"\x1d\n" + "\tPolicyReq\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key2Y\n" + + "\x03key\x18\x01 \x01(\tR\x03key\"C\n" + + "\aTestReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x10\n" + + "\x03ids\x18\x02 \x03(\x03R\x03ids\x12\x16\n" + + "\x06number\x18\x03 \x01(\rR\x06number2\xa1\x01\n" + "\x05Chore\x12P\n" + - "\x06Policy\x12\x10.chore.PolicyReq\x1a\x0f.chore.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x12\x18/api/v3/chore/oss/policyB\x19Z\x17lone-services/rpc/choreb\x06proto3" + "\x06Policy\x12\x10.chore.PolicyReq\x1a\x0f.chore.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x12\x18/api/v3/chore/oss/policy\x12F\n" + + "\x04Test\x12\x0e.chore.TestReq\x1a\x0f.chore.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v3/chore/testB\x19Z\x17lone-services/rpc/choreb\x06proto3" var ( file_chore_chore_proto_rawDescOnce sync.Once @@ -152,16 +217,19 @@ func file_chore_chore_proto_rawDescGZIP() []byte { return file_chore_chore_proto_rawDescData } -var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_chore_chore_proto_goTypes = []any{ (*Response)(nil), // 0: chore.Response (*PolicyReq)(nil), // 1: chore.PolicyReq + (*TestReq)(nil), // 2: chore.TestReq } var file_chore_chore_proto_depIdxs = []int32{ 1, // 0: chore.Chore.Policy:input_type -> chore.PolicyReq - 0, // 1: chore.Chore.Policy:output_type -> chore.Response - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type + 2, // 1: chore.Chore.Test:input_type -> chore.TestReq + 0, // 2: chore.Chore.Policy:output_type -> chore.Response + 0, // 3: chore.Chore.Test:output_type -> chore.Response + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -178,7 +246,7 @@ func file_chore_chore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_chore_chore_proto_rawDesc), len(file_chore_chore_proto_rawDesc)), NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/chore/pb/chore_grpc.pb.go b/rpc/chore/pb/chore_grpc.pb.go index 43ebb1c..6b84e16 100644 --- a/rpc/chore/pb/chore_grpc.pb.go +++ b/rpc/chore/pb/chore_grpc.pb.go @@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( Chore_Policy_FullMethodName = "/chore.Chore/Policy" + Chore_Test_FullMethodName = "/chore.Chore/Test" ) // ChoreClient is the client API for Chore service. @@ -27,6 +28,7 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type ChoreClient interface { Policy(ctx context.Context, in *PolicyReq, opts ...grpc.CallOption) (*Response, error) + Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) } type choreClient struct { @@ -47,11 +49,22 @@ func (c *choreClient) Policy(ctx context.Context, in *PolicyReq, opts ...grpc.Ca return out, nil } +func (c *choreClient) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Chore_Test_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // ChoreServer is the server API for Chore service. // All implementations must embed UnimplementedChoreServer // for forward compatibility. type ChoreServer interface { Policy(context.Context, *PolicyReq) (*Response, error) + Test(context.Context, *TestReq) (*Response, error) mustEmbedUnimplementedChoreServer() } @@ -65,6 +78,9 @@ type UnimplementedChoreServer struct{} func (UnimplementedChoreServer) Policy(context.Context, *PolicyReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Policy not implemented") } +func (UnimplementedChoreServer) Test(context.Context, *TestReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Test not implemented") +} func (UnimplementedChoreServer) mustEmbedUnimplementedChoreServer() {} func (UnimplementedChoreServer) testEmbeddedByValue() {} @@ -104,6 +120,24 @@ func _Chore_Policy_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Chore_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TestReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChoreServer).Test(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Chore_Test_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChoreServer).Test(ctx, req.(*TestReq)) + } + return interceptor(ctx, in, info, handler) +} + // Chore_ServiceDesc is the grpc.ServiceDesc for Chore service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -115,6 +149,10 @@ var Chore_ServiceDesc = grpc.ServiceDesc{ MethodName: "Policy", Handler: _Chore_Policy_Handler, }, + { + MethodName: "Test", + Handler: _Chore_Test_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "chore/chore.proto", diff --git a/rpc/product/pb/product.pb.go b/rpc/product/pb/product.pb.go index c80636c..075acd7 100644 --- a/rpc/product/pb/product.pb.go +++ b/rpc/product/pb/product.pb.go @@ -10,6 +10,7 @@ import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -82,6 +83,138 @@ func (x *Response) GetData() string { return "" } +type InfoByIdReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InfoByIdReq) Reset() { + *x = InfoByIdReq{} + mi := &file_product_product_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InfoByIdReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoByIdReq) ProtoMessage() {} + +func (x *InfoByIdReq) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoByIdReq.ProtoReflect.Descriptor instead. +func (*InfoByIdReq) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{1} +} + +func (x *InfoByIdReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type ItemsByIdsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Ids []int64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ItemsByIdsReq) Reset() { + *x = ItemsByIdsReq{} + mi := &file_product_product_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ItemsByIdsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ItemsByIdsReq) ProtoMessage() {} + +func (x *ItemsByIdsReq) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ItemsByIdsReq.ProtoReflect.Descriptor instead. +func (*ItemsByIdsReq) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{2} +} + +func (x *ItemsByIdsReq) GetIds() []int64 { + if x != nil { + return x.Ids + } + return nil +} + +type ItemsByIdsData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Items []*Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ItemsByIdsData) Reset() { + *x = ItemsByIdsData{} + mi := &file_product_product_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ItemsByIdsData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ItemsByIdsData) ProtoMessage() {} + +func (x *ItemsByIdsData) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ItemsByIdsData.ProtoReflect.Descriptor instead. +func (*ItemsByIdsData) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{3} +} + +func (x *ItemsByIdsData) GetItems() []*Item { + if x != nil { + return x.Items + } + return nil +} + type CreateReq struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -95,7 +228,7 @@ type CreateReq struct { SharePrice float64 `protobuf:"fixed64,9,opt,name=share_price,json=sharePrice,proto3" json:"share_price,omitempty"` AgentPrice float64 `protobuf:"fixed64,10,opt,name=agent_price,json=agentPrice,proto3" json:"agent_price,omitempty"` SaleReward string `protobuf:"bytes,11,opt,name=sale_reward,json=saleReward,proto3" json:"sale_reward,omitempty"` - Images string `protobuf:"bytes,12,opt,name=images,proto3" json:"images,omitempty"` + Images []string `protobuf:"bytes,12,rep,name=images,proto3" json:"images,omitempty"` Weight float64 `protobuf:"fixed64,13,opt,name=weight,proto3" json:"weight,omitempty"` Cubage string `protobuf:"bytes,14,opt,name=cubage,proto3" json:"cubage,omitempty"` Waybill string `protobuf:"bytes,15,opt,name=waybill,proto3" json:"waybill,omitempty"` @@ -116,7 +249,7 @@ type CreateReq struct { func (x *CreateReq) Reset() { *x = CreateReq{} - mi := &file_product_product_proto_msgTypes[1] + mi := &file_product_product_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -128,7 +261,7 @@ func (x *CreateReq) String() string { func (*CreateReq) ProtoMessage() {} func (x *CreateReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[1] + mi := &file_product_product_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -141,7 +274,7 @@ func (x *CreateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateReq.ProtoReflect.Descriptor instead. func (*CreateReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{1} + return file_product_product_proto_rawDescGZIP(), []int{4} } func (x *CreateReq) GetName() string { @@ -221,11 +354,11 @@ func (x *CreateReq) GetSaleReward() string { return "" } -func (x *CreateReq) GetImages() string { +func (x *CreateReq) GetImages() []string { if x != nil { return x.Images } - return "" + return nil } func (x *CreateReq) GetWeight() float64 { @@ -335,7 +468,7 @@ type InfoReq struct { func (x *InfoReq) Reset() { *x = InfoReq{} - mi := &file_product_product_proto_msgTypes[2] + mi := &file_product_product_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -347,7 +480,7 @@ func (x *InfoReq) String() string { func (*InfoReq) ProtoMessage() {} func (x *InfoReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[2] + mi := &file_product_product_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -360,7 +493,7 @@ func (x *InfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use InfoReq.ProtoReflect.Descriptor instead. func (*InfoReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{2} + return file_product_product_proto_rawDescGZIP(), []int{5} } func (x *InfoReq) GetId() int64 { @@ -381,7 +514,7 @@ type ItemsReq struct { func (x *ItemsReq) Reset() { *x = ItemsReq{} - mi := &file_product_product_proto_msgTypes[3] + mi := &file_product_product_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -393,7 +526,7 @@ func (x *ItemsReq) String() string { func (*ItemsReq) ProtoMessage() {} func (x *ItemsReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[3] + mi := &file_product_product_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -406,7 +539,7 @@ func (x *ItemsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsReq.ProtoReflect.Descriptor instead. func (*ItemsReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{3} + return file_product_product_proto_rawDescGZIP(), []int{6} } func (x *ItemsReq) GetName() string { @@ -438,7 +571,7 @@ type NamesReq struct { func (x *NamesReq) Reset() { *x = NamesReq{} - mi := &file_product_product_proto_msgTypes[4] + mi := &file_product_product_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -450,7 +583,7 @@ func (x *NamesReq) String() string { func (*NamesReq) ProtoMessage() {} func (x *NamesReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[4] + mi := &file_product_product_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -463,7 +596,7 @@ func (x *NamesReq) ProtoReflect() protoreflect.Message { // Deprecated: Use NamesReq.ProtoReflect.Descriptor instead. func (*NamesReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{4} + return file_product_product_proto_rawDescGZIP(), []int{7} } type StatusReq struct { @@ -477,7 +610,7 @@ type StatusReq struct { func (x *StatusReq) Reset() { *x = StatusReq{} - mi := &file_product_product_proto_msgTypes[5] + mi := &file_product_product_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -489,7 +622,7 @@ func (x *StatusReq) String() string { func (*StatusReq) ProtoMessage() {} func (x *StatusReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[5] + mi := &file_product_product_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -502,7 +635,7 @@ func (x *StatusReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusReq.ProtoReflect.Descriptor instead. func (*StatusReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{5} + return file_product_product_proto_rawDescGZIP(), []int{8} } func (x *StatusReq) GetId() int64 { @@ -536,7 +669,7 @@ type SortReq struct { func (x *SortReq) Reset() { *x = SortReq{} - mi := &file_product_product_proto_msgTypes[6] + mi := &file_product_product_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -548,7 +681,7 @@ func (x *SortReq) String() string { func (*SortReq) ProtoMessage() {} func (x *SortReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[6] + mi := &file_product_product_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -561,7 +694,7 @@ func (x *SortReq) ProtoReflect() protoreflect.Message { // Deprecated: Use SortReq.ProtoReflect.Descriptor instead. func (*SortReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{6} + return file_product_product_proto_rawDescGZIP(), []int{9} } func (x *SortReq) GetId() int64 { @@ -590,7 +723,7 @@ type VerifyReq struct { func (x *VerifyReq) Reset() { *x = VerifyReq{} - mi := &file_product_product_proto_msgTypes[7] + mi := &file_product_product_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -602,7 +735,7 @@ func (x *VerifyReq) String() string { func (*VerifyReq) ProtoMessage() {} func (x *VerifyReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[7] + mi := &file_product_product_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -615,7 +748,7 @@ func (x *VerifyReq) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyReq.ProtoReflect.Descriptor instead. func (*VerifyReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{7} + return file_product_product_proto_rawDescGZIP(), []int{10} } func (x *VerifyReq) GetStatus() uint32 { @@ -651,7 +784,7 @@ type VerifyStatusReq struct { func (x *VerifyStatusReq) Reset() { *x = VerifyStatusReq{} - mi := &file_product_product_proto_msgTypes[8] + mi := &file_product_product_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -663,7 +796,7 @@ func (x *VerifyStatusReq) String() string { func (*VerifyStatusReq) ProtoMessage() {} func (x *VerifyStatusReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[8] + mi := &file_product_product_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -676,7 +809,7 @@ func (x *VerifyStatusReq) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyStatusReq.ProtoReflect.Descriptor instead. func (*VerifyStatusReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{8} + return file_product_product_proto_rawDescGZIP(), []int{11} } func (x *VerifyStatusReq) GetId() int64 { @@ -710,7 +843,7 @@ type EditApplyReq struct { func (x *EditApplyReq) Reset() { *x = EditApplyReq{} - mi := &file_product_product_proto_msgTypes[9] + mi := &file_product_product_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -722,7 +855,7 @@ func (x *EditApplyReq) String() string { func (*EditApplyReq) ProtoMessage() {} func (x *EditApplyReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[9] + mi := &file_product_product_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -735,7 +868,7 @@ func (x *EditApplyReq) ProtoReflect() protoreflect.Message { // Deprecated: Use EditApplyReq.ProtoReflect.Descriptor instead. func (*EditApplyReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{9} + return file_product_product_proto_rawDescGZIP(), []int{12} } func (x *EditApplyReq) GetId() int64 { @@ -762,7 +895,7 @@ type EditApplyPassReq struct { func (x *EditApplyPassReq) Reset() { *x = EditApplyPassReq{} - mi := &file_product_product_proto_msgTypes[10] + mi := &file_product_product_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -774,7 +907,7 @@ func (x *EditApplyPassReq) String() string { func (*EditApplyPassReq) ProtoMessage() {} func (x *EditApplyPassReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[10] + mi := &file_product_product_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -787,7 +920,7 @@ func (x *EditApplyPassReq) ProtoReflect() protoreflect.Message { // Deprecated: Use EditApplyPassReq.ProtoReflect.Descriptor instead. func (*EditApplyPassReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{10} + return file_product_product_proto_rawDescGZIP(), []int{13} } func (x *EditApplyPassReq) GetId() int64 { @@ -806,7 +939,7 @@ type EditBaseReq struct { Waybill string `protobuf:"bytes,5,opt,name=waybill,proto3" json:"waybill,omitempty"` Weight float64 `protobuf:"fixed64,6,opt,name=weight,proto3" json:"weight,omitempty"` Cubage string `protobuf:"bytes,7,opt,name=cubage,proto3" json:"cubage,omitempty"` - Images string `protobuf:"bytes,8,opt,name=images,proto3" json:"images,omitempty"` + Images []string `protobuf:"bytes,8,rep,name=images,proto3" json:"images,omitempty"` PeriodValidity int32 `protobuf:"varint,9,opt,name=period_validity,json=periodValidity,proto3" json:"period_validity,omitempty"` PublishTime string `protobuf:"bytes,10,opt,name=publish_time,json=publishTime,proto3" json:"publish_time,omitempty"` Label string `protobuf:"bytes,11,opt,name=label,proto3" json:"label,omitempty"` @@ -819,7 +952,7 @@ type EditBaseReq struct { func (x *EditBaseReq) Reset() { *x = EditBaseReq{} - mi := &file_product_product_proto_msgTypes[11] + mi := &file_product_product_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -831,7 +964,7 @@ func (x *EditBaseReq) String() string { func (*EditBaseReq) ProtoMessage() {} func (x *EditBaseReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[11] + mi := &file_product_product_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -844,7 +977,7 @@ func (x *EditBaseReq) ProtoReflect() protoreflect.Message { // Deprecated: Use EditBaseReq.ProtoReflect.Descriptor instead. func (*EditBaseReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{11} + return file_product_product_proto_rawDescGZIP(), []int{14} } func (x *EditBaseReq) GetId() int64 { @@ -896,11 +1029,11 @@ func (x *EditBaseReq) GetCubage() string { return "" } -func (x *EditBaseReq) GetImages() string { +func (x *EditBaseReq) GetImages() []string { if x != nil { return x.Images } - return "" + return nil } func (x *EditBaseReq) GetPeriodValidity() int32 { @@ -964,7 +1097,7 @@ type EditSusceptibleReq struct { func (x *EditSusceptibleReq) Reset() { *x = EditSusceptibleReq{} - mi := &file_product_product_proto_msgTypes[12] + mi := &file_product_product_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -976,7 +1109,7 @@ func (x *EditSusceptibleReq) String() string { func (*EditSusceptibleReq) ProtoMessage() {} func (x *EditSusceptibleReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[12] + mi := &file_product_product_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -989,7 +1122,7 @@ func (x *EditSusceptibleReq) ProtoReflect() protoreflect.Message { // Deprecated: Use EditSusceptibleReq.ProtoReflect.Descriptor instead. func (*EditSusceptibleReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{12} + return file_product_product_proto_rawDescGZIP(), []int{15} } func (x *EditSusceptibleReq) GetId() int64 { @@ -1081,7 +1214,7 @@ type NumberReq struct { func (x *NumberReq) Reset() { *x = NumberReq{} - mi := &file_product_product_proto_msgTypes[13] + mi := &file_product_product_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1093,7 +1226,7 @@ func (x *NumberReq) String() string { func (*NumberReq) ProtoMessage() {} func (x *NumberReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[13] + mi := &file_product_product_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1106,7 +1239,7 @@ func (x *NumberReq) ProtoReflect() protoreflect.Message { // Deprecated: Use NumberReq.ProtoReflect.Descriptor instead. func (*NumberReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{13} + return file_product_product_proto_rawDescGZIP(), []int{16} } func (x *NumberReq) GetId() int64 { @@ -1140,7 +1273,7 @@ type NumberAddReq struct { func (x *NumberAddReq) Reset() { *x = NumberAddReq{} - mi := &file_product_product_proto_msgTypes[14] + mi := &file_product_product_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1152,7 +1285,7 @@ func (x *NumberAddReq) String() string { func (*NumberAddReq) ProtoMessage() {} func (x *NumberAddReq) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[14] + mi := &file_product_product_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1165,7 +1298,7 @@ func (x *NumberAddReq) ProtoReflect() protoreflect.Message { // Deprecated: Use NumberAddReq.ProtoReflect.Descriptor instead. func (*NumberAddReq) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{14} + return file_product_product_proto_rawDescGZIP(), []int{17} } func (x *NumberAddReq) GetId() int64 { @@ -1192,7 +1325,7 @@ type ItemsData struct { func (x *ItemsData) Reset() { *x = ItemsData{} - mi := &file_product_product_proto_msgTypes[15] + mi := &file_product_product_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1204,7 +1337,7 @@ func (x *ItemsData) String() string { func (*ItemsData) ProtoMessage() {} func (x *ItemsData) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[15] + mi := &file_product_product_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1217,7 +1350,7 @@ func (x *ItemsData) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsData.ProtoReflect.Descriptor instead. func (*ItemsData) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{15} + return file_product_product_proto_rawDescGZIP(), []int{18} } func (x *ItemsData) GetCount() int64 { @@ -1244,7 +1377,7 @@ type VerifyItemsData struct { func (x *VerifyItemsData) Reset() { *x = VerifyItemsData{} - mi := &file_product_product_proto_msgTypes[16] + mi := &file_product_product_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1256,7 +1389,7 @@ func (x *VerifyItemsData) String() string { func (*VerifyItemsData) ProtoMessage() {} func (x *VerifyItemsData) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[16] + mi := &file_product_product_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1269,7 +1402,7 @@ func (x *VerifyItemsData) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyItemsData.ProtoReflect.Descriptor instead. func (*VerifyItemsData) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{16} + return file_product_product_proto_rawDescGZIP(), []int{19} } func (x *VerifyItemsData) GetCount() int64 { @@ -1306,7 +1439,7 @@ type VerifyParams struct { func (x *VerifyParams) Reset() { *x = VerifyParams{} - mi := &file_product_product_proto_msgTypes[17] + mi := &file_product_product_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1318,7 +1451,7 @@ func (x *VerifyParams) String() string { func (*VerifyParams) ProtoMessage() {} func (x *VerifyParams) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[17] + mi := &file_product_product_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1331,7 +1464,7 @@ func (x *VerifyParams) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyParams.ProtoReflect.Descriptor instead. func (*VerifyParams) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{17} + return file_product_product_proto_rawDescGZIP(), []int{20} } func (x *VerifyParams) GetId() int64 { @@ -1430,7 +1563,7 @@ type VerifyItem struct { func (x *VerifyItem) Reset() { *x = VerifyItem{} - mi := &file_product_product_proto_msgTypes[18] + mi := &file_product_product_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1442,7 +1575,7 @@ func (x *VerifyItem) String() string { func (*VerifyItem) ProtoMessage() {} func (x *VerifyItem) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[18] + mi := &file_product_product_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1455,7 +1588,7 @@ func (x *VerifyItem) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyItem.ProtoReflect.Descriptor instead. func (*VerifyItem) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{18} + return file_product_product_proto_rawDescGZIP(), []int{21} } func (x *VerifyItem) GetName() string { @@ -1496,7 +1629,7 @@ type NameItem struct { func (x *NameItem) Reset() { *x = NameItem{} - mi := &file_product_product_proto_msgTypes[19] + mi := &file_product_product_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1508,7 +1641,7 @@ func (x *NameItem) String() string { func (*NameItem) ProtoMessage() {} func (x *NameItem) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[19] + mi := &file_product_product_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1521,7 +1654,7 @@ func (x *NameItem) ProtoReflect() protoreflect.Message { // Deprecated: Use NameItem.ProtoReflect.Descriptor instead. func (*NameItem) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{19} + return file_product_product_proto_rawDescGZIP(), []int{22} } func (x *NameItem) GetId() int64 { @@ -1559,7 +1692,7 @@ type Item struct { IndexImage string `protobuf:"bytes,17,opt,name=index_image,json=indexImage,proto3" json:"index_image,omitempty"` Cubage string `protobuf:"bytes,18,opt,name=cubage,proto3" json:"cubage,omitempty"` Label string `protobuf:"bytes,19,opt,name=label,proto3" json:"label,omitempty"` - Images string `protobuf:"bytes,20,opt,name=images,proto3" json:"images,omitempty"` + Images []string `protobuf:"bytes,20,rep,name=images,proto3" json:"images,omitempty"` IsBuy uint32 `protobuf:"varint,21,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` PeriodValidity int32 `protobuf:"varint,22,opt,name=period_validity,json=periodValidity,proto3" json:"period_validity,omitempty"` PublishTime string `protobuf:"bytes,23,opt,name=publish_time,json=publishTime,proto3" json:"publish_time,omitempty"` @@ -1582,7 +1715,7 @@ type Item struct { func (x *Item) Reset() { *x = Item{} - mi := &file_product_product_proto_msgTypes[20] + mi := &file_product_product_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1594,7 +1727,7 @@ func (x *Item) String() string { func (*Item) ProtoMessage() {} func (x *Item) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[20] + mi := &file_product_product_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1607,7 +1740,7 @@ func (x *Item) ProtoReflect() protoreflect.Message { // Deprecated: Use Item.ProtoReflect.Descriptor instead. func (*Item) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{20} + return file_product_product_proto_rawDescGZIP(), []int{23} } func (x *Item) GetId() int64 { @@ -1743,11 +1876,11 @@ func (x *Item) GetLabel() string { return "" } -func (x *Item) GetImages() string { +func (x *Item) GetImages() []string { if x != nil { return x.Images } - return "" + return nil } func (x *Item) GetIsBuy() uint32 { @@ -1866,11 +1999,17 @@ var File_product_product_proto protoreflect.FileDescriptor const file_product_product_proto_rawDesc = "" + "\n" + - "\x15product/product.proto\x12\aproduct\x1a\x1cgoogle/api/annotations.proto\"D\n" + + "\x15product/product.proto\x12\aproduct\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"D\n" + "\bResponse\x12\x12\n" + "\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" + "\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xf0\x05\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\x1d\n" + + "\vInfoByIdReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"!\n" + + "\rItemsByIdsReq\x12\x10\n" + + "\x03ids\x18\x01 \x03(\x03R\x03ids\"5\n" + + "\x0eItemsByIdsData\x12#\n" + + "\x05items\x18\x01 \x03(\v2\r.product.ItemR\x05items\"\xf0\x05\n" + "\tCreateReq\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\asubhead\x18\x02 \x01(\tR\asubhead\x12\x18\n" + @@ -1891,7 +2030,7 @@ const file_product_product_proto_rawDesc = "" + "agentPrice\x12\x1f\n" + "\vsale_reward\x18\v \x01(\tR\n" + "saleReward\x12\x16\n" + - "\x06images\x18\f \x01(\tR\x06images\x12\x16\n" + + "\x06images\x18\f \x03(\tR\x06images\x12\x16\n" + "\x06weight\x18\r \x01(\x01R\x06weight\x12\x16\n" + "\x06cubage\x18\x0e \x01(\tR\x06cubage\x12\x18\n" + "\awaybill\x18\x0f \x01(\tR\awaybill\x12'\n" + @@ -1945,7 +2084,7 @@ const file_product_product_proto_rawDesc = "" + "\awaybill\x18\x05 \x01(\tR\awaybill\x12\x16\n" + "\x06weight\x18\x06 \x01(\x01R\x06weight\x12\x16\n" + "\x06cubage\x18\a \x01(\tR\x06cubage\x12\x16\n" + - "\x06images\x18\b \x01(\tR\x06images\x12'\n" + + "\x06images\x18\b \x03(\tR\x06images\x12'\n" + "\x0fperiod_validity\x18\t \x01(\x05R\x0eperiodValidity\x12!\n" + "\fpublish_time\x18\n" + " \x01(\tR\vpublishTime\x12\x14\n" + @@ -2047,7 +2186,7 @@ const file_product_product_proto_rawDesc = "" + "indexImage\x12\x16\n" + "\x06cubage\x18\x12 \x01(\tR\x06cubage\x12\x14\n" + "\x05label\x18\x13 \x01(\tR\x05label\x12\x16\n" + - "\x06images\x18\x14 \x01(\tR\x06images\x12\x15\n" + + "\x06images\x18\x14 \x03(\tR\x06images\x12\x15\n" + "\x06is_buy\x18\x15 \x01(\rR\x05isBuy\x12'\n" + "\x0fperiod_validity\x18\x16 \x01(\x05R\x0eperiodValidity\x12!\n" + "\fpublish_time\x18\x17 \x01(\tR\vpublishTime\x12\x12\n" + @@ -2066,8 +2205,7 @@ const file_product_product_proto_rawDesc = "" + "\x06reason\x18\" \x01(\tR\x06reason\x12\x1d\n" + "\n" + "admin_name\x18# \x01(\tR\tadminName\x12\x12\n" + - "\x04edit\x18$ \x01(\rR\x04edit2\xb3\n" + - "\n" + + "\x04edit\x18$ \x01(\rR\x04edit2\xa8\v\n" + "\aProduct\x12M\n" + "\x06Create\x12\x12.product.CreateReq\x1a\x11.product.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/admin/v3/product\x12N\n" + "\x04Info\x12\x10.product.InfoReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x12\x16/admin/v3/product/info\x12K\n" + @@ -2081,8 +2219,11 @@ const file_product_product_proto_rawDesc = "" + "\tEditApply\x12\x15.product.EditApplyReq\x1a\x11.product.Response\"'\x82\xd3\xe4\x93\x02!:\x01*\"\x1c/admin/v3/product/edit/apply\x12V\n" + "\bEditBase\x12\x14.product.EditBaseReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/admin/v3/product/base\x12k\n" + "\x0fEditSusceptible\x12\x1b.product.EditSusceptibleReq\x1a\x11.product.Response\"(\x82\xd3\xe4\x93\x02\":\x01*\x1a\x1d/admin/v3/product/susceptible\x12k\n" + - "\rEditApplyPass\x12\x19.product.EditApplyPassReq\x1a\x11.product.Response\",\x82\xd3\xe4\x93\x02&:\x01*\x1a!/admin/v3/product/edit/apply/pass\x12/\n" + - "\x06Number\x12\x12.product.NumberReq\x1a\x11.product.Response\x12Z\n" + + "\rEditApplyPass\x12\x19.product.EditApplyPassReq\x1a\x11.product.Response\",\x82\xd3\xe4\x93\x02&:\x01*\x1a!/admin/v3/product/edit/apply/pass\x124\n" + + "\x06Number\x12\x12.product.NumberReq\x1a\x16.google.protobuf.Empty\x12/\n" + + "\bInfoById\x12\x14.product.InfoByIdReq\x1a\r.product.Item\x12=\n" + + "\n" + + "ItemsByIds\x12\x16.product.ItemsByIdsReq\x1a\x17.product.ItemsByIdsData\x12Z\n" + "\tNumberAdd\x12\x15.product.NumberAddReq\x1a\x11.product.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x1a\x18/admin/v3/product/numberB\x1bZ\x19lone-services/rpc/productb\x06proto3" var ( @@ -2097,70 +2238,79 @@ func file_product_product_proto_rawDescGZIP() []byte { return file_product_product_proto_rawDescData } -var file_product_product_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_product_product_proto_msgTypes = make([]protoimpl.MessageInfo, 24) var file_product_product_proto_goTypes = []any{ (*Response)(nil), // 0: product.Response - (*CreateReq)(nil), // 1: product.CreateReq - (*InfoReq)(nil), // 2: product.InfoReq - (*ItemsReq)(nil), // 3: product.ItemsReq - (*NamesReq)(nil), // 4: product.NamesReq - (*StatusReq)(nil), // 5: product.StatusReq - (*SortReq)(nil), // 6: product.SortReq - (*VerifyReq)(nil), // 7: product.VerifyReq - (*VerifyStatusReq)(nil), // 8: product.VerifyStatusReq - (*EditApplyReq)(nil), // 9: product.EditApplyReq - (*EditApplyPassReq)(nil), // 10: product.EditApplyPassReq - (*EditBaseReq)(nil), // 11: product.EditBaseReq - (*EditSusceptibleReq)(nil), // 12: product.EditSusceptibleReq - (*NumberReq)(nil), // 13: product.NumberReq - (*NumberAddReq)(nil), // 14: product.NumberAddReq - (*ItemsData)(nil), // 15: product.ItemsData - (*VerifyItemsData)(nil), // 16: product.VerifyItemsData - (*VerifyParams)(nil), // 17: product.VerifyParams - (*VerifyItem)(nil), // 18: product.VerifyItem - (*NameItem)(nil), // 19: product.NameItem - (*Item)(nil), // 20: product.Item + (*InfoByIdReq)(nil), // 1: product.InfoByIdReq + (*ItemsByIdsReq)(nil), // 2: product.ItemsByIdsReq + (*ItemsByIdsData)(nil), // 3: product.ItemsByIdsData + (*CreateReq)(nil), // 4: product.CreateReq + (*InfoReq)(nil), // 5: product.InfoReq + (*ItemsReq)(nil), // 6: product.ItemsReq + (*NamesReq)(nil), // 7: product.NamesReq + (*StatusReq)(nil), // 8: product.StatusReq + (*SortReq)(nil), // 9: product.SortReq + (*VerifyReq)(nil), // 10: product.VerifyReq + (*VerifyStatusReq)(nil), // 11: product.VerifyStatusReq + (*EditApplyReq)(nil), // 12: product.EditApplyReq + (*EditApplyPassReq)(nil), // 13: product.EditApplyPassReq + (*EditBaseReq)(nil), // 14: product.EditBaseReq + (*EditSusceptibleReq)(nil), // 15: product.EditSusceptibleReq + (*NumberReq)(nil), // 16: product.NumberReq + (*NumberAddReq)(nil), // 17: product.NumberAddReq + (*ItemsData)(nil), // 18: product.ItemsData + (*VerifyItemsData)(nil), // 19: product.VerifyItemsData + (*VerifyParams)(nil), // 20: product.VerifyParams + (*VerifyItem)(nil), // 21: product.VerifyItem + (*NameItem)(nil), // 22: product.NameItem + (*Item)(nil), // 23: product.Item + (*emptypb.Empty)(nil), // 24: google.protobuf.Empty } var file_product_product_proto_depIdxs = []int32{ - 20, // 0: product.ItemsData.items:type_name -> product.Item - 18, // 1: product.VerifyItemsData.items:type_name -> product.VerifyItem - 17, // 2: product.VerifyItem.new:type_name -> product.VerifyParams - 17, // 3: product.VerifyItem.old:type_name -> product.VerifyParams - 1, // 4: product.Product.Create:input_type -> product.CreateReq - 2, // 5: product.Product.Info:input_type -> product.InfoReq - 3, // 6: product.Product.Items:input_type -> product.ItemsReq - 4, // 7: product.Product.Names:input_type -> product.NamesReq - 5, // 8: product.Product.Status:input_type -> product.StatusReq - 6, // 9: product.Product.Sort:input_type -> product.SortReq - 7, // 10: product.Product.Verify:input_type -> product.VerifyReq - 8, // 11: product.Product.VerifyFirst:input_type -> product.VerifyStatusReq - 8, // 12: product.Product.VerifySecond:input_type -> product.VerifyStatusReq - 9, // 13: product.Product.EditApply:input_type -> product.EditApplyReq - 11, // 14: product.Product.EditBase:input_type -> product.EditBaseReq - 12, // 15: product.Product.EditSusceptible:input_type -> product.EditSusceptibleReq - 10, // 16: product.Product.EditApplyPass:input_type -> product.EditApplyPassReq - 13, // 17: product.Product.Number:input_type -> product.NumberReq - 14, // 18: product.Product.NumberAdd:input_type -> product.NumberAddReq - 0, // 19: product.Product.Create:output_type -> product.Response - 0, // 20: product.Product.Info:output_type -> product.Response - 0, // 21: product.Product.Items:output_type -> product.Response - 0, // 22: product.Product.Names:output_type -> product.Response - 0, // 23: product.Product.Status:output_type -> product.Response - 0, // 24: product.Product.Sort:output_type -> product.Response - 0, // 25: product.Product.Verify:output_type -> product.Response - 0, // 26: product.Product.VerifyFirst:output_type -> product.Response - 0, // 27: product.Product.VerifySecond:output_type -> product.Response - 0, // 28: product.Product.EditApply:output_type -> product.Response - 0, // 29: product.Product.EditBase:output_type -> product.Response - 0, // 30: product.Product.EditSusceptible:output_type -> product.Response - 0, // 31: product.Product.EditApplyPass:output_type -> product.Response - 0, // 32: product.Product.Number:output_type -> product.Response - 0, // 33: product.Product.NumberAdd:output_type -> product.Response - 19, // [19:34] is the sub-list for method output_type - 4, // [4:19] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 23, // 0: product.ItemsByIdsData.items:type_name -> product.Item + 23, // 1: product.ItemsData.items:type_name -> product.Item + 21, // 2: product.VerifyItemsData.items:type_name -> product.VerifyItem + 20, // 3: product.VerifyItem.new:type_name -> product.VerifyParams + 20, // 4: product.VerifyItem.old:type_name -> product.VerifyParams + 4, // 5: product.Product.Create:input_type -> product.CreateReq + 5, // 6: product.Product.Info:input_type -> product.InfoReq + 6, // 7: product.Product.Items:input_type -> product.ItemsReq + 7, // 8: product.Product.Names:input_type -> product.NamesReq + 8, // 9: product.Product.Status:input_type -> product.StatusReq + 9, // 10: product.Product.Sort:input_type -> product.SortReq + 10, // 11: product.Product.Verify:input_type -> product.VerifyReq + 11, // 12: product.Product.VerifyFirst:input_type -> product.VerifyStatusReq + 11, // 13: product.Product.VerifySecond:input_type -> product.VerifyStatusReq + 12, // 14: product.Product.EditApply:input_type -> product.EditApplyReq + 14, // 15: product.Product.EditBase:input_type -> product.EditBaseReq + 15, // 16: product.Product.EditSusceptible:input_type -> product.EditSusceptibleReq + 13, // 17: product.Product.EditApplyPass:input_type -> product.EditApplyPassReq + 16, // 18: product.Product.Number:input_type -> product.NumberReq + 1, // 19: product.Product.InfoById:input_type -> product.InfoByIdReq + 2, // 20: product.Product.ItemsByIds:input_type -> product.ItemsByIdsReq + 17, // 21: product.Product.NumberAdd:input_type -> product.NumberAddReq + 0, // 22: product.Product.Create:output_type -> product.Response + 0, // 23: product.Product.Info:output_type -> product.Response + 0, // 24: product.Product.Items:output_type -> product.Response + 0, // 25: product.Product.Names:output_type -> product.Response + 0, // 26: product.Product.Status:output_type -> product.Response + 0, // 27: product.Product.Sort:output_type -> product.Response + 0, // 28: product.Product.Verify:output_type -> product.Response + 0, // 29: product.Product.VerifyFirst:output_type -> product.Response + 0, // 30: product.Product.VerifySecond:output_type -> product.Response + 0, // 31: product.Product.EditApply:output_type -> product.Response + 0, // 32: product.Product.EditBase:output_type -> product.Response + 0, // 33: product.Product.EditSusceptible:output_type -> product.Response + 0, // 34: product.Product.EditApplyPass:output_type -> product.Response + 24, // 35: product.Product.Number:output_type -> google.protobuf.Empty + 23, // 36: product.Product.InfoById:output_type -> product.Item + 3, // 37: product.Product.ItemsByIds:output_type -> product.ItemsByIdsData + 0, // 38: product.Product.NumberAdd:output_type -> product.Response + 22, // [22:39] is the sub-list for method output_type + 5, // [5:22] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_product_product_proto_init() } @@ -2174,7 +2324,7 @@ func file_product_product_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_product_product_proto_rawDesc), len(file_product_product_proto_rawDesc)), NumEnums: 0, - NumMessages: 21, + NumMessages: 24, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/product/pb/product_grpc.pb.go b/rpc/product/pb/product_grpc.pb.go index 17d192c..9aec8d9 100644 --- a/rpc/product/pb/product_grpc.pb.go +++ b/rpc/product/pb/product_grpc.pb.go @@ -11,6 +11,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -33,6 +34,8 @@ const ( Product_EditSusceptible_FullMethodName = "/product.Product/EditSusceptible" Product_EditApplyPass_FullMethodName = "/product.Product/EditApplyPass" Product_Number_FullMethodName = "/product.Product/Number" + Product_InfoById_FullMethodName = "/product.Product/InfoById" + Product_ItemsByIds_FullMethodName = "/product.Product/ItemsByIds" Product_NumberAdd_FullMethodName = "/product.Product/NumberAdd" ) @@ -62,7 +65,9 @@ type ProductClient interface { EditApplyPass(ctx context.Context, in *EditApplyPassReq, opts ...grpc.CallOption) (*Response, error) // 增减库存 // type: 1 增加, 2 减少 - Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*Response, error) + Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) + ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) // 增加库存 NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) } @@ -205,9 +210,9 @@ func (c *productClient) EditApplyPass(ctx context.Context, in *EditApplyPassReq, return out, nil } -func (c *productClient) Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*Response, error) { +func (c *productClient) Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) + out := new(emptypb.Empty) err := c.cc.Invoke(ctx, Product_Number_FullMethodName, in, out, cOpts...) if err != nil { return nil, err @@ -215,6 +220,26 @@ func (c *productClient) Number(ctx context.Context, in *NumberReq, opts ...grpc. return out, nil } +func (c *productClient) InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Item) + err := c.cc.Invoke(ctx, Product_InfoById_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productClient) ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ItemsByIdsData) + err := c.cc.Invoke(ctx, Product_ItemsByIds_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *productClient) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -251,7 +276,9 @@ type ProductServer interface { EditApplyPass(context.Context, *EditApplyPassReq) (*Response, error) // 增减库存 // type: 1 增加, 2 减少 - Number(context.Context, *NumberReq) (*Response, error) + Number(context.Context, *NumberReq) (*emptypb.Empty, error) + InfoById(context.Context, *InfoByIdReq) (*Item, error) + ItemsByIds(context.Context, *ItemsByIdsReq) (*ItemsByIdsData, error) // 增加库存 NumberAdd(context.Context, *NumberAddReq) (*Response, error) mustEmbedUnimplementedProductServer() @@ -303,9 +330,15 @@ func (UnimplementedProductServer) EditSusceptible(context.Context, *EditSuscepti func (UnimplementedProductServer) EditApplyPass(context.Context, *EditApplyPassReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method EditApplyPass not implemented") } -func (UnimplementedProductServer) Number(context.Context, *NumberReq) (*Response, error) { +func (UnimplementedProductServer) Number(context.Context, *NumberReq) (*emptypb.Empty, error) { return nil, status.Error(codes.Unimplemented, "method Number not implemented") } +func (UnimplementedProductServer) InfoById(context.Context, *InfoByIdReq) (*Item, error) { + return nil, status.Error(codes.Unimplemented, "method InfoById not implemented") +} +func (UnimplementedProductServer) ItemsByIds(context.Context, *ItemsByIdsReq) (*ItemsByIdsData, error) { + return nil, status.Error(codes.Unimplemented, "method ItemsByIds not implemented") +} func (UnimplementedProductServer) NumberAdd(context.Context, *NumberAddReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method NumberAdd not implemented") } @@ -582,6 +615,42 @@ func _Product_Number_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } +func _Product_InfoById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoByIdReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).InfoById(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_InfoById_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).InfoById(ctx, req.(*InfoByIdReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Product_ItemsByIds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ItemsByIdsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).ItemsByIds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_ItemsByIds_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).ItemsByIds(ctx, req.(*ItemsByIdsReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Product_NumberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NumberAddReq) if err := dec(in); err != nil { @@ -663,6 +732,14 @@ var Product_ServiceDesc = grpc.ServiceDesc{ MethodName: "Number", Handler: _Product_Number_Handler, }, + { + MethodName: "InfoById", + Handler: _Product_InfoById_Handler, + }, + { + MethodName: "ItemsByIds", + Handler: _Product_ItemsByIds_Handler, + }, { MethodName: "NumberAdd", Handler: _Product_NumberAdd_Handler, diff --git a/rpc/product/product.pb b/rpc/product/product.pb index b223d3f9f3d0ac9da1c6d6bd3193d819d140a135..38d091aafe8c66c03a6e1ef88a7885d5a2ee2657 100644 GIT binary patch delta 520 zcmX>+g|UAI;|3?wgnf)$(&_p6={c$T1x5KK`AMZ|`l-1EC6#($t`I*&62b#YDzS61 zx`O1LYPp1y^K8o0vMz8CLcCdbjr@lFVBM*TafgFk#P|dvwMKkDkeF1 zu+4g4)j-4b!c%i{yg`aXDhpDJli0v+Fy`vgne1X}CoYBErITw+eYs`1xIOdI@|`L@ zQzkF85{Xpg;`J;^%`FBA6bGdi3JGvAXQmWOFe)%>Fb9E{N~T5J)GgdxUJcxDf6a5`$|| ULx_TOiNhrj;vnBnKIGX50B)79&j0`b delta 68 zcmeC5!FYHI;|3>FrvI9gS&bDmv4+ro4GbS Wxh-d5)SvvyOLp>BH=)UW-i-hgb{8-J diff --git a/rpc/product/product.proto b/rpc/product/product.proto index 379d348..ff186c8 100644 --- a/rpc/product/product.proto +++ b/rpc/product/product.proto @@ -4,6 +4,7 @@ package product; option go_package="lone-services/rpc/product"; import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; service Product { rpc Create(CreateReq) returns (Response) { @@ -95,7 +96,10 @@ service Product { // 增减库存 // type: 1 增加, 2 减少 - rpc Number(NumberReq) returns (Response); + rpc Number(NumberReq) returns (google.protobuf.Empty); + rpc InfoById(InfoByIdReq) returns (Item); + rpc ItemsByIds(ItemsByIdsReq) returns (ItemsByIdsData); + // 增加库存 rpc NumberAdd(NumberAddReq) returns (Response) { @@ -112,6 +116,18 @@ message Response { string data = 3; } +message InfoByIdReq { + int64 id = 1; +} + +message ItemsByIdsReq { + repeated int64 ids = 1; +} + +message ItemsByIdsData { + repeated Item items = 1; +} + message CreateReq { string name = 1; string subhead = 2; @@ -124,7 +140,7 @@ message CreateReq { double share_price = 9; double agent_price = 10; string sale_reward = 11; - string images = 12; + repeated string images = 12; double weight = 13; string cubage = 14; string waybill = 15; @@ -196,7 +212,7 @@ message EditBaseReq { string waybill = 5; double weight = 6; string cubage = 7; - string images = 8; + repeated string images = 8; int32 period_validity = 9; string publish_time = 10; string label = 11; @@ -288,7 +304,7 @@ message Item { string index_image = 17; string cubage = 18; string label = 19; - string images = 20; + repeated string images = 20; uint32 is_buy = 21; int32 period_validity = 22; string publish_time = 23; diff --git a/services/chore/choreclient/chore.go b/services/chore/choreclient/chore.go index 918c5b1..2c5ae83 100644 --- a/services/chore/choreclient/chore.go +++ b/services/chore/choreclient/chore.go @@ -16,9 +16,11 @@ import ( type ( PolicyReq = chore.PolicyReq Response = chore.Response + TestReq = chore.TestReq Chore interface { Policy(ctx context.Context, in *PolicyReq, opts ...grpc.CallOption) (*Response, error) + Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) } defaultChore struct { @@ -36,3 +38,8 @@ func (m *defaultChore) Policy(ctx context.Context, in *PolicyReq, opts ...grpc.C client := chore.NewChoreClient(m.cli.Conn()) return client.Policy(ctx, in, opts...) } + +func (m *defaultChore) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) { + client := chore.NewChoreClient(m.cli.Conn()) + return client.Test(ctx, in, opts...) +} diff --git a/services/chore/internal/logic/testLogic.go b/services/chore/internal/logic/testLogic.go new file mode 100644 index 0000000..b83397b --- /dev/null +++ b/services/chore/internal/logic/testLogic.go @@ -0,0 +1,73 @@ +package logic + +import ( + "context" + "fmt" + + "lone-services/pkg/rpcclient" + "lone-services/pkg/utils" + chore "lone-services/rpc/chore/pb" + product "lone-services/rpc/product/pb" + "lone-services/services/chore/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +// product 库存变更:1 增加 2 减少 +const productNumberTypeIncr uint32 = 1 +const productNumberTypeDecr uint32 = 2 + +type TestLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestLogic { + return &TestLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) { + cli, err := rpcclient.Get(l.svcCtx.ProductSvcName) + if err != nil { + l.Errorf("get product rpc: %v", err) + return failResponse(utils.ErrorInternalServer), nil + } + + // 产品库存更变 + // _, err = product.NewProductClient(cli.Conn()).Number(l.ctx, &product.NumberReq{ + // Id: in.GetId(), + // Type: productNumberTypeDecr, + // Number: in.GetNumber(), + // }) + + // 获取单个产品详情 + // res, err := product.NewProductClient(cli.Conn()).InfoById(l.ctx, &product.InfoByIdReq{ + // Id: int64(in.GetId()), + // }) + + // fmt.Println(res.GetName()) + + // 获取多个产品详情 + res, err := product.NewProductClient(cli.Conn()).ItemsByIds(l.ctx, &product.ItemsByIdsReq{ + Ids: in.GetIds(), + }) + for _, item := range res.GetItems() { + fmt.Println(item.GetName()) + } + + if err != nil { + l.Errorf("错误信息: %v", err) + return failResponse(utils.ErrorInternalServer), nil + } + + if res == nil { + l.Errorf("res为空") + return failResponse(utils.Fail), nil + } + return okResponse(res), nil +} diff --git a/services/chore/internal/server/choreServer.go b/services/chore/internal/server/choreServer.go index 97513c6..a115572 100644 --- a/services/chore/internal/server/choreServer.go +++ b/services/chore/internal/server/choreServer.go @@ -27,3 +27,8 @@ func (s *ChoreServer) Policy(ctx context.Context, in *chore.PolicyReq) (*chore.R l := logic.NewPolicyLogic(ctx, s.svcCtx) return l.Policy(in) } + +func (s *ChoreServer) Test(ctx context.Context, in *chore.TestReq) (*chore.Response, error) { + l := logic.NewTestLogic(ctx, s.svcCtx) + return l.Test(in) +} diff --git a/services/chore/internal/svc/servicecontext.go b/services/chore/internal/svc/servicecontext.go index 9268b21..ecfa91d 100644 --- a/services/chore/internal/svc/servicecontext.go +++ b/services/chore/internal/svc/servicecontext.go @@ -1,15 +1,25 @@ package svc import ( + "lone-services/pkg/utils" "lone-services/services/chore/internal/config" + + "github.com/zeromicro/go-zero/core/logx" ) type ServiceContext struct { - Config config.Config + Config config.Config + ProductSvcName string } func NewServiceContext(c config.Config) *ServiceContext { + productSvc := utils.GetConfigString("services.product") + if productSvc == utils.StringEmpty { + logx.Error("config services.product empty") + } + return &ServiceContext{ - Config: c, + Config: c, + ProductSvcName: productSvc, } } diff --git a/services/chore/run.toml b/services/chore/run.toml index b6bc01d..e56c906 100644 --- a/services/chore/run.toml +++ b/services/chore/run.toml @@ -16,18 +16,16 @@ compress = false [oss] - accessKeyId = "LTAI5t7U8KvxSiPE5auwQUuu" - accessKeySecret = "xjfgbQQRpL4TcIspNuClg6bYADa3pk" - roleArn = "acs:ram::1663896742753915:role/oss-upload" - roleSessionName = "oss-upload" - region = "oss-cn-hangzhou" - bucketName = "lone-images" - # SDK 会拼成 {bucket}.{endpoint},这里不要再带 bucket 名 - # 错误示例: lone-images.oss-accelerate... → 实际请求 lone-images.lone-images.oss-accelerate... - endpoint = "https://oss-accelerate.aliyuncs.com" - host = "https://images.ailuowan.com" - dir = "upload/" - expireSeconds = 3600 + accessKeyId = "LTAI5t7U8KvxSiPE5auwQUuu" + accessKeySecret = "xjfgbQQRpL4TcIspNuClg6bYADa3pk" + roleArn = "acs:ram::1663896742753915:role/oss-upload" + roleSessionName = "oss-upload" + region = "oss-cn-hangzhou" + bucketName = "lone-images" + endpoint = "https://lone-images.oss-accelerate.aliyuncs.com" + host = "https://images.ailuowan.com" + dir = "upload/" + expireSeconds = 3600 [redis] host = '39.106.171.204' @@ -36,4 +34,7 @@ db = 0 [encrypt] - data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" \ No newline at end of file + data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" + +[services] + product = "product-service" \ No newline at end of file diff --git a/services/order/internal/server/orderServer.go b/services/order/internal/server/orderServer.go deleted file mode 100644 index 04ae1a8..0000000 --- a/services/order/internal/server/orderServer.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 -// Source: order.proto - -package server - -import ( - "context" - - "lone-services/rpc/order/pb" - "lone-services/services/order/internal/logic" - "lone-services/services/order/internal/svc" -) - -type OrderServer struct { - svcCtx *svc.ServiceContext - order.UnimplementedOrderServer -} - -func NewOrderServer(svcCtx *svc.ServiceContext) *OrderServer { - return &OrderServer{ - svcCtx: svcCtx, - } -} - -func (s *OrderServer) Items(ctx context.Context, in *order.OrderItemsRequest) (*order.Response, error) { - l := logic.NewItemsLogic(ctx, s.svcCtx) - return l.Items(in) -} - -func (s *OrderServer) WebCreate(ctx context.Context, in *order.CreateOrderRequest) (*order.Response, error) { - l := logic.NewWebCreateLogic(ctx, s.svcCtx) - return l.WebCreate(in) -} - -func (s *OrderServer) WebCreateOne(ctx context.Context, in *order.CreateOrderOneRequest) (*order.Response, error) { - l := logic.NewWebCreateOneLogic(ctx, s.svcCtx) - return l.WebCreateOne(in) -} - -func (s *OrderServer) WebAddressCreate(ctx context.Context, in *order.EditAddressRequest) (*order.Response, error) { - l := logic.NewWebAddressCreateLogic(ctx, s.svcCtx) - return l.WebAddressCreate(in) -} - -func (s *OrderServer) WebAddressEdit(ctx context.Context, in *order.EditAddressRequest) (*order.Response, error) { - l := logic.NewWebAddressEditLogic(ctx, s.svcCtx) - return l.WebAddressEdit(in) -} - -func (s *OrderServer) WebAddressDel(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { - l := logic.NewWebAddressDelLogic(ctx, s.svcCtx) - return l.WebAddressDel(in) -} - -func (s *OrderServer) WebAddressDef(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { - l := logic.NewWebAddressDefLogic(ctx, s.svcCtx) - return l.WebAddressDef(in) -} - -func (s *OrderServer) WebAddressInfo(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { - l := logic.NewWebAddressInfoLogic(ctx, s.svcCtx) - return l.WebAddressInfo(in) -} - -func (s *OrderServer) WebAddressItems(ctx context.Context, in *order.TypeRequest) (*order.Response, error) { - l := logic.NewWebAddressItemsLogic(ctx, s.svcCtx) - return l.WebAddressItems(in) -} - -func (s *OrderServer) WebCart(ctx context.Context, in *order.CartRequest) (*order.Response, error) { - l := logic.NewWebCartLogic(ctx, s.svcCtx) - return l.WebCart(in) -} - -func (s *OrderServer) WebCartEdit(ctx context.Context, in *order.EditCartRequest) (*order.Response, error) { - l := logic.NewWebCartEditLogic(ctx, s.svcCtx) - return l.WebCartEdit(in) -} - -func (s *OrderServer) AddressItem(ctx context.Context, in *order.AddressItemsRequest) (*order.Response, error) { - l := logic.NewAddressItemLogic(ctx, s.svcCtx) - return l.AddressItem(in) -} - -func (s *OrderServer) OrderAuditingItems(ctx context.Context, in *order.OrderAuditingItemsRequest) (*order.Response, error) { - l := logic.NewOrderAuditingItemsLogic(ctx, s.svcCtx) - return l.OrderAuditingItems(in) -} - -func (s *OrderServer) OrderAuditing(ctx context.Context, in *order.OrderAuditingRequest) (*order.Response, error) { - l := logic.NewOrderAuditingLogic(ctx, s.svcCtx) - return l.OrderAuditing(in) -} - -func (s *OrderServer) OrderCreate(ctx context.Context, in *order.AdminCreateOrderRequest) (*order.Response, error) { - l := logic.NewOrderCreateLogic(ctx, s.svcCtx) - return l.OrderCreate(in) -} diff --git a/services/product/internal/dao/product.go b/services/product/internal/dao/product.go index 75d64fc..176f797 100644 --- a/services/product/internal/dao/product.go +++ b/services/product/internal/dao/product.go @@ -49,7 +49,7 @@ type Product struct { Waybill string `gorm:"column:waybill;type:varchar(255)"` AgentPrice float32 `gorm:"column:agent_price;type:decimal(10,2)"` SaleReward string `gorm:"column:sale_reward;type:varchar(255)"` - Images string `gorm:"column:images;type:varchar(512);not null"` + Images string `gorm:"column:images;type:json;not null"` Weight float32 `gorm:"column:weight;type:double"` Cubage string `gorm:"column:cubage;type:varchar(255)"` IsIndex uint8 `gorm:"column:is_index;type:tinyint(4);default:2"` @@ -75,7 +75,7 @@ type Product struct { AdminId int `gorm:"column:admin_id;type:int(11);not null"` } -type ProductCreate struct { +type Create struct { Id int `gorm:"column:id;primaryKey;autoIncrement"` Name string `gorm:"column:name"` Subhead string `gorm:"column:subhead"` @@ -108,19 +108,19 @@ type ProductCreate struct { AdminId int `gorm:"column:admin_id"` } -type ProductCheckExist struct { +type CheckExist struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` ModelCode string `gorm:"column:model_code"` Status uint8 `gorm:"column:status"` } -type ProductNumberInfo struct { +type NumberInfo struct { Id int `gorm:"column:id"` Number uint `gorm:"column:number"` } -type ProductVerify struct { +type VerifyContent struct { Id int `json:"id"` Name string `json:"name,omitempty"` ModelCode string `json:"model_code"` @@ -140,7 +140,7 @@ type ProductVerify struct { IndexImage string `json:"index_image,omitempty"` } -type ProductEditBase struct { +type EditBase struct { Id int `gorm:"column:id;primaryKey" json:"id"` Name string `gorm:"column:name" json:"name"` Subhead string `gorm:"column:subhead" json:"subhead"` @@ -160,8 +160,8 @@ type ProductEditBase struct { AdminId int `gorm:"column:admin_id" json:"admin_id"` } -// ProductEditSusceptible 敏感字段(查询旧值 / 写入 verify 快照) -type ProductEditSusceptible struct { +// EditSusceptible 敏感字段(查询旧值 / 写入 verify 快照) +type EditSusceptible struct { Id int `gorm:"column:id" json:"id"` ModelCode string `gorm:"column:model_code" json:"model_code"` Price float32 `gorm:"column:price" json:"price"` @@ -177,13 +177,13 @@ type ProductEditSusceptible struct { AdminId int `gorm:"column:admin_id" json:"admin_id"` } -// ProductVerifyFirstEditStatus 敏感编辑提交后置为一审中(Edit 走 json→map,必须带 json tag) -type ProductVerifyFirstEditStatus struct { +// VerifyFirstEditStatus 敏感编辑提交后置为一审中(Edit 走 json→map,必须带 json tag) +type VerifyFirstEditStatus struct { VerifyStatus uint8 `gorm:"column:verify_status" json:"verify_status"` } -// ProductInfo 列表/详情查询投影 -type ProductInfo struct { +// Info 列表/详情查询投影 +type Info struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` Subhead string `gorm:"column:subhead"` @@ -222,27 +222,27 @@ type ProductInfo struct { Edit uint8 `gorm:"-"` } -type ProductNames struct { +type Names struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` } -type ProductStatusUpdate struct { +type StatusUpdate struct { Status uint8 `gorm:"column:status" json:"status"` Reason string `gorm:"column:reason" json:"reason"` AdminName string `gorm:"column:admin_name" json:"admin_name"` AdminId int `gorm:"column:admin_id" json:"admin_id"` } -type ProductSort struct { +type Sort struct { Id int `gorm:"column:id" json:"id"` Sort uint16 `gorm:"column:sort" json:"sort"` AdminName string `gorm:"column:admin_name" json:"admin_name"` AdminId int `gorm:"column:admin_id" json:"admin_id"` } -// ProductVerifyListRow 审核列表产品侧字段 -type ProductVerifyListRow struct { +// VerifyListRow 审核列表产品侧字段 +type VerifyListRow struct { Id int `gorm:"column:id"` Name string `gorm:"column:name"` ModelCode string `gorm:"column:model_code"` @@ -258,24 +258,24 @@ type ProductVerifyListRow struct { BoxNumber float64 `gorm:"column:box_number"` } -// ProductVerifyFirstStatus 一审后回写产品审核状态(Edit 走 json→map,必须带 json tag) -type ProductVerifyFirstStatus struct { +// VerifyFirstStatus 一审后回写产品审核状态(Edit 走 json→map,必须带 json tag) +type VerifyFirstStatus struct { VerifyStatus uint8 `gorm:"column:verify_status" json:"verify_status"` VerifyId int `gorm:"column:verify_id" json:"verify_id"` VerifyName string `gorm:"column:verify_name" json:"verify_name"` Reason string `gorm:"column:reason" json:"reason"` } -// ProductVerifySecondStatus 二审驳回回写(Edit 走 json→map,必须带 json tag) -type ProductVerifySecondStatus struct { +// VerifySecondStatus 二审驳回回写(Edit 走 json→map,必须带 json tag) +type VerifySecondStatus struct { VerifyStatus uint8 `gorm:"column:verify_status" json:"verify_status"` VerifySecondId int `gorm:"column:verify_second_id" json:"verify_second_id"` VerifySecondName string `gorm:"column:verify_second_name" json:"verify_second_name"` Reason string `gorm:"column:reason" json:"reason"` } -// ProductVerifySecondOkStatus 二审通过:应用快照并回写审核人(Edit 走 json→map,必须带 json tag) -type ProductVerifySecondOkStatus struct { +// VerifySecondOkStatus 二审通过:应用快照并回写审核人(Edit 走 json→map,必须带 json tag) +type VerifySecondOkStatus struct { ModelCode string `gorm:"column:model_code" json:"model_code"` Price float32 `gorm:"column:price" json:"price"` StorePrice float32 `gorm:"column:store_price" json:"store_price"` diff --git a/services/product/internal/logic/convert.go b/services/product/internal/logic/convert.go index 3ad5455..177434d 100644 --- a/services/product/internal/logic/convert.go +++ b/services/product/internal/logic/convert.go @@ -1,12 +1,17 @@ package logic import ( + "strings" + "time" + + "lone-services/pkg/utils" product "lone-services/rpc/product/pb" "lone-services/services/product/internal/dao" - "time" + + jsoniter "github.com/json-iterator/go" ) -func toProductItem(row dao.ProductInfo) *product.Item { +func toProductItem(row dao.Info) *product.Item { publishTime := "" if !row.PublishTime.IsZero() { publishTime = row.PublishTime.Format(time.DateTime) @@ -31,7 +36,7 @@ func toProductItem(row dao.ProductInfo) *product.Item { IndexImage: row.IndexImage, Cubage: row.Cubage, Label: row.Label, - Images: row.Images, + Images: splitImages(row.Images), IsBuy: uint32(row.IsBuy), PeriodValidity: int32(row.PeriodValidity), PublishTime: publishTime, @@ -50,3 +55,38 @@ func toProductItem(row dao.ProductInfo) *product.Item { Edit: uint32(row.Edit), } } + +func joinImages(images []string) string { + list := cleanImages(images) + if len(list) == 0 { + return "[]" + } + buf, err := jsoniter.Marshal(list) + if err != nil { + return "[]" + } + return string(buf) +} + +func splitImages(images string) []string { + images = strings.TrimSpace(images) + if images == utils.StringEmpty { + return []string{} + } + var list []string + if err := jsoniter.Unmarshal([]byte(images), &list); err != nil { + return []string{} + } + return cleanImages(list) +} + +func cleanImages(images []string) []string { + out := make([]string, 0, len(images)) + for _, img := range images { + img = strings.TrimSpace(img) + if img != utils.StringEmpty { + out = append(out, img) + } + } + return out +} diff --git a/services/product/internal/logic/createlogic.go b/services/product/internal/logic/createlogic.go index 04a0aed..df25005 100644 --- a/services/product/internal/logic/createlogic.go +++ b/services/product/internal/logic/createlogic.go @@ -57,7 +57,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) { publishTime = t } - var check dao.ProductCheckExist + var check dao.CheckExist err := model.ProductModel{}.Init().GetOne(modelbase.Params{ Eq: map[string]string{"name": req.Name}, }, &check) @@ -73,7 +73,11 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) { if adminInfo.ID < utils.NumberOne { return failResponse(utils.ErrorNoLoginInfo), nil } - data := dao.ProductCreate{ + images := joinImages(req.Images) + if images == "[]" { + return outResponse(utils.ErrorParams, "图片不能为空"), nil + } + data := dao.Create{ Name: req.Name, Subhead: req.Subhead, Content: req.Content, @@ -87,7 +91,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) { Waybill: req.Waybill, SalesModel: uint8(req.SalesModel), Weight: float32(req.Weight), - Images: req.Images, + Images: images, PeriodValidity: int16(req.PeriodValidity), Type: uint8(req.Type), NormsNumber: uint8(req.NormsNumber), @@ -119,7 +123,7 @@ func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) { return err } - content := dao.ProductVerify{ + content := dao.VerifyContent{ Id: data.Id, ModelCode: data.ModelCode, Price: data.Price, diff --git a/services/product/internal/logic/editApplyPassLogic.go b/services/product/internal/logic/editApplyPassLogic.go new file mode 100644 index 0000000..e3d9413 --- /dev/null +++ b/services/product/internal/logic/editApplyPassLogic.go @@ -0,0 +1,31 @@ +package logic + +import ( + "context" + + "lone-services/rpc/product/pb" + "lone-services/services/product/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type EditApplyPassLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewEditApplyPassLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditApplyPassLogic { + return &EditApplyPassLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// TODO: 临时接口,企微编辑申请审批对接后删除 +func (l *EditApplyPassLogic) EditApplyPass(in *product.EditApplyPassReq) (*product.Response, error) { + // todo: add your logic here and delete this line + + return &product.Response{}, nil +} diff --git a/services/product/internal/logic/editapplylogic.go b/services/product/internal/logic/editapplylogic.go index 6fd2739..8089f23 100644 --- a/services/product/internal/logic/editapplylogic.go +++ b/services/product/internal/logic/editapplylogic.go @@ -36,7 +36,7 @@ func (l *EditApplyLogic) EditApply(in *product.EditApplyReq) (*product.Response, return outResponse(utils.ErrorParams, msg), nil } - var exist dao.ProductCheckExist + var exist dao.CheckExist err := model.ProductModel{}.Init().GetOne(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, }, &exist) @@ -78,7 +78,7 @@ func (l *EditApplyLogic) EditApplyPass(in *product.EditApplyPassReq) (*product.R return outResponse(utils.ErrorParams, msg), nil } - var exist dao.ProductCheckExist + var exist dao.CheckExist err := model.ProductModel{}.Init().GetOne(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, }, &exist) diff --git a/services/product/internal/logic/editbaselogic.go b/services/product/internal/logic/editbaselogic.go index 6804935..064f3a8 100644 --- a/services/product/internal/logic/editbaselogic.go +++ b/services/product/internal/logic/editbaselogic.go @@ -50,7 +50,7 @@ func (l *EditBaseLogic) EditBase(in *product.EditBaseReq) (*product.Response, er } w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}} - var old dao.ProductEditBase + var old dao.EditBase m := model.ProductModel{}.Init() err := m.GetOne(w, &old) if err != nil { @@ -61,7 +61,7 @@ func (l *EditBaseLogic) EditBase(in *product.EditBaseReq) (*product.Response, er return failResponse(utils.ErrorNotFund), nil } - var nameCheck dao.ProductCheckExist + var nameCheck dao.CheckExist err = m.GetOne(modelbase.Params{Eq: map[string]string{"name": req.Name}}, &nameCheck) if err != nil { l.Errorf("edit base name check: %v", err) @@ -80,12 +80,17 @@ func (l *EditBaseLogic) EditBase(in *product.EditBaseReq) (*product.Response, er publishTime = t } - data := dao.ProductEditBase{ + images := joinImages(req.Images) + if images == "[]" { + return outResponse(utils.ErrorParams, "图片不能为空"), nil + } + + data := dao.EditBase{ Id: old.Id, Name: req.Name, Subhead: req.Subhead, Content: req.Content, - Images: req.Images, + Images: images, PeriodValidity: int16(req.PeriodValidity), Waybill: req.Waybill, Weight: float32(req.Weight), diff --git a/services/product/internal/logic/editsusceptiblelogic.go b/services/product/internal/logic/editsusceptiblelogic.go index 8bd8cc3..d482959 100644 --- a/services/product/internal/logic/editsusceptiblelogic.go +++ b/services/product/internal/logic/editsusceptiblelogic.go @@ -68,7 +68,7 @@ func (l *EditSusceptibleLogic) EditSusceptible(in *product.EditSusceptibleReq) ( }, }, } - var old dao.ProductEditSusceptible + var old dao.EditSusceptible err := model.ProductModel{}.Init().GetOne(w, &old) if err != nil { l.Errorf("edit susceptible get: %v", err) @@ -78,7 +78,7 @@ func (l *EditSusceptibleLogic) EditSusceptible(in *product.EditSusceptibleReq) ( return failResponse(utils.ErrorNotFund), nil } - data := dao.ProductEditSusceptible{ + data := dao.EditSusceptible{ Id: int(req.Id), ModelCode: req.ModelCode, Price: float32(req.Price), @@ -102,7 +102,7 @@ func (l *EditSusceptibleLogic) EditSusceptible(in *product.EditSusceptibleReq) ( err = l.svcCtx.DB.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { pm := model.ProductModel{}.Init().WithTX(tx) - if _, err := pm.Edit(w, &dao.ProductVerifyFirstEditStatus{ + if _, err := pm.Edit(w, &dao.VerifyFirstEditStatus{ VerifyStatus: dao.VerifyStatusChecking, }); err != nil { return err diff --git a/services/product/internal/logic/infoByIdLogic.go b/services/product/internal/logic/infoByIdLogic.go new file mode 100644 index 0000000..524a99e --- /dev/null +++ b/services/product/internal/logic/infoByIdLogic.go @@ -0,0 +1,54 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + product "lone-services/rpc/product/pb" + "lone-services/services/product/internal/dao" + "lone-services/services/product/internal/model" + "lone-services/services/product/internal/svc" + "lone-services/services/product/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type InfoByIdLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInfoByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoByIdLogic { + return &InfoByIdLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InfoByIdLogic) InfoById(in *product.InfoByIdReq) (*product.Item, error) { + var req validator.ProductInfoValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + var info dao.Info + err := model.ProductModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, + }, &info) + if err != nil { + l.Errorf("product InfoById: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if info.Id < 1 { + return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg) + } + + return toProductItem(info), nil +} diff --git a/services/product/internal/logic/infologic.go b/services/product/internal/logic/infologic.go index 2ba4b80..6aaa9df 100644 --- a/services/product/internal/logic/infologic.go +++ b/services/product/internal/logic/infologic.go @@ -36,7 +36,7 @@ func (l *InfoLogic) Info(in *product.InfoReq) (*product.Response, error) { return outResponse(utils.ErrorParams, msg), nil } - var info dao.ProductInfo + var info dao.Info err := model.ProductModel{}.Init().GetOne(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, }, &info) diff --git a/services/product/internal/logic/itemsByIdsLogic.go b/services/product/internal/logic/itemsByIdsLogic.go new file mode 100644 index 0000000..fe8bfa4 --- /dev/null +++ b/services/product/internal/logic/itemsByIdsLogic.go @@ -0,0 +1,60 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + product "lone-services/rpc/product/pb" + "lone-services/services/product/internal/dao" + "lone-services/services/product/internal/model" + "lone-services/services/product/internal/svc" + "lone-services/services/product/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type ItemsByIdsLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewItemsByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsByIdsLogic { + return &ItemsByIdsLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ItemsByIdsLogic) ItemsByIds(in *product.ItemsByIdsReq) (*product.ItemsByIdsData, error) { + var req validator.ProductItemsByIdsValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + ids := make([]string, 0, len(req.Ids)) + for _, id := range req.Ids { + ids = append(ids, strconv.FormatInt(id, 10)) + } + + var infos []dao.Info + err := model.ProductModel{}.Init().Items(modelbase.Params{ + In: map[string][]string{"id in ?": ids}, + }, &infos) + if err != nil { + l.Errorf("product ItemsByIds: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + items := make([]*product.Item, 0, len(infos)) + for _, row := range infos { + items = append(items, toProductItem(row)) + } + return &product.ItemsByIdsData{Items: items}, nil +} diff --git a/services/product/internal/logic/itemslogic.go b/services/product/internal/logic/itemslogic.go index 49fd705..66615c2 100644 --- a/services/product/internal/logic/itemslogic.go +++ b/services/product/internal/logic/itemslogic.go @@ -55,7 +55,7 @@ func (l *ItemsLogic) Items(in *product.ItemsReq) (*product.Response, error) { } } - var info []dao.ProductInfo + var info []dao.Info result, err := model.ProductModel{}.Init().Page(w, &info) if err != nil { l.Errorf("product items: %v", err) diff --git a/services/product/internal/logic/nameslogic.go b/services/product/internal/logic/nameslogic.go index c7b8aac..2ce916e 100644 --- a/services/product/internal/logic/nameslogic.go +++ b/services/product/internal/logic/nameslogic.go @@ -28,7 +28,7 @@ func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic } func (l *NamesLogic) Names(_ *product.NamesReq) (*product.Response, error) { - var info []dao.ProductNames + var info []dao.Names err := model.ProductModel{}.Init().Items(modelbase.Params{ Eq: map[string]string{"status": strconv.Itoa(int(dao.ProductStatusNormal))}, }, &info) diff --git a/services/product/internal/logic/numberAddLogic.go b/services/product/internal/logic/numberAddLogic.go index 0824f27..9f8b3fa 100644 --- a/services/product/internal/logic/numberAddLogic.go +++ b/services/product/internal/logic/numberAddLogic.go @@ -2,6 +2,7 @@ package logic import ( "context" + "lone-services/pkg/utils" "lone-services/pkg/validate" product "lone-services/rpc/product/pb" @@ -10,6 +11,8 @@ import ( "lone-services/services/product/validator" "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type NumberAddLogic struct { @@ -37,5 +40,25 @@ func (l *NumberAddLogic) NumberAdd(in *product.NumberAddReq) (*product.Response, return failResponse(utils.ErrorNoLoginInfo), nil } - return changeProductNumber(l.Logger, req.Id, dao.NumberTypeAdd, req.Number) + if err := changeProductNumber(l.Logger, req.Id, dao.NumberTypeAdd, req.Number); err != nil { + return mapNumberErr(err), nil + } + return okResponse(utils.StringEmpty), nil +} + +func mapNumberErr(err error) *product.Response { + st, ok := status.FromError(err) + if !ok { + return failResponse(utils.Fail) + } + switch st.Code() { + case codes.InvalidArgument: + return outResponse(utils.ErrorParams, st.Message()) + case codes.NotFound: + return failResponse(utils.ErrorNotFund) + case codes.FailedPrecondition: + return failResponse(utils.ErrorStockNotEnough) + default: + return failResponse(utils.Fail) + } } diff --git a/services/product/internal/logic/numberLogic.go b/services/product/internal/logic/numberLogic.go index 12eb893..bdc42e8 100644 --- a/services/product/internal/logic/numberLogic.go +++ b/services/product/internal/logic/numberLogic.go @@ -2,6 +2,8 @@ package logic import ( "context" + "strconv" + "lone-services/pkg/modelbase" "lone-services/pkg/utils" "lone-services/pkg/validate" @@ -10,9 +12,11 @@ import ( "lone-services/services/product/internal/model" "lone-services/services/product/internal/svc" "lone-services/services/product/validator" - "strconv" "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/emptypb" ) type NumberLogic struct { @@ -30,27 +34,30 @@ func NewNumberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NumberLogi } // Number 服务间增减库存:type=1 增加,type=2 减少 -func (l *NumberLogic) Number(in *product.NumberReq) (*product.Response, error) { +func (l *NumberLogic) Number(in *product.NumberReq) (*emptypb.Empty, error) { var req validator.ProductNumberValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { - return outResponse(utils.ErrorParams, msg), nil + return nil, status.Error(codes.InvalidArgument, msg) } - return changeProductNumber(l.Logger, req.Id, req.Type, req.Number) + if err := changeProductNumber(l.Logger, req.Id, req.Type, req.Number); err != nil { + return nil, err + } + return &emptypb.Empty{}, nil } -func changeProductNumber(logger logx.Logger, id int64, typ uint32, number uint32) (*product.Response, error) { - var info dao.ProductNumberInfo +func changeProductNumber(logger logx.Logger, id int64, typ uint32, number uint32) error { + var info dao.NumberInfo w := modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(id, 10)}, } m := model.ProductModel{}.Init() if err := m.GetOne(w, &info); err != nil { logger.Errorf("product number get: %v", err) - return failResponse(utils.Fail), nil + return status.Error(codes.Internal, utils.Fail.Msg) } if info.Id < 1 { - return failResponse(utils.ErrorNotFund), nil + return status.Error(codes.NotFound, utils.ErrorNotFund.Msg) } var ( @@ -63,18 +70,17 @@ func changeProductNumber(logger logx.Logger, id int64, typ uint32, number uint32 case dao.NumberTypeSub: rows, err = m.DecrNumber(id, number) default: - return failResponse(utils.ErrorParams), nil + return status.Error(codes.InvalidArgument, utils.ErrorParams.Msg) } if err != nil { logger.Errorf("product number change: %v", err) - return failResponse(utils.Fail), nil + return status.Error(codes.Internal, utils.Fail.Msg) } if rows < 1 { if typ == dao.NumberTypeSub { - return failResponse(utils.ErrorStockNotEnough), nil + return status.Error(codes.FailedPrecondition, utils.ErrorStockNotEnough.Msg) } - return failResponse(utils.Fail), nil + return status.Error(codes.Internal, utils.Fail.Msg) } - - return okResponse(utils.StringEmpty), nil + return nil } diff --git a/services/product/internal/logic/sortlogic.go b/services/product/internal/logic/sortlogic.go index 639005a..9418471 100644 --- a/services/product/internal/logic/sortlogic.go +++ b/services/product/internal/logic/sortlogic.go @@ -35,7 +35,7 @@ func (l *SortLogic) Sort(in *product.SortReq) (*product.Response, error) { return outResponse(utils.ErrorParams, msg), nil } - var info dao.ProductSort + var info dao.Sort w := modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, } diff --git a/services/product/internal/logic/statuslogic.go b/services/product/internal/logic/statuslogic.go index 7f774e1..a1a17f8 100644 --- a/services/product/internal/logic/statuslogic.go +++ b/services/product/internal/logic/statuslogic.go @@ -39,7 +39,7 @@ func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) { return failResponse(utils.ErrorReasonParams), nil } - var info dao.ProductCheckExist + var info dao.CheckExist w := modelbase.Params{ Eq: map[string]string{ "id": strconv.FormatInt(req.Id, 10), @@ -61,7 +61,7 @@ func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) { return failResponse(utils.ErrorNoLoginInfo), nil } - update := dao.ProductStatusUpdate{ + update := dao.StatusUpdate{ Status: uint8(req.Status), Reason: req.Reason, AdminName: adminInfo.Name, diff --git a/services/product/internal/logic/verifyFirstLogic.go b/services/product/internal/logic/verifyFirstLogic.go new file mode 100644 index 0000000..0ea364e --- /dev/null +++ b/services/product/internal/logic/verifyFirstLogic.go @@ -0,0 +1,31 @@ +package logic + +import ( + "context" + + "lone-services/rpc/product/pb" + "lone-services/services/product/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type VerifyFirstLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewVerifyFirstLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VerifyFirstLogic { + return &VerifyFirstLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 一审通过/驳回 +func (l *VerifyFirstLogic) VerifyFirst(in *product.VerifyStatusReq) (*product.Response, error) { + // todo: add your logic here and delete this line + + return &product.Response{}, nil +} diff --git a/services/product/internal/logic/verifySecondLogic.go b/services/product/internal/logic/verifySecondLogic.go new file mode 100644 index 0000000..0cc2e3c --- /dev/null +++ b/services/product/internal/logic/verifySecondLogic.go @@ -0,0 +1,31 @@ +package logic + +import ( + "context" + + "lone-services/rpc/product/pb" + "lone-services/services/product/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type VerifySecondLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewVerifySecondLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VerifySecondLogic { + return &VerifySecondLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// 二审通过/驳回 +func (l *VerifySecondLogic) VerifySecond(in *product.VerifyStatusReq) (*product.Response, error) { + // todo: add your logic here and delete this line + + return &product.Response{}, nil +} diff --git a/services/product/internal/logic/verifylogic.go b/services/product/internal/logic/verifylogic.go index 7e98829..d9d57bb 100644 --- a/services/product/internal/logic/verifylogic.go +++ b/services/product/internal/logic/verifylogic.go @@ -58,7 +58,7 @@ func (l *VerifyLogic) Verify(in *product.VerifyReq) (*product.Response, error) { Order: "id desc", } - var rows []dao.ProductVerifyListRow + var rows []dao.VerifyListRow result, err := model.ProductModel{}.Init().Page(w, &rows) if err != nil { l.Errorf("product verify list: %v", err) @@ -102,7 +102,7 @@ func (l *VerifyLogic) Verify(in *product.VerifyReq) (*product.Response, error) { if !ok || len(v.Content) <= utils.NumberTen { continue } - var content dao.ProductVerify + var content dao.VerifyContent err = jsoniter.Unmarshal([]byte(v.Content), &content) if err != nil { l.Errorf("product verify content json: %v", err) diff --git a/services/product/internal/logic/verifystatuslogic.go b/services/product/internal/logic/verifystatuslogic.go index 5989dd6..b8479d7 100644 --- a/services/product/internal/logic/verifystatuslogic.go +++ b/services/product/internal/logic/verifystatuslogic.go @@ -85,7 +85,7 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS } productWhere := modelbase.Params{Eq: map[string]string{"id": info.VerifyId}} - var productExist dao.ProductCheckExist + var productExist dao.CheckExist err = model.ProductModel{}.Init().GetOne(productWhere, &productExist) if err != nil { l.Errorf("verify product get: %v", err) @@ -110,7 +110,7 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS }); err != nil { return err } - _, err := pm.Edit(productWhere, &dao.ProductVerifyFirstStatus{ + _, err := pm.Edit(productWhere, &dao.VerifyFirstStatus{ VerifyStatus: nextStatus, VerifyId: adminId, VerifyName: adminName, @@ -130,12 +130,12 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS } if nextStatus == dao.VerifyStatusPass { - var content dao.ProductVerify + var content dao.VerifyContent if err := jsoniter.Unmarshal([]byte(info.Content), &content); err != nil { l.Errorf("product verify content json: %v content=%s", err, info.Content) return err } - _, err := pm.Edit(productWhere, &dao.ProductVerifySecondOkStatus{ + _, err := pm.Edit(productWhere, &dao.VerifySecondOkStatus{ ModelCode: content.ModelCode, Price: content.Price, StorePrice: content.StorePrice, @@ -154,7 +154,7 @@ func (l *VerifyStatusLogic) verifyStatus(expectStatus uint8, in *product.VerifyS return err } - _, err := pm.Edit(productWhere, &dao.ProductVerifySecondStatus{ + _, err := pm.Edit(productWhere, &dao.VerifySecondStatus{ VerifyStatus: nextStatus, VerifySecondId: adminId, VerifySecondName: adminName, diff --git a/services/product/internal/model/product_model.go b/services/product/internal/model/product_model.go index ee735e2..ba50dd4 100644 --- a/services/product/internal/model/product_model.go +++ b/services/product/internal/model/product_model.go @@ -20,11 +20,10 @@ func (m ProductModel) Init() ProductModel { return m } -func (m ProductModel) Create(data *dao.ProductCreate) error { +func (m ProductModel) Create(data *dao.Create) error { return m.Base.Create(data) } -// IncrNumber 原子增加库存 func (m ProductModel) IncrNumber(id int64, n uint32) (int64, error) { ret := modelbase.DB().Table(m.TableName()). Where("id = ?", id). @@ -32,7 +31,6 @@ func (m ProductModel) IncrNumber(id int64, n uint32) (int64, error) { return ret.RowsAffected, ret.Error } -// DecrNumber 原子减少库存(库存不足时 RowsAffected=0) func (m ProductModel) DecrNumber(id int64, n uint32) (int64, error) { ret := modelbase.DB().Table(m.TableName()). Where("id = ? AND number >= ?", id, n). diff --git a/services/product/internal/server/productserver.go b/services/product/internal/server/productserver.go index bdd145a..eae7bcc 100644 --- a/services/product/internal/server/productserver.go +++ b/services/product/internal/server/productserver.go @@ -1,11 +1,14 @@ // Code generated by goctl. DO NOT EDIT. +// goctl 1.10.1 // Source: product.proto package server import ( "context" - product "lone-services/rpc/product/pb" + + "google.golang.org/protobuf/types/known/emptypb" + "lone-services/rpc/product/pb" "lone-services/services/product/internal/logic" "lone-services/services/product/internal/svc" ) @@ -51,46 +54,65 @@ func (s *ProductServer) Sort(ctx context.Context, in *product.SortReq) (*product return l.Sort(in) } +// 审核列表: status: 1: 一审, 2: 二审 func (s *ProductServer) Verify(ctx context.Context, in *product.VerifyReq) (*product.Response, error) { l := logic.NewVerifyLogic(ctx, s.svcCtx) return l.Verify(in) } +// 一审通过/驳回 func (s *ProductServer) VerifyFirst(ctx context.Context, in *product.VerifyStatusReq) (*product.Response, error) { - l := logic.NewVerifyStatusLogic(ctx, s.svcCtx) + l := logic.NewVerifyFirstLogic(ctx, s.svcCtx) return l.VerifyFirst(in) } +// 二审通过/驳回 func (s *ProductServer) VerifySecond(ctx context.Context, in *product.VerifyStatusReq) (*product.Response, error) { - l := logic.NewVerifyStatusLogic(ctx, s.svcCtx) + l := logic.NewVerifySecondLogic(ctx, s.svcCtx) return l.VerifySecond(in) } +// 编辑申请 func (s *ProductServer) EditApply(ctx context.Context, in *product.EditApplyReq) (*product.Response, error) { l := logic.NewEditApplyLogic(ctx, s.svcCtx) return l.EditApply(in) } -func (s *ProductServer) EditApplyPass(ctx context.Context, in *product.EditApplyPassReq) (*product.Response, error) { - l := logic.NewEditApplyLogic(ctx, s.svcCtx) - return l.EditApplyPass(in) -} - +// 编辑基础信息 func (s *ProductServer) EditBase(ctx context.Context, in *product.EditBaseReq) (*product.Response, error) { l := logic.NewEditBaseLogic(ctx, s.svcCtx) return l.EditBase(in) } +// 编辑敏感信息(进入一审) func (s *ProductServer) EditSusceptible(ctx context.Context, in *product.EditSusceptibleReq) (*product.Response, error) { l := logic.NewEditSusceptibleLogic(ctx, s.svcCtx) return l.EditSusceptible(in) } -func (s *ProductServer) Number(ctx context.Context, in *product.NumberReq) (*product.Response, error) { +// TODO: 临时接口,企微编辑申请审批对接后删除 +func (s *ProductServer) EditApplyPass(ctx context.Context, in *product.EditApplyPassReq) (*product.Response, error) { + l := logic.NewEditApplyPassLogic(ctx, s.svcCtx) + return l.EditApplyPass(in) +} + +// 增减库存 +func (s *ProductServer) Number(ctx context.Context, in *product.NumberReq) (*emptypb.Empty, error) { l := logic.NewNumberLogic(ctx, s.svcCtx) return l.Number(in) } +func (s *ProductServer) InfoById(ctx context.Context, in *product.InfoByIdReq) (*product.Item, error) { + l := logic.NewInfoByIdLogic(ctx, s.svcCtx) + return l.InfoById(in) +} + +func (s *ProductServer) ItemsByIds(ctx context.Context, in *product.ItemsByIdsReq) (*product.ItemsByIdsData, error) { + l := logic.NewItemsByIdsLogic(ctx, s.svcCtx) + return l.ItemsByIds(in) +} + +// 增加库存 func (s *ProductServer) NumberAdd(ctx context.Context, in *product.NumberAddReq) (*product.Response, error) { l := logic.NewNumberAddLogic(ctx, s.svcCtx) return l.NumberAdd(in) diff --git a/services/product/productClient/product.go b/services/product/productClient/product.go new file mode 100644 index 0000000..4c1ac92 --- /dev/null +++ b/services/product/productClient/product.go @@ -0,0 +1,176 @@ +// Code generated by goctl. DO NOT EDIT. +// goctl 1.10.1 +// Source: product.proto + +package productClient + +import ( + "context" + + "lone-services/rpc/product/pb" + + "google.golang.org/protobuf/types/known/emptypb" + + "github.com/zeromicro/go-zero/zrpc" + "google.golang.org/grpc" +) + +type ( + CreateReq = product.CreateReq + EditApplyPassReq = product.EditApplyPassReq + EditApplyReq = product.EditApplyReq + EditBaseReq = product.EditBaseReq + EditSusceptibleReq = product.EditSusceptibleReq + InfoByIdReq = product.InfoByIdReq + InfoReq = product.InfoReq + Item = product.Item + ItemsByIdsData = product.ItemsByIdsData + ItemsByIdsReq = product.ItemsByIdsReq + ItemsData = product.ItemsData + ItemsReq = product.ItemsReq + NameItem = product.NameItem + NamesReq = product.NamesReq + NumberAddReq = product.NumberAddReq + NumberReq = product.NumberReq + Response = product.Response + SortReq = product.SortReq + StatusReq = product.StatusReq + VerifyItem = product.VerifyItem + VerifyItemsData = product.VerifyItemsData + VerifyParams = product.VerifyParams + VerifyReq = product.VerifyReq + VerifyStatusReq = product.VerifyStatusReq + + Product interface { + Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) + Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) + Names(ctx context.Context, in *NamesReq, opts ...grpc.CallOption) (*Response, error) + Status(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) + Sort(ctx context.Context, in *SortReq, opts ...grpc.CallOption) (*Response, error) + // 审核列表: status: 1: 一审, 2: 二审 + Verify(ctx context.Context, in *VerifyReq, opts ...grpc.CallOption) (*Response, error) + // 一审通过/驳回 + VerifyFirst(ctx context.Context, in *VerifyStatusReq, opts ...grpc.CallOption) (*Response, error) + // 二审通过/驳回 + VerifySecond(ctx context.Context, in *VerifyStatusReq, opts ...grpc.CallOption) (*Response, error) + // 编辑申请 + EditApply(ctx context.Context, in *EditApplyReq, opts ...grpc.CallOption) (*Response, error) + // 编辑基础信息 + EditBase(ctx context.Context, in *EditBaseReq, opts ...grpc.CallOption) (*Response, error) + // 编辑敏感信息(进入一审) + EditSusceptible(ctx context.Context, in *EditSusceptibleReq, opts ...grpc.CallOption) (*Response, error) + // TODO: 临时接口,企微编辑申请审批对接后删除 + EditApplyPass(ctx context.Context, in *EditApplyPassReq, opts ...grpc.CallOption) (*Response, error) + // 增减库存 + Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) + ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) + // 增加库存 + NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) + } + + defaultProduct struct { + cli zrpc.Client + } +) + +func NewProduct(cli zrpc.Client) Product { + return &defaultProduct{ + cli: cli, + } +} + +func (m *defaultProduct) Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Create(ctx, in, opts...) +} + +func (m *defaultProduct) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Info(ctx, in, opts...) +} + +func (m *defaultProduct) Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Items(ctx, in, opts...) +} + +func (m *defaultProduct) Names(ctx context.Context, in *NamesReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Names(ctx, in, opts...) +} + +func (m *defaultProduct) Status(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Status(ctx, in, opts...) +} + +func (m *defaultProduct) Sort(ctx context.Context, in *SortReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Sort(ctx, in, opts...) +} + +// 审核列表: status: 1: 一审, 2: 二审 +func (m *defaultProduct) Verify(ctx context.Context, in *VerifyReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Verify(ctx, in, opts...) +} + +// 一审通过/驳回 +func (m *defaultProduct) VerifyFirst(ctx context.Context, in *VerifyStatusReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.VerifyFirst(ctx, in, opts...) +} + +// 二审通过/驳回 +func (m *defaultProduct) VerifySecond(ctx context.Context, in *VerifyStatusReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.VerifySecond(ctx, in, opts...) +} + +// 编辑申请 +func (m *defaultProduct) EditApply(ctx context.Context, in *EditApplyReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.EditApply(ctx, in, opts...) +} + +// 编辑基础信息 +func (m *defaultProduct) EditBase(ctx context.Context, in *EditBaseReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.EditBase(ctx, in, opts...) +} + +// 编辑敏感信息(进入一审) +func (m *defaultProduct) EditSusceptible(ctx context.Context, in *EditSusceptibleReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.EditSusceptible(ctx, in, opts...) +} + +// TODO: 临时接口,企微编辑申请审批对接后删除 +func (m *defaultProduct) EditApplyPass(ctx context.Context, in *EditApplyPassReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.EditApplyPass(ctx, in, opts...) +} + +// 增减库存 +func (m *defaultProduct) Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.Number(ctx, in, opts...) +} + +func (m *defaultProduct) InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.InfoById(ctx, in, opts...) +} + +func (m *defaultProduct) ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.ItemsByIds(ctx, in, opts...) +} + +// 增加库存 +func (m *defaultProduct) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.NumberAdd(ctx, in, opts...) +} diff --git a/services/product/validator/validator.go b/services/product/validator/validator.go index ef15af4..e4bdc8c 100644 --- a/services/product/validator/validator.go +++ b/services/product/validator/validator.go @@ -13,13 +13,13 @@ type ProductCreateValidator struct { SalePrice float64 SharePrice float64 AgentPrice float64 - SaleReward string `validate:"max=255"` - Images string `validate:"required,max=512"` - Weight float64 `validate:"required"` - Cubage string `validate:"required,max=255"` - Waybill string `validate:"required,max=255"` - PeriodValidity int32 `validate:"required"` - NormsNumber uint32 `validate:"required,min=1"` + SaleReward string `validate:"max=255"` + Images []string `validate:"required,min=1,dive,required"` + Weight float64 `validate:"required"` + Cubage string `validate:"required,max=255"` + Waybill string `validate:"required,max=255"` + PeriodValidity int32 `validate:"required"` + NormsNumber uint32 `validate:"required,min=1"` BoxNumber float64 Type uint32 `validate:"required,oneof=1 2 3"` Number uint32 @@ -42,6 +42,7 @@ func (p ProductCreateValidator) GetMessage() validate.ValidatorMessages { "ModelCode.required": "请输入机器码", "Price.required": "价格不能为空", "Images.required": "图片不能为空", + "Images.min": "图片不能为空", "Weight.required": "重量不能为空", "Cubage.required": "体积不能为空", "Waybill.required": "运货单图片不能为空", @@ -168,14 +169,14 @@ type ProductEditBaseValidator struct { Content string `validate:"required"` Waybill string `validate:"required,max=255"` Weight float64 `validate:"required"` - Cubage string `validate:"required,max=255"` - Images string `validate:"required,max=512"` - PeriodValidity int32 `validate:"required"` - PublishTime string `validate:"max=32"` - Label string `validate:"max=255"` - IsBuy uint32 `validate:"omitempty,oneof=1 2"` - IsIndex uint32 `validate:"omitempty,oneof=1 2"` - IndexImage string `validate:"max=255"` + Cubage string `validate:"required,max=255"` + Images []string `validate:"required,min=1,dive,required"` + PeriodValidity int32 `validate:"required"` + PublishTime string `validate:"max=32"` + Label string `validate:"max=255"` + IsBuy uint32 `validate:"omitempty,oneof=1 2"` + IsIndex uint32 `validate:"omitempty,oneof=1 2"` + IndexImage string `validate:"max=255"` } func (p ProductEditBaseValidator) GetMessage() validate.ValidatorMessages { @@ -186,6 +187,7 @@ func (p ProductEditBaseValidator) GetMessage() validate.ValidatorMessages { "Subhead.required": "副标题不能为空", "Content.required": "内容不能为空", "Images.required": "图片不能为空", + "Images.min": "图片不能为空", "PeriodValidity.required": "有效期不能为空", "Waybill.required": "运货单图片不能为空", "Weight.required": "重量不能为空", @@ -249,3 +251,14 @@ func (p ProductNumberAddValidator) GetMessage() validate.ValidatorMessages { "Number.gt": "数量必须大于0", } } + +type ProductItemsByIdsValidator struct { + Ids []int64 `validate:"required,min=1"` +} + +func (p ProductItemsByIdsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Ids.required": "ID列表不能为空", + "Ids.min": "ID列表不能为空", + } +}