库存扣减

master
shenzhuan 2 years ago
parent 07b96d72c5
commit ef538a66a0

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"goproduct/domain/model"
"goproduct/proto"
"gorm.io/gorm"
)
@ -20,6 +21,8 @@ type IProductRepository interface {
ShowProductDetail(int32) (*model.ProductDetail, error)
ShowProductSku(int32) (*[]model.ProductSku, error)
ShowDetailSku(int32) (*model.ProductSku, error)
UpdateSku(req *proto.UpdateSkuReq) (isSuccess bool, err error)
CountNum() int64
}
@ -92,3 +95,10 @@ func (u *ProductRepository) ShowDetailSku(id int32) (obj *model.ProductSku, err
fmt.Println("repository ShowDetailSku >>>> ", productSku)
return productSku, nil
}
func (u *ProductRepository) UpdateSku(req *proto.UpdateSkuReq) (isSuccess bool, err error) {
sku := req.GetProductSku()
//u.mysqlDB.Updates(sku)
u.mysqlDB.Debug().Model(&model.ProductSku{}).Where("id=?", sku.SkuId).Update("stock", sku.Stock)
return true, nil
}

@ -3,6 +3,7 @@ package service
import (
"goproduct/domain/model"
"goproduct/domain/repository"
"goproduct/proto"
)
type IProductDataService interface {
@ -10,7 +11,7 @@ type IProductDataService interface {
ShowProductDetail(int32) (obj *model.ProductDetail, err error)
ShowProductSku(int32) (obj *[]model.ProductSku, err error)
ShowDetailSku(int32) (obj *model.ProductSku, err error)
UpdateSku(req *proto.UpdateSkuReq) (isSuccess bool, err error)
CountNum() int64
}
type ProductDataService struct {
@ -44,3 +45,8 @@ func (u *ProductDataService) ShowDetailSku(id int32) (product *model.ProductSku,
return u.productRepository.ShowDetailSku(id)
}
func (u *ProductDataService) UpdateSku(req *proto.UpdateSkuReq) (isSuccess bool, err error) {
return u.productRepository.UpdateSku(req)
}

@ -112,3 +112,15 @@ func (u *ProductHandler) ShowDetailSku(ctx context.Context, req *proto.ProductDe
resp.ProductSku = append(resp.ProductSku, productSku)
return nil
}
// 修改商品SKU
func (u *ProductHandler) UpdateSku(ctx context.Context, req *proto.UpdateSkuReq, resp *proto.UpdateSkuResp) error {
//count := u.ProductDataService.CountNum()
isSuccess, err := u.ProductDataService.UpdateSku(req)
if err != nil {
resp.IsSuccess = isSuccess
println("UpdateSku err :", err)
}
resp.IsSuccess = isSuccess
return nil
}

@ -59,6 +59,7 @@ func main() {
proto.RegisterShowProductDetailHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterShowProductSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterShowDetailSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterUpdateSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService})
//5.启动服务
if err := repcService.Run(); err != nil {
log.Println("start user service err :", err)

@ -11,10 +11,6 @@
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -746,6 +742,100 @@ func (x *ProductSkuResp) GetProductSku() []*ProductSku {
return nil
}
type UpdateSkuReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductSku *ProductSku `protobuf:"bytes,1,opt,name=productSku,proto3" json:"productSku,omitempty"`
}
func (x *UpdateSkuReq) Reset() {
*x = UpdateSkuReq{}
if protoimpl.UnsafeEnabled {
mi := &file_product_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSkuReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSkuReq) ProtoMessage() {}
func (x *UpdateSkuReq) ProtoReflect() protoreflect.Message {
mi := &file_product_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateSkuReq.ProtoReflect.Descriptor instead.
func (*UpdateSkuReq) Descriptor() ([]byte, []int) {
return file_product_proto_rawDescGZIP(), []int{9}
}
func (x *UpdateSkuReq) GetProductSku() *ProductSku {
if x != nil {
return x.ProductSku
}
return nil
}
type UpdateSkuResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=isSuccess,proto3" json:"isSuccess,omitempty"`
}
func (x *UpdateSkuResp) Reset() {
*x = UpdateSkuResp{}
if protoimpl.UnsafeEnabled {
mi := &file_product_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSkuResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSkuResp) ProtoMessage() {}
func (x *UpdateSkuResp) ProtoReflect() protoreflect.Message {
mi := &file_product_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateSkuResp.ProtoReflect.Descriptor instead.
func (*UpdateSkuResp) Descriptor() ([]byte, []int) {
return file_product_proto_rawDescGZIP(), []int{10}
}
func (x *UpdateSkuResp) GetIsSuccess() bool {
if x != nil {
return x.IsSuccess
}
return false
}
var File_product_proto protoreflect.FileDescriptor
var file_product_proto_rawDesc = []byte{
@ -844,27 +934,39 @@ var file_product_proto_rawDesc = []byte{
0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x53, 0x6b, 0x75, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75,
0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65,
0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71,
0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73,
0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70,
0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64,
0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65,
0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71,
0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x22, 0x41, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71,
0x12, 0x31, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f,
0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x53, 0x6b, 0x75, 0x22, 0x2d, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75,
0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73,
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61,
0x67, 0x65, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52,
0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f,
0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68,
0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12,
0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44,
0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65,
0x73, 0x70, 0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64,
0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72,
0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b,
0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44,
0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77,
0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52,
0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x45, 0x0a, 0x09, 0x55,
0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70,
0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -879,7 +981,7 @@ func file_product_proto_rawDescGZIP() []byte {
return file_product_proto_rawDescData
}
var file_product_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_product_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_product_proto_goTypes = []interface{}{
(*Product)(nil), // 0: proto.Product
(*PageReq)(nil), // 1: proto.PageReq
@ -890,26 +992,31 @@ var file_product_proto_goTypes = []interface{}{
(*ProductSku)(nil), // 6: proto.ProductSku
(*ProductSkuReq)(nil), // 7: proto.ProductSkuReq
(*ProductSkuResp)(nil), // 8: proto.ProductSkuResp
nil, // 9: proto.Product.LabelListEntry
(*UpdateSkuReq)(nil), // 9: proto.UpdateSkuReq
(*UpdateSkuResp)(nil), // 10: proto.UpdateSkuResp
nil, // 11: proto.Product.LabelListEntry
}
var file_product_proto_depIdxs = []int32{
9, // 0: proto.Product.labelList:type_name -> proto.Product.LabelListEntry
11, // 0: proto.Product.labelList:type_name -> proto.Product.LabelListEntry
0, // 1: proto.PageResp.product:type_name -> proto.Product
3, // 2: proto.ProductDetailResp.productDetail:type_name -> proto.ProductDetail
6, // 3: proto.ProductSkuResp.productSku:type_name -> proto.ProductSku
1, // 4: proto.Page.Page:input_type -> proto.PageReq
4, // 5: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
7, // 6: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
4, // 7: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
2, // 8: proto.Page.Page:output_type -> proto.PageResp
5, // 9: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
8, // 10: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
8, // 11: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
8, // [8:12] is the sub-list for method output_type
4, // [4:8] 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
6, // 4: proto.UpdateSkuReq.productSku:type_name -> proto.ProductSku
1, // 5: proto.Page.Page:input_type -> proto.PageReq
4, // 6: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
7, // 7: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
4, // 8: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
9, // 9: proto.UpdateSku.UpdateSku:input_type -> proto.UpdateSkuReq
2, // 10: proto.Page.Page:output_type -> proto.PageResp
5, // 11: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
8, // 12: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
8, // 13: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
10, // 14: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp
10, // [10:15] is the sub-list for method output_type
5, // [5:10] 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_proto_init() }
@ -1026,6 +1133,30 @@ func file_product_proto_init() {
return nil
}
}
file_product_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSkuReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_product_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSkuResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1033,9 +1164,9 @@ func file_product_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_product_proto_rawDesc,
NumEnums: 0,
NumMessages: 10,
NumMessages: 12,
NumExtensions: 0,
NumServices: 4,
NumServices: 5,
},
GoTypes: file_product_proto_goTypes,
DependencyIndexes: file_product_proto_depIdxs,
@ -1046,307 +1177,3 @@ func file_product_proto_init() {
file_product_proto_goTypes = nil
file_product_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// PageClient is the client API for Page service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type PageClient interface {
// rpc 服务
Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error)
}
type pageClient struct {
cc grpc.ClientConnInterface
}
func NewPageClient(cc grpc.ClientConnInterface) PageClient {
return &pageClient{cc}
}
func (c *pageClient) Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error) {
out := new(PageResp)
err := c.cc.Invoke(ctx, "/proto.Page/Page", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// PageServer is the server API for Page service.
type PageServer interface {
// rpc 服务
Page(context.Context, *PageReq) (*PageResp, error)
}
// UnimplementedPageServer can be embedded to have forward compatible implementations.
type UnimplementedPageServer struct {
}
func (*UnimplementedPageServer) Page(context.Context, *PageReq) (*PageResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Page not implemented")
}
func RegisterPageServer(s *grpc.Server, srv PageServer) {
s.RegisterService(&_Page_serviceDesc, srv)
}
func _Page_Page_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PageReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PageServer).Page(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Page/Page",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PageServer).Page(ctx, req.(*PageReq))
}
return interceptor(ctx, in, info, handler)
}
var _Page_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.Page",
HandlerType: (*PageServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Page",
Handler: _Page_Page_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowProductDetailClient is the client API for ShowProductDetail service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductDetailClient interface {
// rpc 服务
ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error)
}
type showProductDetailClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductDetailClient(cc grpc.ClientConnInterface) ShowProductDetailClient {
return &showProductDetailClient{cc}
}
func (c *showProductDetailClient) ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error) {
out := new(ProductDetailResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductDetail/ShowProductDetail", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductDetailServer is the server API for ShowProductDetail service.
type ShowProductDetailServer interface {
// rpc 服务
ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error)
}
// UnimplementedShowProductDetailServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductDetailServer struct {
}
func (*UnimplementedShowProductDetailServer) ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductDetail not implemented")
}
func RegisterShowProductDetailServer(s *grpc.Server, srv ShowProductDetailServer) {
s.RegisterService(&_ShowProductDetail_serviceDesc, srv)
}
func _ShowProductDetail_ShowProductDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductDetail/ShowProductDetail",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, req.(*ProductDetailReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductDetail_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductDetail",
HandlerType: (*ShowProductDetailServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductDetail",
Handler: _ShowProductDetail_ShowProductDetail_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowProductSkuClient is the client API for ShowProductSku service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductSkuClient interface {
// rpc 服务
ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error)
}
type showProductSkuClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductSkuClient(cc grpc.ClientConnInterface) ShowProductSkuClient {
return &showProductSkuClient{cc}
}
func (c *showProductSkuClient) ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error) {
out := new(ProductSkuResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductSku/ShowProductSku", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductSkuServer is the server API for ShowProductSku service.
type ShowProductSkuServer interface {
// rpc 服务
ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error)
}
// UnimplementedShowProductSkuServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductSkuServer struct {
}
func (*UnimplementedShowProductSkuServer) ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductSku not implemented")
}
func RegisterShowProductSkuServer(s *grpc.Server, srv ShowProductSkuServer) {
s.RegisterService(&_ShowProductSku_serviceDesc, srv)
}
func _ShowProductSku_ShowProductSku_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductSkuReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductSku/ShowProductSku",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, req.(*ProductSkuReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductSku_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductSku",
HandlerType: (*ShowProductSkuServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductSku",
Handler: _ShowProductSku_ShowProductSku_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowDetailSkuClient is the client API for ShowDetailSku service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowDetailSkuClient interface {
// rpc 服务
ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductSkuResp, error)
}
type showDetailSkuClient struct {
cc grpc.ClientConnInterface
}
func NewShowDetailSkuClient(cc grpc.ClientConnInterface) ShowDetailSkuClient {
return &showDetailSkuClient{cc}
}
func (c *showDetailSkuClient) ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductSkuResp, error) {
out := new(ProductSkuResp)
err := c.cc.Invoke(ctx, "/proto.ShowDetailSku/ShowDetailSku", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowDetailSkuServer is the server API for ShowDetailSku service.
type ShowDetailSkuServer interface {
// rpc 服务
ShowDetailSku(context.Context, *ProductDetailReq) (*ProductSkuResp, error)
}
// UnimplementedShowDetailSkuServer can be embedded to have forward compatible implementations.
type UnimplementedShowDetailSkuServer struct {
}
func (*UnimplementedShowDetailSkuServer) ShowDetailSku(context.Context, *ProductDetailReq) (*ProductSkuResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowDetailSku not implemented")
}
func RegisterShowDetailSkuServer(s *grpc.Server, srv ShowDetailSkuServer) {
s.RegisterService(&_ShowDetailSku_serviceDesc, srv)
}
func _ShowDetailSku_ShowDetailSku_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowDetailSkuServer).ShowDetailSku(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowDetailSku/ShowDetailSku",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowDetailSkuServer).ShowDetailSku(ctx, req.(*ProductDetailReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowDetailSku_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowDetailSku",
HandlerType: (*ShowDetailSkuServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowDetailSku",
Handler: _ShowDetailSku_ShowDetailSku_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}

@ -270,3 +270,62 @@ type showDetailSkuHandler struct {
func (h *showDetailSkuHandler) ShowDetailSku(ctx context.Context, in *ProductDetailReq, out *ProductSkuResp) error {
return h.ShowDetailSkuHandler.ShowDetailSku(ctx, in, out)
}
// Api Endpoints for UpdateSku service
func NewUpdateSkuEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for UpdateSku service
type UpdateSkuService interface {
UpdateSku(ctx context.Context, in *UpdateSkuReq, opts ...client.CallOption) (*UpdateSkuResp, error)
}
type updateSkuService struct {
c client.Client
name string
}
func NewUpdateSkuService(name string, c client.Client) UpdateSkuService {
return &updateSkuService{
c: c,
name: name,
}
}
func (c *updateSkuService) UpdateSku(ctx context.Context, in *UpdateSkuReq, opts ...client.CallOption) (*UpdateSkuResp, error) {
req := c.c.NewRequest(c.name, "UpdateSku.UpdateSku", in)
out := new(UpdateSkuResp)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for UpdateSku service
type UpdateSkuHandler interface {
UpdateSku(context.Context, *UpdateSkuReq, *UpdateSkuResp) error
}
func RegisterUpdateSkuHandler(s server.Server, hdlr UpdateSkuHandler, opts ...server.HandlerOption) error {
type updateSku interface {
UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error
}
type UpdateSku struct {
updateSku
}
h := &updateSkuHandler{hdlr}
return s.Handle(s.NewHandler(&UpdateSku{h}, opts...))
}
type updateSkuHandler struct {
UpdateSkuHandler
}
func (h *updateSkuHandler) UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error {
return h.UpdateSkuHandler.UpdateSku(ctx, in, out)
}

@ -150,3 +150,15 @@ service ShowDetailSku {
//rpc
rpc ShowDetailSku (ProductDetailReq) returns (ProductSkuResp){}
}
message UpdateSkuReq{
ProductSku productSku = 1;
}
message UpdateSkuResp {
bool isSuccess =1;
}
service UpdateSku {
rpc UpdateSku (UpdateSkuReq) returns (UpdateSkuResp){}
}

@ -11,10 +11,6 @@
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -420,85 +416,3 @@ func file_user_proto_init() {
file_user_proto_goTypes = nil
file_user_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// LoginClient is the client API for Login service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type LoginClient interface {
// rpc 服务
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResp, error)
}
type loginClient struct {
cc grpc.ClientConnInterface
}
func NewLoginClient(cc grpc.ClientConnInterface) LoginClient {
return &loginClient{cc}
}
func (c *loginClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResp, error) {
out := new(LoginResp)
err := c.cc.Invoke(ctx, "/proto.Login/Login", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LoginServer is the server API for Login service.
type LoginServer interface {
// rpc 服务
Login(context.Context, *LoginRequest) (*LoginResp, error)
}
// UnimplementedLoginServer can be embedded to have forward compatible implementations.
type UnimplementedLoginServer struct {
}
func (*UnimplementedLoginServer) Login(context.Context, *LoginRequest) (*LoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func RegisterLoginServer(s *grpc.Server, srv LoginServer) {
s.RegisterService(&_Login_serviceDesc, srv)
}
func _Login_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LoginServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Login/Login",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LoginServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Login_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.Login",
HandlerType: (*LoginServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _Login_Login_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "user.proto",
}

@ -61,6 +61,8 @@ func main() {
ShowProductDetailClient := proto.NewShowProductDetailService("shop-product", rpcServer.Client())
ShowDetailSkuClient := proto.NewShowDetailSkuService("shop-product", rpcServer.Client())
GetUserTokenClient := proto.NewGetUserTokenService("shop-user", rpcServer.Client())
UpdateSkuClient := proto.NewUpdateSkuService("shop-product", rpcServer.Client())
//分页查询商品列表
router.GET("/increase", func(c *gin.Context) {
// "number": 0,
@ -130,6 +132,16 @@ func main() {
common.RespFail(c.Writer, &proto.AddCartResp{}, "库存不足,添加失败")
return
}
sku := respSkuDetail.ProductSku[0]
sku.Stock -= req.Number
updateSkuReq := &proto.UpdateSkuReq{
ProductSku: sku,
}
respUpdate, err := UpdateSkuClient.UpdateSku(context.TODO(), updateSkuReq)
if err != nil {
log.Println(" /UpdateSkuClient resp :", err)
}
log.Println(" /UpdateSkuClient resp :", respUpdate.IsSuccess)
resp.ProductSkuSimple = respSkuDetail.ProductSku[0]
resp.ProductSimple = respDetail.ProductDetail[0]

@ -1132,6 +1132,101 @@ func (x *TokenResp) GetIsLogin() bool {
return false
}
// 修改库存
type UpdateSkuReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductSku *ProductSku `protobuf:"bytes,1,opt,name=productSku,proto3" json:"productSku,omitempty"`
}
func (x *UpdateSkuReq) Reset() {
*x = UpdateSkuReq{}
if protoimpl.UnsafeEnabled {
mi := &file_cart_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSkuReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSkuReq) ProtoMessage() {}
func (x *UpdateSkuReq) ProtoReflect() protoreflect.Message {
mi := &file_cart_proto_msgTypes[14]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateSkuReq.ProtoReflect.Descriptor instead.
func (*UpdateSkuReq) Descriptor() ([]byte, []int) {
return file_cart_proto_rawDescGZIP(), []int{14}
}
func (x *UpdateSkuReq) GetProductSku() *ProductSku {
if x != nil {
return x.ProductSku
}
return nil
}
type UpdateSkuResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSuccess bool `protobuf:"varint,1,opt,name=isSuccess,proto3" json:"isSuccess,omitempty"`
}
func (x *UpdateSkuResp) Reset() {
*x = UpdateSkuResp{}
if protoimpl.UnsafeEnabled {
mi := &file_cart_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSkuResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSkuResp) ProtoMessage() {}
func (x *UpdateSkuResp) ProtoReflect() protoreflect.Message {
mi := &file_cart_proto_msgTypes[15]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UpdateSkuResp.ProtoReflect.Descriptor instead.
func (*UpdateSkuResp) Descriptor() ([]byte, []int) {
return file_cart_proto_rawDescGZIP(), []int{15}
}
func (x *UpdateSkuResp) GetIsSuccess() bool {
if x != nil {
return x.IsSuccess
}
return false
}
var File_cart_proto protoreflect.FileDescriptor
var file_cart_proto_rawDesc = []byte{
@ -1281,36 +1376,47 @@ var file_cart_proto_rawDesc = []byte{
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x69,
0x73, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x32, 0x3d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74,
0x12, 0x32, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x12,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65,
0x73, 0x70, 0x22, 0x00, 0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04,
0x50, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67,
0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67,
0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11,
0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69,
0x6c, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72,
0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71,
0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f,
0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68,
0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69,
0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f,
0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x43, 0x0a,
0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x0a,
0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0f, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70,
0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x22, 0x41, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
0x6b, 0x75, 0x52, 0x65, 0x71, 0x12, 0x31, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x53, 0x6b, 0x75, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x0a, 0x70, 0x72,
0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x22, 0x2d, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x53,
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73,
0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32, 0x3d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, 0x61,
0x72, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x11, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71,
0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74,
0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29,
0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f,
0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48,
0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64,
0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61,
0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68,
0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52,
0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75,
0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53,
0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d,
0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32,
0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12,
0x33, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12,
0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71,
0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x22, 0x00, 0x32, 0x45, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b,
0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x13,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75,
0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e,
0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1325,7 +1431,7 @@ func file_cart_proto_rawDescGZIP() []byte {
return file_cart_proto_rawDescData
}
var file_cart_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_cart_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
var file_cart_proto_goTypes = []interface{}{
(*ShoppingCart)(nil), // 0: proto.ShoppingCart
(*AddCartReq)(nil), // 1: proto.AddCartReq
@ -1341,32 +1447,37 @@ var file_cart_proto_goTypes = []interface{}{
(*ProductSkuResp)(nil), // 11: proto.ProductSkuResp
(*TokenReq)(nil), // 12: proto.TokenReq
(*TokenResp)(nil), // 13: proto.TokenResp
nil, // 14: proto.Product.LabelListEntry
(*UpdateSkuReq)(nil), // 14: proto.UpdateSkuReq
(*UpdateSkuResp)(nil), // 15: proto.UpdateSkuResp
nil, // 16: proto.Product.LabelListEntry
}
var file_cart_proto_depIdxs = []int32{
6, // 0: proto.AddCartResp.productSimple:type_name -> proto.ProductDetail
9, // 1: proto.AddCartResp.productSkuSimple:type_name -> proto.ProductSku
14, // 2: proto.Product.labelList:type_name -> proto.Product.LabelListEntry
16, // 2: proto.Product.labelList:type_name -> proto.Product.LabelListEntry
3, // 3: proto.PageResp.product:type_name -> proto.Product
6, // 4: proto.ProductDetailResp.productDetail:type_name -> proto.ProductDetail
9, // 5: proto.ProductSkuResp.productSku:type_name -> proto.ProductSku
1, // 6: proto.AddCart.AddCart:input_type -> proto.AddCartReq
4, // 7: proto.Page.Page:input_type -> proto.PageReq
7, // 8: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
10, // 9: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
7, // 10: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
12, // 11: proto.GetUserToken.GetUserToken:input_type -> proto.TokenReq
2, // 12: proto.AddCart.AddCart:output_type -> proto.AddCartResp
5, // 13: proto.Page.Page:output_type -> proto.PageResp
8, // 14: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
11, // 15: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
11, // 16: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
13, // 17: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp
12, // [12:18] is the sub-list for method output_type
6, // [6:12] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
9, // 6: proto.UpdateSkuReq.productSku:type_name -> proto.ProductSku
1, // 7: proto.AddCart.AddCart:input_type -> proto.AddCartReq
4, // 8: proto.Page.Page:input_type -> proto.PageReq
7, // 9: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
10, // 10: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
7, // 11: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
12, // 12: proto.GetUserToken.GetUserToken:input_type -> proto.TokenReq
14, // 13: proto.UpdateSku.UpdateSku:input_type -> proto.UpdateSkuReq
2, // 14: proto.AddCart.AddCart:output_type -> proto.AddCartResp
5, // 15: proto.Page.Page:output_type -> proto.PageResp
8, // 16: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
11, // 17: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
11, // 18: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
13, // 19: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp
15, // 20: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp
14, // [14:21] is the sub-list for method output_type
7, // [7:14] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_cart_proto_init() }
@ -1543,6 +1654,30 @@ func file_cart_proto_init() {
return nil
}
}
file_cart_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSkuReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cart_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSkuResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1550,9 +1685,9 @@ func file_cart_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cart_proto_rawDesc,
NumEnums: 0,
NumMessages: 15,
NumMessages: 17,
NumExtensions: 0,
NumServices: 6,
NumServices: 7,
},
GoTypes: file_cart_proto_goTypes,
DependencyIndexes: file_cart_proto_depIdxs,

@ -392,3 +392,62 @@ type getUserTokenHandler struct {
func (h *getUserTokenHandler) GetUserToken(ctx context.Context, in *TokenReq, out *TokenResp) error {
return h.GetUserTokenHandler.GetUserToken(ctx, in, out)
}
// Api Endpoints for UpdateSku service
func NewUpdateSkuEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for UpdateSku service
type UpdateSkuService interface {
UpdateSku(ctx context.Context, in *UpdateSkuReq, opts ...client.CallOption) (*UpdateSkuResp, error)
}
type updateSkuService struct {
c client.Client
name string
}
func NewUpdateSkuService(name string, c client.Client) UpdateSkuService {
return &updateSkuService{
c: c,
name: name,
}
}
func (c *updateSkuService) UpdateSku(ctx context.Context, in *UpdateSkuReq, opts ...client.CallOption) (*UpdateSkuResp, error) {
req := c.c.NewRequest(c.name, "UpdateSku.UpdateSku", in)
out := new(UpdateSkuResp)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for UpdateSku service
type UpdateSkuHandler interface {
UpdateSku(context.Context, *UpdateSkuReq, *UpdateSkuResp) error
}
func RegisterUpdateSkuHandler(s server.Server, hdlr UpdateSkuHandler, opts ...server.HandlerOption) error {
type updateSku interface {
UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error
}
type UpdateSku struct {
updateSku
}
h := &updateSkuHandler{hdlr}
return s.Handle(s.NewHandler(&UpdateSku{h}, opts...))
}
type updateSkuHandler struct {
UpdateSkuHandler
}
func (h *updateSkuHandler) UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error {
return h.UpdateSkuHandler.UpdateSku(ctx, in, out)
}

@ -229,3 +229,14 @@ service GetUserToken {
//rpc
rpc GetUserToken (TokenReq) returns (TokenResp){}
}
//
message UpdateSkuReq{
ProductSku productSku = 1;
}
message UpdateSkuResp {
bool isSuccess =1;
}
service UpdateSku {
rpc UpdateSku (UpdateSkuReq) returns (UpdateSkuResp){}
}

Loading…
Cancel
Save