diff --git a/product/internal/dao/product.go b/product/internal/dao/product.go index 03b398c..d020610 100644 --- a/product/internal/dao/product.go +++ b/product/internal/dao/product.go @@ -187,3 +187,22 @@ type ProductInfo struct { AdminName string `gorm:"column:admin_name"` Edit uint8 `gorm:"-"` } + +type ProductNames struct { + Id int `gorm:"column:id"` + Name string `gorm:"column:name"` +} + +type ProductStatusUpdate struct { + Status uint8 `gorm:"column:status"` + Reason string `gorm:"column:reason"` + AdminName string `gorm:"column:admin_name"` + AdminId int `gorm:"column:admin_id"` +} + +type ProductSort struct { + Id int `gorm:"column:id"` + Sort uint16 `gorm:"column:sort"` + AdminName string `gorm:"column:admin_name"` + AdminId int `gorm:"column:admin_id"` +} diff --git a/product/internal/logic/convert.go b/product/internal/logic/convert.go new file mode 100644 index 0000000..b63a117 --- /dev/null +++ b/product/internal/logic/convert.go @@ -0,0 +1,53 @@ +package logic + +import ( + "time" + + "product/internal/dao" + "product/product" +) + +func toProductItem(row dao.ProductInfo) *product.Item { + publishTime := "" + if !row.PublishTime.IsZero() { + publishTime = row.PublishTime.Format(time.DateTime) + } + return &product.Item{ + Id: int64(row.Id), + Name: row.Name, + Subhead: row.Subhead, + Content: row.Content, + ModelCode: row.ModelCode, + Price: float64(row.Price), + StorePrice: float64(row.StorePrice), + SalePrice: float64(row.SalePrice), + SharePrice: float64(row.SharePrice), + AgentPrice: float64(row.AgentPrice), + SaleReward: row.SaleReward, + SalesModel: uint32(row.SalesModel), + Waybill: row.Waybill, + Status: uint32(row.Status), + Weight: float64(row.Weight), + IsIndex: uint32(row.IsIndex), + IndexImage: row.IndexImage, + Cubage: row.Cubage, + Label: row.Label, + Images: row.Images, + IsBuy: uint32(row.IsBuy), + PeriodValidity: int32(row.PeriodValidity), + PublishTime: publishTime, + Type: uint32(row.Type), + NormsNumber: uint32(row.NormsNumber), + BoxNumber: row.BoxNumber, + Sort: uint32(row.Sort), + Number: uint32(row.Number), + VerifyStatus: uint32(row.VerifyStatus), + VerifyId: int64(row.VerifyId), + VerifyName: row.VerifyName, + VerifySecondId: int64(row.VerifySecondId), + VerifySecondName: row.VerifySecondName, + Reason: row.Reason, + AdminName: row.AdminName, + Edit: uint32(row.Edit), + } +} diff --git a/product/internal/logic/addLogic.go b/product/internal/logic/createlogic.go similarity index 52% rename from product/internal/logic/addLogic.go rename to product/internal/logic/createlogic.go index 6cdec43..08a63ee 100644 --- a/product/internal/logic/addLogic.go +++ b/product/internal/logic/createlogic.go @@ -11,56 +11,57 @@ import ( "product/internal/model" "product/internal/svc" "product/product" + "product/validator" "pkg.local/log" "pkg.local/modelbase" - "pkg.local/redis" "pkg.local/utils" + validateService "pkg.local/validate" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" ) -type AddLogic struct { +type CreateLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } -func NewAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLogic { - return &AddLogic{ +func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic { + return &CreateLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -func (l *AddLogic) Add(in *product.AddReq) (*product.Response, error) { - l.Info("zero logx 方式 ... ") - log.Info("原始 zap 方式 ... ") +func (l *CreateLogic) Create(in *product.CreateReq) (*product.Response, error) { + var req validator.ProductCreateValidator + if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return msgResponse(utils.Ok.Code, msg), nil + } - redis.Client.Get(l.ctx, redis.GetRedisKey("product:test")) - - if in.GetType() == dao.ProductTypeNormal { - if in.GetAgentPrice() == 0 || in.GetStorePrice() == 0 || - in.GetSalePrice() == 0 || in.GetSharePrice() == 0 || - in.GetSaleReward() == "" { - return failResponse(utils.ErrorMissingParams), nil + if req.Type == dao.ProductTypeNormal { + if req.AgentPrice == 0 || req.StorePrice == 0 || + req.SalePrice == 0 || req.SharePrice == 0 || + req.SaleReward == "" { + return msgResponse(int32(utils.ErrorMissingParams.GetCode()), "缺少相关价格"), nil } } publishTime := time.Now() - if len(in.GetPublishTime()) > 1 { - t, err := parsePublishTime(in.GetPublishTime()) + if len(req.PublishTime) > 1 { + t, err := parsePublishTime(req.PublishTime) if err != nil { - return msgResponse(utils.Ok.Code, "时间错误"), nil + return msgResponse(int32(utils.ErrorMissingParams.GetCode()), "时间错误"), nil } publishTime = t } var check dao.ProductCheckExist err := model.ProductModel{}.Init().GetOne(modelbase.Params{ - Eq: map[string]string{"name": in.GetName()}, + Eq: map[string]string{"name": req.Name}, }, &check) if err != nil { log.Errorf("check product name: %v", err) @@ -75,33 +76,33 @@ func (l *AddLogic) Add(in *product.AddReq) (*product.Response, error) { adminName := "" data := dao.ProductCreate{ - Name: in.GetName(), - Subhead: in.GetSubhead(), - Content: in.GetContent(), - ModelCode: in.GetModelCode(), - Price: float32(in.GetPrice()), - StorePrice: float32(in.GetStorePrice()), - SalePrice: float32(in.GetSalePrice()), - SharePrice: float32(in.GetSharePrice()), - AgentPrice: float32(in.GetAgentPrice()), - SaleReward: in.GetSaleReward(), - Waybill: in.GetWaybill(), - SalesModel: uint8(in.GetSalesModel()), - Weight: float32(in.GetWeight()), - Images: in.GetImages(), - PeriodValidity: int16(in.GetPeriodValidity()), - Type: uint8(in.GetType()), - NormsNumber: uint8(in.GetNormsNumber()), - Number: uint(in.GetNumber()), + Name: req.Name, + Subhead: req.Subhead, + Content: req.Content, + ModelCode: req.ModelCode, + Price: float32(req.Price), + StorePrice: float32(req.StorePrice), + SalePrice: float32(req.SalePrice), + SharePrice: float32(req.SharePrice), + AgentPrice: float32(req.AgentPrice), + SaleReward: req.SaleReward, + Waybill: req.Waybill, + SalesModel: uint8(req.SalesModel), + Weight: float32(req.Weight), + Images: req.Images, + PeriodValidity: int16(req.PeriodValidity), + Type: uint8(req.Type), + NormsNumber: uint8(req.NormsNumber), + Number: uint(req.Number), Sort: 1, - Label: in.GetLabel(), - Cubage: in.GetCubage(), - BoxNumber: in.GetBoxNumber(), - IsIndex: uint8(in.GetIsIndex()), - IndexImage: in.GetIndexImage(), - IsBuy: uint8(in.GetIsBuy()), + Label: req.Label, + Cubage: req.Cubage, + BoxNumber: req.BoxNumber, + IsIndex: uint8(req.IsIndex), + IndexImage: req.IndexImage, + IsBuy: uint8(req.IsBuy), PublishTime: publishTime, - TryNumber: uint8(in.GetTryNumber()), + TryNumber: uint8(req.TryNumber), AdminName: adminName, AdminId: adminId, } @@ -111,18 +112,9 @@ func (l *AddLogic) Add(in *product.AddReq) (*product.Response, error) { if data.IsBuy == 0 { data.IsBuy = 2 } - if data.Type == 0 { - data.Type = dao.ProductTypeNormal - } - if data.NormsNumber == 0 { - data.NormsNumber = 1 - } if data.TryNumber == 0 { data.TryNumber = 1 } - if data.SalesModel == 0 { - data.SalesModel = dao.ProductSalesModelOffline - } err = l.svcCtx.DB.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { if err := (model.ProductModel{}.Init().WithTX(tx).Create(&data)); err != nil { @@ -161,14 +153,7 @@ func (l *AddLogic) Add(in *product.AddReq) (*product.Response, error) { return failResponse(utils.Fail), nil } - key := redis.GetRedisKey("product:last_add") - if err := redis.Client.Set(l.ctx, key, in.GetName(), time.Hour).Err(); err != nil { - log.Errorf("redis set %s: %v", key, err) - } else { - log.Infof("add product success id=%d", data.Id) - } - - return okResponse(utils.StringEmpty), nil + return okResponse(utils.StructToJson(data.Id)), nil } func parsePublishTime(s string) (time.Time, error) { diff --git a/product/internal/logic/editlogic.go b/product/internal/logic/editlogic.go deleted file mode 100644 index bf2af25..0000000 --- a/product/internal/logic/editlogic.go +++ /dev/null @@ -1,32 +0,0 @@ -package logic - -import ( - "context" - - "product/internal/svc" - "product/product" - - "pkg.local/utils" - - "github.com/zeromicro/go-zero/core/logx" -) - -type EditLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditLogic { - return &EditLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -func (l *EditLogic) Edit(in *product.EditReq) (*product.Response, error) { - // todo: add your logic here and delete this line - _ = in - return okResponse(utils.StringEmpty), nil -} diff --git a/product/internal/logic/infologic.go b/product/internal/logic/infologic.go new file mode 100644 index 0000000..c238ad4 --- /dev/null +++ b/product/internal/logic/infologic.go @@ -0,0 +1,54 @@ +package logic + +import ( + "context" + "strconv" + + "product/internal/dao" + "product/internal/model" + "product/internal/svc" + "product/product" + "product/validator" + + "pkg.local/log" + "pkg.local/modelbase" + "pkg.local/utils" + validateService "pkg.local/validate" + + "github.com/zeromicro/go-zero/core/logx" +) + +type InfoLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoLogic { + return &InfoLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InfoLogic) Info(in *product.InfoReq) (*product.Response, error) { + var req validator.ProductInfoValidator + if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return msgResponse(utils.Ok.Code, msg), nil + } + + var info dao.ProductInfo + err := model.ProductModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, + }, &info) + if err != nil { + log.Errorf("product info: %v", err) + return failResponse(utils.Fail), nil + } + if info.Id < 1 { + return failResponse(utils.ErrorNotFund), nil + } + + return okResponse(utils.StructToJson(toProductItem(info))), nil +} diff --git a/product/internal/logic/itemslogic.go b/product/internal/logic/itemslogic.go index d91f40e..9dfae91 100644 --- a/product/internal/logic/itemslogic.go +++ b/product/internal/logic/itemslogic.go @@ -2,7 +2,6 @@ package logic import ( "context" - "time" "product/internal/dao" "product/internal/model" @@ -75,48 +74,3 @@ func (l *ItemsLogic) Items(in *product.ItemsReq) (*product.Response, error) { Items: items, })), nil } - -func toProductItem(row dao.ProductInfo) *product.Item { - publishTime := "" - if !row.PublishTime.IsZero() { - publishTime = row.PublishTime.Format(time.DateTime) - } - return &product.Item{ - Id: int64(row.Id), - Name: row.Name, - Subhead: row.Subhead, - Content: row.Content, - ModelCode: row.ModelCode, - Price: float64(row.Price), - StorePrice: float64(row.StorePrice), - SalePrice: float64(row.SalePrice), - SharePrice: float64(row.SharePrice), - AgentPrice: float64(row.AgentPrice), - SaleReward: row.SaleReward, - SalesModel: uint32(row.SalesModel), - Waybill: row.Waybill, - Status: uint32(row.Status), - Weight: float64(row.Weight), - IsIndex: uint32(row.IsIndex), - IndexImage: row.IndexImage, - Cubage: row.Cubage, - Label: row.Label, - Images: row.Images, - IsBuy: uint32(row.IsBuy), - PeriodValidity: int32(row.PeriodValidity), - PublishTime: publishTime, - Type: uint32(row.Type), - NormsNumber: uint32(row.NormsNumber), - BoxNumber: row.BoxNumber, - Sort: uint32(row.Sort), - Number: uint32(row.Number), - VerifyStatus: uint32(row.VerifyStatus), - VerifyId: int64(row.VerifyId), - VerifyName: row.VerifyName, - VerifySecondId: int64(row.VerifySecondId), - VerifySecondName: row.VerifySecondName, - Reason: row.Reason, - AdminName: row.AdminName, - Edit: uint32(row.Edit), - } -} diff --git a/product/internal/logic/nameslogic.go b/product/internal/logic/nameslogic.go new file mode 100644 index 0000000..ff19054 --- /dev/null +++ b/product/internal/logic/nameslogic.go @@ -0,0 +1,51 @@ +package logic + +import ( + "context" + "strconv" + + "product/internal/dao" + "product/internal/model" + "product/internal/svc" + "product/product" + + "pkg.local/log" + "pkg.local/modelbase" + "pkg.local/utils" + + "github.com/zeromicro/go-zero/core/logx" +) + +type NamesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NamesLogic { + return &NamesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *NamesLogic) Names(_ *product.NamesReq) (*product.Response, error) { + var info []dao.ProductNames + err := model.ProductModel{}.Init().Items(modelbase.Params{ + Eq: map[string]string{"status": strconv.Itoa(int(dao.ProductStatusNormal))}, + }, &info) + if err != nil { + log.Errorf("product names: %v", err) + return failResponse(utils.Fail), nil + } + + items := make([]*product.NameItem, 0, len(info)) + for _, row := range info { + items = append(items, &product.NameItem{ + Id: int64(row.Id), + Name: row.Name, + }) + } + return okResponse(utils.StructToJson(items)), nil +} diff --git a/product/internal/logic/sortlogic.go b/product/internal/logic/sortlogic.go new file mode 100644 index 0000000..7a8579f --- /dev/null +++ b/product/internal/logic/sortlogic.go @@ -0,0 +1,66 @@ +package logic + +import ( + "context" + "strconv" + + "product/internal/dao" + "product/internal/model" + "product/internal/svc" + "product/product" + "product/validator" + + "pkg.local/log" + "pkg.local/modelbase" + "pkg.local/utils" + validateService "pkg.local/validate" + + "github.com/zeromicro/go-zero/core/logx" +) + +type SortLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewSortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SortLogic { + return &SortLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *SortLogic) Sort(in *product.SortReq) (*product.Response, error) { + var req validator.ProductSortValidator + if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return msgResponse(utils.Ok.Code, msg), nil + } + + var info dao.ProductSort + w := modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, + } + m := model.ProductModel{}.Init() + err := m.GetOne(w, &info) + if err != nil { + log.Errorf("product sort get: %v", err) + return failResponse(utils.Fail), nil + } + if info.Id < 1 { + return failResponse(utils.ErrorNotFund), nil + } + + info.Sort = uint16(req.Sort) + // 管理员信息后续从 ctx / metadata 取 + info.AdminName = "" + info.AdminId = 0 + + if _, err = m.Edit(w, &info); err != nil { + log.Errorf("product sort edit: %v", err) + return failResponse(utils.Fail), nil + } + + return okResponse(utils.StringEmpty), nil +} diff --git a/product/internal/logic/statuslogic.go b/product/internal/logic/statuslogic.go new file mode 100644 index 0000000..b64642e --- /dev/null +++ b/product/internal/logic/statuslogic.go @@ -0,0 +1,75 @@ +package logic + +import ( + "context" + "strconv" + + "product/internal/dao" + "product/internal/model" + "product/internal/svc" + "product/product" + "product/validator" + + "pkg.local/log" + "pkg.local/modelbase" + "pkg.local/utils" + validateService "pkg.local/validate" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StatusLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusLogic { + return &StatusLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *StatusLogic) Status(in *product.StatusReq) (*product.Response, error) { + var req validator.ProductStatusValidator + if msg := validateService.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return msgResponse(utils.Ok.Code, msg), nil + } + + if req.Status == uint32(dao.ProductStatusDisabled) && len(req.Reason) < 1 { + return failResponse(utils.ErrorReasonParams), nil + } + + var info dao.ProductCheckExist + w := modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(req.Id, 10), + "verify_status": strconv.Itoa(int(dao.VerifyStatusPass)), + }, + } + m := model.ProductModel{}.Init() + err := m.GetOne(w, &info) + if err != nil { + log.Errorf("product status get: %v", err) + return failResponse(utils.Fail), nil + } + if info.Id < 1 { + return failResponse(utils.ErrorNotFund), nil + } + + // 管理员信息后续从 ctx / metadata 取 + update := dao.ProductStatusUpdate{ + Status: uint8(req.Status), + Reason: req.Reason, + AdminName: "", + AdminId: 0, + } + if _, err = m.Edit(w, &update); err != nil { + log.Errorf("product status edit: %v", err) + return failResponse(utils.Fail), nil + } + + return okResponse(utils.StringEmpty), nil +} diff --git a/product/internal/server/productserver.go b/product/internal/server/productserver.go index baf999d..ea2324d 100644 --- a/product/internal/server/productserver.go +++ b/product/internal/server/productserver.go @@ -22,17 +22,32 @@ func NewProductServer(svcCtx *svc.ServiceContext) *ProductServer { } } -func (s *ProductServer) Add(ctx context.Context, in *product.AddReq) (*product.Response, error) { - l := logic.NewAddLogic(ctx, s.svcCtx) - return l.Add(in) +func (s *ProductServer) Create(ctx context.Context, in *product.CreateReq) (*product.Response, error) { + l := logic.NewCreateLogic(ctx, s.svcCtx) + return l.Create(in) } -func (s *ProductServer) Edit(ctx context.Context, in *product.EditReq) (*product.Response, error) { - l := logic.NewEditLogic(ctx, s.svcCtx) - return l.Edit(in) +func (s *ProductServer) Info(ctx context.Context, in *product.InfoReq) (*product.Response, error) { + l := logic.NewInfoLogic(ctx, s.svcCtx) + return l.Info(in) } func (s *ProductServer) Items(ctx context.Context, in *product.ItemsReq) (*product.Response, error) { l := logic.NewItemsLogic(ctx, s.svcCtx) return l.Items(in) } + +func (s *ProductServer) Names(ctx context.Context, in *product.NamesReq) (*product.Response, error) { + l := logic.NewNamesLogic(ctx, s.svcCtx) + return l.Names(in) +} + +func (s *ProductServer) Status(ctx context.Context, in *product.StatusReq) (*product.Response, error) { + l := logic.NewStatusLogic(ctx, s.svcCtx) + return l.Status(in) +} + +func (s *ProductServer) Sort(ctx context.Context, in *product.SortReq) (*product.Response, error) { + l := logic.NewSortLogic(ctx, s.svcCtx) + return l.Sort(in) +} diff --git a/product/product/product.pb.go b/product/product/product.pb.go index 15466a3..156c1fa 100644 --- a/product/product/product.pb.go +++ b/product/product/product.pb.go @@ -7,7 +7,6 @@ package product import ( - _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -83,6 +82,294 @@ func (x *Response) GetData() string { return "" } +type CreateReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Subhead string `protobuf:"bytes,2,opt,name=subhead,proto3" json:"subhead,omitempty"` + Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` + SalesModel uint32 `protobuf:"varint,4,opt,name=sales_model,json=salesModel,proto3" json:"sales_model,omitempty"` + ModelCode string `protobuf:"bytes,5,opt,name=model_code,json=modelCode,proto3" json:"model_code,omitempty"` + Price float64 `protobuf:"fixed64,6,opt,name=price,proto3" json:"price,omitempty"` + StorePrice float64 `protobuf:"fixed64,7,opt,name=store_price,json=storePrice,proto3" json:"store_price,omitempty"` + SalePrice float64 `protobuf:"fixed64,8,opt,name=sale_price,json=salePrice,proto3" json:"sale_price,omitempty"` + 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"` + 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"` + PeriodValidity int32 `protobuf:"varint,16,opt,name=period_validity,json=periodValidity,proto3" json:"period_validity,omitempty"` + NormsNumber uint32 `protobuf:"varint,17,opt,name=norms_number,json=normsNumber,proto3" json:"norms_number,omitempty"` + BoxNumber float64 `protobuf:"fixed64,18,opt,name=box_number,json=boxNumber,proto3" json:"box_number,omitempty"` + Type uint32 `protobuf:"varint,19,opt,name=type,proto3" json:"type,omitempty"` + Number uint32 `protobuf:"varint,20,opt,name=number,proto3" json:"number,omitempty"` + TryNumber uint32 `protobuf:"varint,21,opt,name=try_number,json=tryNumber,proto3" json:"try_number,omitempty"` + PublishTime string `protobuf:"bytes,22,opt,name=publish_time,json=publishTime,proto3" json:"publish_time,omitempty"` + Label string `protobuf:"bytes,23,opt,name=label,proto3" json:"label,omitempty"` + IsBuy uint32 `protobuf:"varint,24,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` + IsIndex uint32 `protobuf:"varint,25,opt,name=is_index,json=isIndex,proto3" json:"is_index,omitempty"` + IndexImage string `protobuf:"bytes,26,opt,name=index_image,json=indexImage,proto3" json:"index_image,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateReq) Reset() { + *x = CreateReq{} + mi := &file_proto_admin_product_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateReq) ProtoMessage() {} + +func (x *CreateReq) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_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 CreateReq.ProtoReflect.Descriptor instead. +func (*CreateReq) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateReq) GetSubhead() string { + if x != nil { + return x.Subhead + } + return "" +} + +func (x *CreateReq) GetContent() string { + if x != nil { + return x.Content + } + return "" +} + +func (x *CreateReq) GetSalesModel() uint32 { + if x != nil { + return x.SalesModel + } + return 0 +} + +func (x *CreateReq) GetModelCode() string { + if x != nil { + return x.ModelCode + } + return "" +} + +func (x *CreateReq) GetPrice() float64 { + if x != nil { + return x.Price + } + return 0 +} + +func (x *CreateReq) GetStorePrice() float64 { + if x != nil { + return x.StorePrice + } + return 0 +} + +func (x *CreateReq) GetSalePrice() float64 { + if x != nil { + return x.SalePrice + } + return 0 +} + +func (x *CreateReq) GetSharePrice() float64 { + if x != nil { + return x.SharePrice + } + return 0 +} + +func (x *CreateReq) GetAgentPrice() float64 { + if x != nil { + return x.AgentPrice + } + return 0 +} + +func (x *CreateReq) GetSaleReward() string { + if x != nil { + return x.SaleReward + } + return "" +} + +func (x *CreateReq) GetImages() string { + if x != nil { + return x.Images + } + return "" +} + +func (x *CreateReq) GetWeight() float64 { + if x != nil { + return x.Weight + } + return 0 +} + +func (x *CreateReq) GetCubage() string { + if x != nil { + return x.Cubage + } + return "" +} + +func (x *CreateReq) GetWaybill() string { + if x != nil { + return x.Waybill + } + return "" +} + +func (x *CreateReq) GetPeriodValidity() int32 { + if x != nil { + return x.PeriodValidity + } + return 0 +} + +func (x *CreateReq) GetNormsNumber() uint32 { + if x != nil { + return x.NormsNumber + } + return 0 +} + +func (x *CreateReq) GetBoxNumber() float64 { + if x != nil { + return x.BoxNumber + } + return 0 +} + +func (x *CreateReq) GetType() uint32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *CreateReq) GetNumber() uint32 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *CreateReq) GetTryNumber() uint32 { + if x != nil { + return x.TryNumber + } + return 0 +} + +func (x *CreateReq) GetPublishTime() string { + if x != nil { + return x.PublishTime + } + return "" +} + +func (x *CreateReq) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *CreateReq) GetIsBuy() uint32 { + if x != nil { + return x.IsBuy + } + return 0 +} + +func (x *CreateReq) GetIsIndex() uint32 { + if x != nil { + return x.IsIndex + } + return 0 +} + +func (x *CreateReq) GetIndexImage() string { + if x != nil { + return x.IndexImage + } + return "" +} + +type InfoReq 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 *InfoReq) Reset() { + *x = InfoReq{} + mi := &file_proto_admin_product_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InfoReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoReq) ProtoMessage() {} + +func (x *InfoReq) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_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 InfoReq.ProtoReflect.Descriptor instead. +func (*InfoReq) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{2} +} + +func (x *InfoReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + type ItemsReq struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -94,7 +381,7 @@ type ItemsReq struct { func (x *ItemsReq) Reset() { *x = ItemsReq{} - mi := &file_proto_admin_product_proto_msgTypes[1] + mi := &file_proto_admin_product_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -106,7 +393,7 @@ func (x *ItemsReq) String() string { func (*ItemsReq) ProtoMessage() {} func (x *ItemsReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_admin_product_proto_msgTypes[1] + mi := &file_proto_admin_product_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -119,7 +406,7 @@ func (x *ItemsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsReq.ProtoReflect.Descriptor instead. func (*ItemsReq) Descriptor() ([]byte, []int) { - return file_proto_admin_product_proto_rawDescGZIP(), []int{1} + return file_proto_admin_product_proto_rawDescGZIP(), []int{3} } func (x *ItemsReq) GetName() string { @@ -143,6 +430,154 @@ func (x *ItemsReq) GetPageSize() uint32 { return 0 } +type NamesReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NamesReq) Reset() { + *x = NamesReq{} + mi := &file_proto_admin_product_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NamesReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamesReq) ProtoMessage() {} + +func (x *NamesReq) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_product_proto_msgTypes[4] + 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 NamesReq.ProtoReflect.Descriptor instead. +func (*NamesReq) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{4} +} + +type StatusReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Status uint32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StatusReq) Reset() { + *x = StatusReq{} + mi := &file_proto_admin_product_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StatusReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusReq) ProtoMessage() {} + +func (x *StatusReq) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_product_proto_msgTypes[5] + 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 StatusReq.ProtoReflect.Descriptor instead. +func (*StatusReq) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{5} +} + +func (x *StatusReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *StatusReq) GetStatus() uint32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *StatusReq) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +type SortReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Sort uint32 `protobuf:"varint,2,opt,name=sort,proto3" json:"sort,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SortReq) Reset() { + *x = SortReq{} + mi := &file_proto_admin_product_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SortReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SortReq) ProtoMessage() {} + +func (x *SortReq) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_product_proto_msgTypes[6] + 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 SortReq.ProtoReflect.Descriptor instead. +func (*SortReq) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{6} +} + +func (x *SortReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *SortReq) GetSort() uint32 { + if x != nil { + return x.Sort + } + return 0 +} + type ItemsData struct { state protoimpl.MessageState `protogen:"open.v1"` Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` @@ -153,7 +588,7 @@ type ItemsData struct { func (x *ItemsData) Reset() { *x = ItemsData{} - mi := &file_proto_admin_product_proto_msgTypes[2] + mi := &file_proto_admin_product_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -165,7 +600,7 @@ func (x *ItemsData) String() string { func (*ItemsData) ProtoMessage() {} func (x *ItemsData) ProtoReflect() protoreflect.Message { - mi := &file_proto_admin_product_proto_msgTypes[2] + mi := &file_proto_admin_product_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -178,7 +613,7 @@ func (x *ItemsData) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsData.ProtoReflect.Descriptor instead. func (*ItemsData) Descriptor() ([]byte, []int) { - return file_proto_admin_product_proto_rawDescGZIP(), []int{2} + return file_proto_admin_product_proto_rawDescGZIP(), []int{7} } func (x *ItemsData) GetCount() int64 { @@ -195,6 +630,58 @@ func (x *ItemsData) GetItems() []*Item { return nil } +type NameItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *NameItem) Reset() { + *x = NameItem{} + mi := &file_proto_admin_product_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *NameItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NameItem) ProtoMessage() {} + +func (x *NameItem) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_product_proto_msgTypes[8] + 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 NameItem.ProtoReflect.Descriptor instead. +func (*NameItem) Descriptor() ([]byte, []int) { + return file_proto_admin_product_proto_rawDescGZIP(), []int{8} +} + +func (x *NameItem) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *NameItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + type Item struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -239,7 +726,7 @@ type Item struct { func (x *Item) Reset() { *x = Item{} - mi := &file_proto_admin_product_proto_msgTypes[3] + mi := &file_proto_admin_product_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -251,7 +738,7 @@ func (x *Item) String() string { func (*Item) ProtoMessage() {} func (x *Item) ProtoReflect() protoreflect.Message { - mi := &file_proto_admin_product_proto_msgTypes[3] + mi := &file_proto_admin_product_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -264,7 +751,7 @@ func (x *Item) ProtoReflect() protoreflect.Message { // Deprecated: Use Item.ProtoReflect.Descriptor instead. func (*Item) Descriptor() ([]byte, []int) { - return file_proto_admin_product_proto_rawDescGZIP(), []int{3} + return file_proto_admin_product_proto_rawDescGZIP(), []int{9} } func (x *Item) GetId() int64 { @@ -519,415 +1006,74 @@ func (x *Item) GetEdit() uint32 { return 0 } -type AddReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Subhead string `protobuf:"bytes,2,opt,name=subhead,proto3" json:"subhead,omitempty"` - Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` - SalesModel uint32 `protobuf:"varint,4,opt,name=sales_model,json=salesModel,proto3" json:"sales_model,omitempty"` - ModelCode string `protobuf:"bytes,5,opt,name=model_code,json=modelCode,proto3" json:"model_code,omitempty"` - Price float64 `protobuf:"fixed64,6,opt,name=price,proto3" json:"price,omitempty"` - StorePrice float64 `protobuf:"fixed64,7,opt,name=store_price,json=storePrice,proto3" json:"store_price,omitempty"` - SalePrice float64 `protobuf:"fixed64,8,opt,name=sale_price,json=salePrice,proto3" json:"sale_price,omitempty"` - 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"` - 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"` - PeriodValidity int32 `protobuf:"varint,16,opt,name=period_validity,json=periodValidity,proto3" json:"period_validity,omitempty"` - NormsNumber uint32 `protobuf:"varint,17,opt,name=norms_number,json=normsNumber,proto3" json:"norms_number,omitempty"` - BoxNumber float64 `protobuf:"fixed64,18,opt,name=box_number,json=boxNumber,proto3" json:"box_number,omitempty"` - Type uint32 `protobuf:"varint,19,opt,name=type,proto3" json:"type,omitempty"` - Number uint32 `protobuf:"varint,20,opt,name=number,proto3" json:"number,omitempty"` - TryNumber uint32 `protobuf:"varint,21,opt,name=try_number,json=tryNumber,proto3" json:"try_number,omitempty"` - PublishTime string `protobuf:"bytes,22,opt,name=publish_time,json=publishTime,proto3" json:"publish_time,omitempty"` - Label string `protobuf:"bytes,23,opt,name=label,proto3" json:"label,omitempty"` - IsBuy uint32 `protobuf:"varint,24,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` - IsIndex uint32 `protobuf:"varint,25,opt,name=is_index,json=isIndex,proto3" json:"is_index,omitempty"` - IndexImage string `protobuf:"bytes,26,opt,name=index_image,json=indexImage,proto3" json:"index_image,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AddReq) Reset() { - *x = AddReq{} - mi := &file_proto_admin_product_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AddReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AddReq) ProtoMessage() {} - -func (x *AddReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_admin_product_proto_msgTypes[4] - 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 AddReq.ProtoReflect.Descriptor instead. -func (*AddReq) Descriptor() ([]byte, []int) { - return file_proto_admin_product_proto_rawDescGZIP(), []int{4} -} - -func (x *AddReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *AddReq) GetSubhead() string { - if x != nil { - return x.Subhead - } - return "" -} - -func (x *AddReq) GetContent() string { - if x != nil { - return x.Content - } - return "" -} - -func (x *AddReq) GetSalesModel() uint32 { - if x != nil { - return x.SalesModel - } - return 0 -} - -func (x *AddReq) GetModelCode() string { - if x != nil { - return x.ModelCode - } - return "" -} - -func (x *AddReq) GetPrice() float64 { - if x != nil { - return x.Price - } - return 0 -} - -func (x *AddReq) GetStorePrice() float64 { - if x != nil { - return x.StorePrice - } - return 0 -} - -func (x *AddReq) GetSalePrice() float64 { - if x != nil { - return x.SalePrice - } - return 0 -} - -func (x *AddReq) GetSharePrice() float64 { - if x != nil { - return x.SharePrice - } - return 0 -} - -func (x *AddReq) GetAgentPrice() float64 { - if x != nil { - return x.AgentPrice - } - return 0 -} - -func (x *AddReq) GetSaleReward() string { - if x != nil { - return x.SaleReward - } - return "" -} - -func (x *AddReq) GetImages() string { - if x != nil { - return x.Images - } - return "" -} - -func (x *AddReq) GetWeight() float64 { - if x != nil { - return x.Weight - } - return 0 -} - -func (x *AddReq) GetCubage() string { - if x != nil { - return x.Cubage - } - return "" -} - -func (x *AddReq) GetWaybill() string { - if x != nil { - return x.Waybill - } - return "" -} - -func (x *AddReq) GetPeriodValidity() int32 { - if x != nil { - return x.PeriodValidity - } - return 0 -} - -func (x *AddReq) GetNormsNumber() uint32 { - if x != nil { - return x.NormsNumber - } - return 0 -} - -func (x *AddReq) GetBoxNumber() float64 { - if x != nil { - return x.BoxNumber - } - return 0 -} - -func (x *AddReq) GetType() uint32 { - if x != nil { - return x.Type - } - return 0 -} - -func (x *AddReq) GetNumber() uint32 { - if x != nil { - return x.Number - } - return 0 -} - -func (x *AddReq) GetTryNumber() uint32 { - if x != nil { - return x.TryNumber - } - return 0 -} - -func (x *AddReq) GetPublishTime() string { - if x != nil { - return x.PublishTime - } - return "" -} - -func (x *AddReq) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -func (x *AddReq) GetIsBuy() uint32 { - if x != nil { - return x.IsBuy - } - return 0 -} - -func (x *AddReq) GetIsIndex() uint32 { - if x != nil { - return x.IsIndex - } - return 0 -} - -func (x *AddReq) GetIndexImage() string { - if x != nil { - return x.IndexImage - } - return "" -} - -type EditReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Subhead string `protobuf:"bytes,3,opt,name=subhead,proto3" json:"subhead,omitempty"` - Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` - Waybill string `protobuf:"bytes,5,opt,name=waybill,proto3" json:"waybill,omitempty"` - Weight float32 `protobuf:"fixed32,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"` - 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"` - IsBuy uint32 `protobuf:"varint,12,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` - IsIndex uint32 `protobuf:"varint,13,opt,name=is_index,json=isIndex,proto3" json:"is_index,omitempty"` - IndexImage string `protobuf:"bytes,14,opt,name=index_image,json=indexImage,proto3" json:"index_image,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *EditReq) Reset() { - *x = EditReq{} - mi := &file_proto_admin_product_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *EditReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EditReq) ProtoMessage() {} - -func (x *EditReq) ProtoReflect() protoreflect.Message { - mi := &file_proto_admin_product_proto_msgTypes[5] - 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 EditReq.ProtoReflect.Descriptor instead. -func (*EditReq) Descriptor() ([]byte, []int) { - return file_proto_admin_product_proto_rawDescGZIP(), []int{5} -} - -func (x *EditReq) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *EditReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *EditReq) GetSubhead() string { - if x != nil { - return x.Subhead - } - return "" -} - -func (x *EditReq) GetContent() string { - if x != nil { - return x.Content - } - return "" -} - -func (x *EditReq) GetWaybill() string { - if x != nil { - return x.Waybill - } - return "" -} - -func (x *EditReq) GetWeight() float32 { - if x != nil { - return x.Weight - } - return 0 -} - -func (x *EditReq) GetCubage() string { - if x != nil { - return x.Cubage - } - return "" -} - -func (x *EditReq) GetImages() string { - if x != nil { - return x.Images - } - return "" -} - -func (x *EditReq) GetPeriodValidity() int32 { - if x != nil { - return x.PeriodValidity - } - return 0 -} - -func (x *EditReq) GetPublishTime() string { - if x != nil { - return x.PublishTime - } - return "" -} - -func (x *EditReq) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -func (x *EditReq) GetIsBuy() uint32 { - if x != nil { - return x.IsBuy - } - return 0 -} - -func (x *EditReq) GetIsIndex() uint32 { - if x != nil { - return x.IsIndex - } - return 0 -} - -func (x *EditReq) GetIndexImage() string { - if x != nil { - return x.IndexImage - } - return "" -} - var File_proto_admin_product_proto protoreflect.FileDescriptor const file_proto_admin_product_proto_rawDesc = "" + "\n" + - "\x19proto/admin/product.proto\x12\aproduct\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/api/annotations.proto\"D\n" + + "\x19proto/admin/product.proto\x12\aproduct\x1a\x1cgoogle/api/annotations.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\"s\n" + - "\bItemsReq\x12\x1c\n" + - "\x04name\x18\x01 \x01(\tB\b\xbaH\x05r\x03\x18\x80\x02R\x04name\x12\x1e\n" + - "\x04page\x18\x02 \x01(\rB\n" + - "\xbaH\a\xd8\x01\x01*\x02(\x01R\x04page\x12)\n" + - "\tpage_size\x18\x03 \x01(\rB\f\xbaH\t\xd8\x01\x01*\x04\x18d(\x01R\bpageSize\"F\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\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" + + "\acontent\x18\x03 \x01(\tR\acontent\x12\x1f\n" + + "\vsales_model\x18\x04 \x01(\rR\n" + + "salesModel\x12\x1d\n" + + "\n" + + "model_code\x18\x05 \x01(\tR\tmodelCode\x12\x14\n" + + "\x05price\x18\x06 \x01(\x01R\x05price\x12\x1f\n" + + "\vstore_price\x18\a \x01(\x01R\n" + + "storePrice\x12\x1d\n" + + "\n" + + "sale_price\x18\b \x01(\x01R\tsalePrice\x12\x1f\n" + + "\vshare_price\x18\t \x01(\x01R\n" + + "sharePrice\x12\x1f\n" + + "\vagent_price\x18\n" + + " \x01(\x01R\n" + + "agentPrice\x12\x1f\n" + + "\vsale_reward\x18\v \x01(\tR\n" + + "saleReward\x12\x16\n" + + "\x06images\x18\f \x01(\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" + + "\x0fperiod_validity\x18\x10 \x01(\x05R\x0eperiodValidity\x12!\n" + + "\fnorms_number\x18\x11 \x01(\rR\vnormsNumber\x12\x1d\n" + + "\n" + + "box_number\x18\x12 \x01(\x01R\tboxNumber\x12\x12\n" + + "\x04type\x18\x13 \x01(\rR\x04type\x12\x16\n" + + "\x06number\x18\x14 \x01(\rR\x06number\x12\x1d\n" + + "\n" + + "try_number\x18\x15 \x01(\rR\ttryNumber\x12!\n" + + "\fpublish_time\x18\x16 \x01(\tR\vpublishTime\x12\x14\n" + + "\x05label\x18\x17 \x01(\tR\x05label\x12\x15\n" + + "\x06is_buy\x18\x18 \x01(\rR\x05isBuy\x12\x19\n" + + "\bis_index\x18\x19 \x01(\rR\aisIndex\x12\x1f\n" + + "\vindex_image\x18\x1a \x01(\tR\n" + + "indexImage\"\x19\n" + + "\aInfoReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"O\n" + + "\bItemsReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" + + "\x04page\x18\x02 \x01(\rR\x04page\x12\x1b\n" + + "\tpage_size\x18\x03 \x01(\rR\bpageSize\"\n" + + "\n" + + "\bNamesReq\"K\n" + + "\tStatusReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + + "\x06status\x18\x02 \x01(\rR\x06status\x12\x16\n" + + "\x06reason\x18\x03 \x01(\tR\x06reason\"-\n" + + "\aSortReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04sort\x18\x02 \x01(\rR\x04sort\"F\n" + "\tItemsData\x12\x14\n" + "\x05count\x18\x01 \x01(\x03R\x05count\x12#\n" + - "\x05items\x18\x02 \x03(\v2\r.product.ItemR\x05items\"\x8e\b\n" + + "\x05items\x18\x02 \x03(\v2\r.product.ItemR\x05items\".\n" + + "\bNameItem\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\"\x8e\b\n" + "\x04Item\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" + @@ -976,74 +1122,14 @@ const file_proto_admin_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\x04edit\"\xab\b\n" + - "\x06AddReq\x12\x1e\n" + - "\x04name\x18\x01 \x01(\tB\n" + - "\xbaH\ar\x05\x10\x01\x18\x80\x02R\x04name\x12\"\n" + - "\asubhead\x18\x02 \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\asubhead\x12!\n" + - "\acontent\x18\x03 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\acontent\x12-\n" + - "\vsales_model\x18\x04 \x01(\rB\f\xbaH\t\xd8\x01\x01*\x040\x010\x02R\n" + - "salesModel\x12'\n" + - "\n" + - "model_code\x18\x05 \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\tmodelCode\x12$\n" + - "\x05price\x18\x06 \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\x05price\x122\n" + - "\vstore_price\x18\a \x01(\x01B\x11\xbaH\x0e\xd8\x01\x01\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\n" + - "storePrice\x12-\n" + - "\n" + - "sale_price\x18\b \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\tsalePrice\x12/\n" + - "\vshare_price\x18\t \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\n" + - "sharePrice\x12/\n" + - "\vagent_price\x18\n" + - " \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\n" + - "agentPrice\x12)\n" + - "\vsale_reward\x18\v \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\n" + - "saleReward\x12\"\n" + - "\x06images\x18\f \x01(\tB\n" + - "\xbaH\ar\x05\x10\x01\x18\x80\x04R\x06images\x12&\n" + - "\x06weight\x18\r \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\x06weight\x12 \n" + - "\x06cubage\x18\x0e \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\x06cubage\x12\"\n" + - "\awaybill\x18\x0f \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\awaybill\x120\n" + - "\x0fperiod_validity\x18\x10 \x01(\x05B\a\xbaH\x04\x1a\x02(\x00R\x0eperiodValidity\x12-\n" + - "\fnorms_number\x18\x11 \x01(\rB\n" + - "\xbaH\a\xd8\x01\x01*\x02(\x01R\vnormsNumber\x12-\n" + - "\n" + - "box_number\x18\x12 \x01(\x01B\x0e\xbaH\v\x12\t)\x00\x00\x00\x00\x00\x00\x00\x00R\tboxNumber\x12\"\n" + - "\x04type\x18\x13 \x01(\rB\x0e\xbaH\v\xd8\x01\x01*\x060\x010\x020\x03R\x04type\x12\x16\n" + - "\x06number\x18\x14 \x01(\rR\x06number\x12)\n" + - "\n" + - "try_number\x18\x15 \x01(\rB\n" + - "\xbaH\a\xd8\x01\x01*\x02(\x01R\ttryNumber\x12*\n" + - "\fpublish_time\x18\x16 \x01(\tB\a\xbaH\x04r\x02\x18 R\vpublishTime\x12\x1e\n" + - "\x05label\x18\x17 \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\x05label\x12#\n" + - "\x06is_buy\x18\x18 \x01(\rB\f\xbaH\t\xd8\x01\x01*\x040\x010\x02R\x05isBuy\x12'\n" + - "\bis_index\x18\x19 \x01(\rB\f\xbaH\t\xd8\x01\x01*\x040\x010\x02R\aisIndex\x12)\n" + - "\vindex_image\x18\x1a \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\n" + - "indexImage\"\x8e\x04\n" + - "\aEditReq\x12\x17\n" + - "\x02id\x18\x01 \x01(\x03B\a\xbaH\x04\"\x02 \x00R\x02id\x12\x1e\n" + - "\x04name\x18\x02 \x01(\tB\n" + - "\xbaH\ar\x05\x10\x01\x18\x80\x02R\x04name\x12\"\n" + - "\asubhead\x18\x03 \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\asubhead\x12!\n" + - "\acontent\x18\x04 \x01(\tB\a\xbaH\x04r\x02\x10\x01R\acontent\x12\"\n" + - "\awaybill\x18\x05 \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\awaybill\x12\"\n" + - "\x06weight\x18\x06 \x01(\x02B\n" + - "\xbaH\a\n" + - "\x05-\x00\x00\x00\x00R\x06weight\x12 \n" + - "\x06cubage\x18\a \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\x06cubage\x12\"\n" + - "\x06images\x18\b \x01(\tB\n" + - "\xbaH\ar\x05\x10\x01\x18\x80\x04R\x06images\x120\n" + - "\x0fperiod_validity\x18\t \x01(\x05B\a\xbaH\x04\x1a\x02(\x00R\x0eperiodValidity\x12*\n" + - "\fpublish_time\x18\n" + - " \x01(\tB\a\xbaH\x04r\x02\x18 R\vpublishTime\x12\x1e\n" + - "\x05label\x18\v \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\x05label\x12#\n" + - "\x06is_buy\x18\f \x01(\rB\f\xbaH\t\xd8\x01\x01*\x040\x010\x02R\x05isBuy\x12'\n" + - "\bis_index\x18\r \x01(\rB\f\xbaH\t\xd8\x01\x01*\x040\x010\x02R\aisIndex\x12)\n" + - "\vindex_image\x18\x0e \x01(\tB\b\xbaH\x05r\x03\x18\xff\x01R\n" + - "indexImage2\xe7\x01\n" + - "\aProduct\x12G\n" + - "\x03Add\x12\x0f.product.AddReq\x1a\x11.product.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/admin/v3/product\x12I\n" + - "\x04Edit\x12\x10.product.EditReq\x1a\x11.product.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x1a\x11/admin/v3/product\x12H\n" + - "\x05Items\x12\x11.product.ItemsReq\x1a\x11.product.Response\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/admin/v3/productB\vZ\t./productb\x06proto3" + "\x04edit\x18$ \x01(\rR\x04edit2\xfb\x03\n" + + "\aProduct\x12T\n" + + "\x06Create\x12\x12.product.CreateReq\x1a\x11.product.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/admin/v3/product/create\x12N\n" + + "\x04Info\x12\x10.product.InfoReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x12\x16/admin/v3/product/info\x12Q\n" + + "\x05Items\x12\x11.product.ItemsReq\x1a\x11.product.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/product/items\x12Q\n" + + "\x05Names\x12\x11.product.NamesReq\x1a\x11.product.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/product/names\x12T\n" + + "\x06Status\x12\x12.product.StatusReq\x1a\x11.product.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x1a\x18/admin/v3/product/status\x12N\n" + + "\x04Sort\x12\x10.product.SortReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/admin/v3/product/sortB\vZ\t./productb\x06proto3" var ( file_proto_admin_product_proto_rawDescOnce sync.Once @@ -1057,25 +1143,35 @@ func file_proto_admin_product_proto_rawDescGZIP() []byte { return file_proto_admin_product_proto_rawDescData } -var file_proto_admin_product_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_proto_admin_product_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_proto_admin_product_proto_goTypes = []any{ (*Response)(nil), // 0: product.Response - (*ItemsReq)(nil), // 1: product.ItemsReq - (*ItemsData)(nil), // 2: product.ItemsData - (*Item)(nil), // 3: product.Item - (*AddReq)(nil), // 4: product.AddReq - (*EditReq)(nil), // 5: product.EditReq + (*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 + (*ItemsData)(nil), // 7: product.ItemsData + (*NameItem)(nil), // 8: product.NameItem + (*Item)(nil), // 9: product.Item } var file_proto_admin_product_proto_depIdxs = []int32{ - 3, // 0: product.ItemsData.items:type_name -> product.Item - 4, // 1: product.Product.Add:input_type -> product.AddReq - 5, // 2: product.Product.Edit:input_type -> product.EditReq - 1, // 3: product.Product.Items:input_type -> product.ItemsReq - 0, // 4: product.Product.Add:output_type -> product.Response - 0, // 5: product.Product.Edit:output_type -> product.Response - 0, // 6: product.Product.Items:output_type -> product.Response - 4, // [4:7] is the sub-list for method output_type - 1, // [1:4] is the sub-list for method input_type + 9, // 0: product.ItemsData.items:type_name -> product.Item + 1, // 1: product.Product.Create:input_type -> product.CreateReq + 2, // 2: product.Product.Info:input_type -> product.InfoReq + 3, // 3: product.Product.Items:input_type -> product.ItemsReq + 4, // 4: product.Product.Names:input_type -> product.NamesReq + 5, // 5: product.Product.Status:input_type -> product.StatusReq + 6, // 6: product.Product.Sort:input_type -> product.SortReq + 0, // 7: product.Product.Create:output_type -> product.Response + 0, // 8: product.Product.Info:output_type -> product.Response + 0, // 9: product.Product.Items:output_type -> product.Response + 0, // 10: product.Product.Names:output_type -> product.Response + 0, // 11: product.Product.Status:output_type -> product.Response + 0, // 12: product.Product.Sort:output_type -> product.Response + 7, // [7:13] is the sub-list for method output_type + 1, // [1:7] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -1092,7 +1188,7 @@ func file_proto_admin_product_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_admin_product_proto_rawDesc), len(file_proto_admin_product_proto_rawDesc)), NumEnums: 0, - NumMessages: 6, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/product/product/product_grpc.pb.go b/product/product/product_grpc.pb.go index f0718f6..9dc8bbc 100644 --- a/product/product/product_grpc.pb.go +++ b/product/product/product_grpc.pb.go @@ -19,18 +19,24 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Product_Add_FullMethodName = "/product.Product/Add" - Product_Edit_FullMethodName = "/product.Product/Edit" - Product_Items_FullMethodName = "/product.Product/Items" + Product_Create_FullMethodName = "/product.Product/Create" + Product_Info_FullMethodName = "/product.Product/Info" + Product_Items_FullMethodName = "/product.Product/Items" + Product_Names_FullMethodName = "/product.Product/Names" + Product_Status_FullMethodName = "/product.Product/Status" + Product_Sort_FullMethodName = "/product.Product/Sort" ) // ProductClient is the client API for Product service. // // 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 ProductClient interface { - Add(ctx context.Context, in *AddReq, opts ...grpc.CallOption) (*Response, error) - Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) + 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) } type productClient struct { @@ -41,20 +47,20 @@ func NewProductClient(cc grpc.ClientConnInterface) ProductClient { return &productClient{cc} } -func (c *productClient) Add(ctx context.Context, in *AddReq, opts ...grpc.CallOption) (*Response, error) { +func (c *productClient) Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) - err := c.cc.Invoke(ctx, Product_Add_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Product_Create_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *productClient) Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) { +func (c *productClient) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) - err := c.cc.Invoke(ctx, Product_Edit_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Product_Info_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -71,13 +77,46 @@ func (c *productClient) Items(ctx context.Context, in *ItemsReq, opts ...grpc.Ca return out, nil } +func (c *productClient) Names(ctx context.Context, in *NamesReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_Names_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productClient) Status(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_Status_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productClient) Sort(ctx context.Context, in *SortReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_Sort_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // ProductServer is the server API for Product service. // All implementations must embed UnimplementedProductServer // for forward compatibility. type ProductServer interface { - Add(context.Context, *AddReq) (*Response, error) - Edit(context.Context, *EditReq) (*Response, error) + Create(context.Context, *CreateReq) (*Response, error) + Info(context.Context, *InfoReq) (*Response, error) Items(context.Context, *ItemsReq) (*Response, error) + Names(context.Context, *NamesReq) (*Response, error) + Status(context.Context, *StatusReq) (*Response, error) + Sort(context.Context, *SortReq) (*Response, error) mustEmbedUnimplementedProductServer() } @@ -88,15 +127,24 @@ type ProductServer interface { // pointer dereference when methods are called. type UnimplementedProductServer struct{} -func (UnimplementedProductServer) Add(context.Context, *AddReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method Add not implemented") +func (UnimplementedProductServer) Create(context.Context, *CreateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Create not implemented") } -func (UnimplementedProductServer) Edit(context.Context, *EditReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method Edit not implemented") +func (UnimplementedProductServer) Info(context.Context, *InfoReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Info not implemented") } func (UnimplementedProductServer) Items(context.Context, *ItemsReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Items not implemented") } +func (UnimplementedProductServer) Names(context.Context, *NamesReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Names not implemented") +} +func (UnimplementedProductServer) Status(context.Context, *StatusReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Status not implemented") +} +func (UnimplementedProductServer) Sort(context.Context, *SortReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Sort not implemented") +} func (UnimplementedProductServer) mustEmbedUnimplementedProductServer() {} func (UnimplementedProductServer) testEmbeddedByValue() {} @@ -118,38 +166,38 @@ func RegisterProductServer(s grpc.ServiceRegistrar, srv ProductServer) { s.RegisterService(&Product_ServiceDesc, srv) } -func _Product_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddReq) +func _Product_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ProductServer).Add(ctx, in) + return srv.(ProductServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Product_Add_FullMethodName, + FullMethod: Product_Create_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductServer).Add(ctx, req.(*AddReq)) + return srv.(ProductServer).Create(ctx, req.(*CreateReq)) } return interceptor(ctx, in, info, handler) } -func _Product_Edit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EditReq) +func _Product_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ProductServer).Edit(ctx, in) + return srv.(ProductServer).Info(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Product_Edit_FullMethodName, + FullMethod: Product_Info_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductServer).Edit(ctx, req.(*EditReq)) + return srv.(ProductServer).Info(ctx, req.(*InfoReq)) } return interceptor(ctx, in, info, handler) } @@ -172,6 +220,60 @@ func _Product_Items_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Product_Names_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NamesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).Names(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_Names_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).Names(ctx, req.(*NamesReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Product_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_Status_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).Status(ctx, req.(*StatusReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Product_Sort_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SortReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).Sort(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_Sort_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).Sort(ctx, req.(*SortReq)) + } + return interceptor(ctx, in, info, handler) +} + // Product_ServiceDesc is the grpc.ServiceDesc for Product service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -180,17 +282,29 @@ var Product_ServiceDesc = grpc.ServiceDesc{ HandlerType: (*ProductServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Add", - Handler: _Product_Add_Handler, + MethodName: "Create", + Handler: _Product_Create_Handler, }, { - MethodName: "Edit", - Handler: _Product_Edit_Handler, + MethodName: "Info", + Handler: _Product_Info_Handler, }, { MethodName: "Items", Handler: _Product_Items_Handler, }, + { + MethodName: "Names", + Handler: _Product_Names_Handler, + }, + { + MethodName: "Status", + Handler: _Product_Status_Handler, + }, + { + MethodName: "Sort", + Handler: _Product_Sort_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/admin/product.proto", diff --git a/product/productclient/product.go b/product/productclient/product.go index 7aa1a13..61e7616 100644 --- a/product/productclient/product.go +++ b/product/productclient/product.go @@ -13,17 +13,24 @@ import ( ) type ( - AddReq = product.AddReq - EditReq = product.EditReq + CreateReq = product.CreateReq + InfoReq = product.InfoReq ItemsReq = product.ItemsReq + NamesReq = product.NamesReq + StatusReq = product.StatusReq + SortReq = product.SortReq ItemsData = product.ItemsData + NameItem = product.NameItem Item = product.Item Response = product.Response Product interface { - Add(ctx context.Context, in *AddReq, opts ...grpc.CallOption) (*Response, error) - Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) + 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) } defaultProduct struct { @@ -37,17 +44,32 @@ func NewProduct(cli zrpc.Client) Product { } } -func (m *defaultProduct) Add(ctx context.Context, in *AddReq, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultProduct) Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) { client := product.NewProductClient(m.cli.Conn()) - return client.Add(ctx, in, opts...) + return client.Create(ctx, in, opts...) } -func (m *defaultProduct) Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultProduct) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) { client := product.NewProductClient(m.cli.Conn()) - return client.Edit(ctx, in, opts...) + 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...) +} diff --git a/product/proto/admin/product.proto b/product/proto/admin/product.proto index 1dd9f42..e06ab6c 100644 --- a/product/proto/admin/product.proto +++ b/product/proto/admin/product.proto @@ -3,25 +3,43 @@ syntax = "proto3"; package product; option go_package="./product"; -import "buf/validate/validate.proto"; import "google/api/annotations.proto"; service Product { - rpc Add(AddReq) returns (Response) { + rpc Create(CreateReq) returns (Response) { option (google.api.http) = { - post: "/admin/v3/product" + post: "/admin/v3/product/create" body: "*" }; } - rpc Edit(EditReq) returns (Response) { + rpc Info(InfoReq) returns (Response) { option (google.api.http) = { - put: "/admin/v3/product" + get: "/admin/v3/product/info" body: "*" }; } rpc Items(ItemsReq) returns (Response) { option (google.api.http) = { get: "/admin/v3/product" + body: "*" + }; + } + rpc Names(NamesReq) returns (Response) { + option (google.api.http) = { + get: "/admin/v3/product/names" + body: "*" + }; + } + rpc Status(StatusReq) returns (Response) { + option (google.api.http) = { + put: "/admin/v3/product/status" + body: "*" + }; + } + rpc Sort(SortReq) returns (Response) { + option (google.api.http) = { + put: "/admin/v3/product/sort" + body: "*" }; } } @@ -32,16 +50,56 @@ message Response { string data = 3; } +message CreateReq { + string name = 1; + string subhead = 2; + string content = 3; + uint32 sales_model = 4; + string model_code = 5; + double price = 6; + double store_price = 7; + double sale_price = 8; + double share_price = 9; + double agent_price = 10; + string sale_reward = 11; + string images = 12; + double weight = 13; + string cubage = 14; + string waybill = 15; + int32 period_validity = 16; + uint32 norms_number = 17; + double box_number = 18; + uint32 type = 19; + uint32 number = 20; + uint32 try_number = 21; + string publish_time = 22; + string label = 23; + uint32 is_buy = 24; + uint32 is_index = 25; + string index_image = 26; +} + +message InfoReq { + int64 id = 1; +} + message ItemsReq { - string name = 1 [(buf.validate.field).string = {max_len: 256}]; - uint32 page = 2 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {gte: 1} - }]; - uint32 page_size = 3 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {gte: 1, lte: 100} - }]; + string name = 1; + uint32 page = 2; + uint32 page_size = 3; +} + +message NamesReq {} + +message StatusReq { + int64 id = 1; + uint32 status = 2; + string reason = 3; +} + +message SortReq { + int64 id = 1; + uint32 sort = 2; } message ItemsData { @@ -49,6 +107,11 @@ message ItemsData { repeated Item items = 2; } +message NameItem { + int64 id = 1; + string name = 2; +} + message Item { int64 id = 1; string name = 2; @@ -87,76 +150,3 @@ message Item { string admin_name = 35; uint32 edit = 36; } - -message AddReq { - string name = 1 [(buf.validate.field).string = {min_len: 1, max_len: 256}]; - string subhead = 2 [(buf.validate.field).string = {max_len: 255}]; - string content = 3 [(buf.validate.field).string = {min_len: 1}]; - uint32 sales_model = 4 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2]} - }]; - string model_code = 5 [(buf.validate.field).string = {max_len: 255}]; - double price = 6 [(buf.validate.field).double = {gte: 0}]; - double store_price = 7 [(buf.validate.field) = {ignore: IGNORE_IF_ZERO_VALUE, double: {gte: 0}}]; - double sale_price = 8 [(buf.validate.field).double = {gte: 0}]; - double share_price = 9 [(buf.validate.field).double = {gte: 0}]; - double agent_price = 10 [(buf.validate.field).double = {gte: 0}]; - string sale_reward = 11 [(buf.validate.field).string = {max_len: 255}]; - string images = 12 [(buf.validate.field).string = {min_len: 1, max_len: 512}]; - double weight = 13 [(buf.validate.field).double = {gte: 0}]; - string cubage = 14 [(buf.validate.field).string = {max_len: 255}]; - string waybill = 15 [(buf.validate.field).string = {max_len: 255}]; - int32 period_validity = 16 [(buf.validate.field).int32 = {gte: 0}]; - uint32 norms_number = 17 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {gte: 1} - }]; - double box_number = 18 [(buf.validate.field).double = {gte: 0}]; - uint32 type = 19 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2, 3]} - }]; - uint32 number = 20; - uint32 try_number = 21 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {gte: 1} - }]; - string publish_time = 22 [(buf.validate.field).string = {max_len: 32}]; - string label = 23 [(buf.validate.field).string = {max_len: 255}]; - uint32 is_buy = 24 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2]} - }]; - uint32 is_index = 25 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2]} - }]; - string index_image = 26 [(buf.validate.field).string = {max_len: 255}]; - - // 删除字段方式 - // reserved 2; -} - -message EditReq { - int64 id = 1 [(buf.validate.field).int64 = {gt: 0}]; - string name = 2 [(buf.validate.field).string = {min_len: 1, max_len: 256}]; - string subhead = 3 [(buf.validate.field).string = {max_len: 255}]; - string content = 4 [(buf.validate.field).string = {min_len: 1}]; - string waybill = 5 [(buf.validate.field).string = {max_len: 255}]; - float weight = 6 [(buf.validate.field).float = {gte: 0}]; - string cubage = 7 [(buf.validate.field).string = {max_len: 255}]; - string images = 8 [(buf.validate.field).string = {min_len: 1, max_len: 512}]; - int32 period_validity = 9 [(buf.validate.field).int32 = {gte: 0}]; - string publish_time = 10 [(buf.validate.field).string = {max_len: 32}]; - string label = 11 [(buf.validate.field).string = {max_len: 255}]; - uint32 is_buy = 12 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2]} - }]; - uint32 is_index = 13 [(buf.validate.field) = { - ignore: IGNORE_IF_ZERO_VALUE, - uint32: {in: [1, 2]} - }]; - string index_image = 14 [(buf.validate.field).string = {max_len: 255}]; -} diff --git a/product/validator/validator.go b/product/validator/validator.go index 3fa1446..4f05953 100644 --- a/product/validator/validator.go +++ b/product/validator/validator.go @@ -4,6 +4,67 @@ import ( "pkg.local/validate" ) +type ProductCreateValidator struct { + Name string `validate:"required,max=256"` + Subhead string `validate:"required,max=255"` + Content string `validate:"required"` + SalesModel uint32 `validate:"required,oneof=1 2"` + ModelCode string `validate:"required,max=255"` + Price float64 `validate:"required"` + StorePrice float64 + 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"` + BoxNumber float64 + Type uint32 `validate:"required,oneof=1 2 3"` + Number uint32 + TryNumber uint32 + 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 ProductCreateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Name.required": "产品名不能为空", + "Name.max": "产品名长度不能超过256", + "Subhead.required": "副标题不能为空", + "Content.required": "内容不能为空", + "SalesModel.required": "销售类型不能为空", + "SalesModel.oneof": "销售类型不对", + "ModelCode.required": "请输入机器码", + "Price.required": "价格不能为空", + "Images.required": "图片不能为空", + "Weight.required": "重量不能为空", + "Cubage.required": "体积不能为空", + "Waybill.required": "运货单图片不能为空", + "PeriodValidity.required": "有效期不能为空", + "NormsNumber.required": "缺少一份中有几个", + "Type.required": "请选择类型", + "Type.oneof": "类型不对", + } +} + +type ProductInfoValidator struct { + Id int64 `validate:"required,gt=0"` +} + +func (p ProductInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Id.gt": "ID必须大于0", + } +} + type ProductItemsValidator struct { Name string `validate:"max=256"` Page uint32 `validate:"omitempty,min=1"` @@ -18,3 +79,31 @@ func (p ProductItemsValidator) GetMessage() validate.ValidatorMessages { "PageSize.max": "每页数量最大为100", } } + +type ProductStatusValidator struct { + Id int64 `validate:"required,gt=0"` + Status uint32 `validate:"required,oneof=1 2 3"` + Reason string `validate:"max=255"` +} + +func (p ProductStatusValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Id.gt": "ID必须大于0", + "Status.required": "状态不能为空", + "Status.oneof": "状态不对", + } +} + +type ProductSortValidator struct { + Id int64 `validate:"required,gt=0"` + Sort uint32 `validate:"required"` +} + +func (p ProductSortValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Id.gt": "ID必须大于0", + "Sort.required": "排序不能为空", + } +}