add service order

This commit is contained in:
yystopf 2023-03-17 17:54:13 +08:00
parent e347cdd750
commit ac7a62045d
35 changed files with 2607 additions and 1 deletions

3
.gitignore vendored
View File

@ -21,4 +21,5 @@ vendor/
go.work
*user.yaml
*product.yaml
*product.yaml
*order.yaml

View File

@ -0,0 +1,16 @@
package config
import (
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
rest.RestConf
Auth struct {
AccessSecret string
AccessExpire int64
}
OrderRpc zrpc.RpcClientConf
}

View File

@ -0,0 +1,28 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mall/service/order/api/internal/logic"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
)
func CreateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewCreateLogic(r.Context(), svcCtx)
resp, err := l.Create(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,28 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mall/service/order/api/internal/logic"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
)
func DetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DetailRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewDetailLogic(r.Context(), svcCtx)
resp, err := l.Detail(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,28 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mall/service/order/api/internal/logic"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
)
func ListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewListLogic(r.Context(), svcCtx)
resp, err := l.List(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,28 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mall/service/order/api/internal/logic"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
)
func RemoveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RemoveRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewRemoveLogic(r.Context(), svcCtx)
resp, err := l.Remove(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,43 @@
// Code generated by goctl. DO NOT EDIT.
package handler
import (
"net/http"
"mall/service/order/api/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/api/order/create",
Handler: CreateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/order/update",
Handler: UpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/order/remove",
Handler: RemoveHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/order/detail",
Handler: DetailHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/api/order/list",
Handler: ListHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
)
}

View File

@ -0,0 +1,28 @@
package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"mall/service/order/api/internal/logic"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
)
func UpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := logic.NewUpdateLogic(r.Context(), svcCtx)
resp, err := l.Update(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

View File

@ -0,0 +1,42 @@
package logic
import (
"context"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateLogic) Create(req *types.CreateRequest) (resp *types.CreateResponse, err error) {
res, err := l.svcCtx.OrderRpc.Create(l.ctx, &orderclient.CreateRequest{
Uid: req.Uid,
Pid: req.Pid,
Amount: req.Amount,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &types.CreateResponse{
Id: res.Id,
}, nil
}

View File

@ -0,0 +1,43 @@
package logic
import (
"context"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/core/logx"
)
type DetailLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailLogic {
return &DetailLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DetailLogic) Detail(req *types.DetailRequest) (resp *types.DetailResponse, err error) {
res, err := l.svcCtx.OrderRpc.Detail(l.ctx, &orderclient.DetailRequest{
Id: req.Id,
})
if err != nil {
return nil, err
}
return &types.DetailResponse{
Id: res.Id,
Uid: res.Uid,
Pid: res.Pid,
Amount: res.Amount,
Status: res.Status,
}, nil
}

View File

@ -0,0 +1,47 @@
package logic
import (
"context"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/core/logx"
)
type ListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
return &ListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ListLogic) List(req *types.ListRequest) (resp []*types.ListResponse, err error) {
res, err := l.svcCtx.OrderRpc.List(l.ctx, &orderclient.ListRequest{
Uid: req.Uid,
})
if err != nil {
return nil, err
}
orderList := make([]*types.ListResponse, 0)
for _, item := range res.Data {
orderList = append(orderList, &types.ListResponse{
Id: item.Id,
Uid: item.Uid,
Pid: item.Pid,
Amount: item.Amount,
Status: item.Status,
})
}
return orderList, nil
}

View File

@ -0,0 +1,36 @@
package logic
import (
"context"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/core/logx"
)
type RemoveLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewRemoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLogic {
return &RemoveLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *RemoveLogic) Remove(req *types.RemoveRequest) (resp *types.RemoveResponse, err error) {
_, err = l.svcCtx.OrderRpc.Remove(l.ctx, &orderclient.RemoveRequest{
Id: req.Id,
})
if err != nil {
return nil, err
}
return &types.RemoveResponse{}, nil
}

View File

@ -0,0 +1,41 @@
package logic
import (
"context"
"mall/service/order/api/internal/svc"
"mall/service/order/api/internal/types"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
return &UpdateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *UpdateLogic) Update(req *types.UpdateRequest) (resp *types.UpdateResponse, err error) {
_, err = l.svcCtx.OrderRpc.Update(l.ctx, &orderclient.UpdateRequest{
Id: req.Id,
Uid: req.Uid,
Pid: req.Pid,
Amount: req.Amount,
Status: req.Status,
})
if err != nil {
return nil, err
}
return &types.UpdateResponse{}, nil
}

View File

@ -0,0 +1,21 @@
package svc
import (
"mall/service/order/api/internal/config"
"mall/service/order/rpc/orderclient"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {
Config config.Config
OrderRpc orderclient.Order
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
OrderRpc: orderclient.NewOrder(zrpc.MustNewClient(c.OrderRpc)),
}
}

View File

@ -0,0 +1,55 @@
// Code generated by goctl. DO NOT EDIT.
package types
type CreateRequest struct {
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}
type CreateResponse struct {
Id int64 `json:"id"`
}
type UpdateRequest struct {
Id int64 `json:"id"`
Uid int64 `json:"uid,optional"`
Pid int64 `json:"pid,optional"`
Amount int64 `json:"amount,optional"`
Status int64 `json:"status,optional"`
}
type UpdateResponse struct {
}
type RemoveRequest struct {
Id int64 `json:"id"`
}
type RemoveResponse struct {
}
type DetailRequest struct {
Id int64 `json:"id"`
}
type DetailResponse struct {
Id int64 `json:"id"`
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}
type ListRequest struct {
Uid int64 `json:"uid"`
}
type ListResponse struct {
Id int64 `json:"id"`
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}

View File

@ -0,0 +1,74 @@
type (
CreateRequest {
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}
CreateResponse {
Id int64 `json:"id"`
}
UpdateRequest {
Id int64 `json:"id"`
Uid int64 `json:"uid,optional"`
Pid int64 `json:"pid,optional"`
Amount int64 `json:"amount,optional"`
Status int64 `json:"status,optional"`
}
UpdateResponse {
}
RemoveRequest {
Id int64 `json:"id"`
}
RemoveResponse {
}
DetailRequest {
Id int64 `json:"id"`
}
DetailResponse {
Id int64 `json:"id"`
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}
ListRequest {
Uid int64 `json:"uid"`
}
ListResponse {
Id int64 `json:"id"`
Uid int64 `json:"uid"`
Pid int64 `json:"pid"`
Amount int64 `json:"amount"`
Status int64 `json:"status"`
}
)
@server(
jwt: Auth
)
service Order {
@handler Create
post /api/order/create(CreateRequest) returns (CreateResponse)
@handler Update
post /api/order/update(UpdateRequest) returns (UpdateResponse)
@handler Remove
post /api/order/remove(RemoveRequest) returns (RemoveResponse)
@handler Detail
post /api/order/detail(DetailRequest) returns (DetailResponse)
@handler List
post /api/order/list(ListRequest) returns (ListResponse)
}

View File

@ -0,0 +1,31 @@
package main
import (
"flag"
"fmt"
"mall/service/order/api/internal/config"
"mall/service/order/api/internal/handler"
"mall/service/order/api/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/order.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
server := rest.MustNewServer(c.RestConf)
defer server.Stop()
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}

View File

@ -0,0 +1,12 @@
CREATE TABLE `order` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`uid` bigint unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`pid` bigint unsigned NOT NULL DEFAULT '0' COMMENT '产品ID',
`amount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '订单金额',
`status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '订单状态',
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_uid` (`uid`),
KEY `idx_pid` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -0,0 +1,27 @@
package model
import (
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ OrderModel = (*customOrderModel)(nil)
type (
// OrderModel is an interface to be customized, add more methods here,
// and implement the added methods in customOrderModel.
OrderModel interface {
orderModel
}
customOrderModel struct {
*defaultOrderModel
}
)
// NewOrderModel returns a model for the database table.
func NewOrderModel(conn sqlx.SqlConn, c cache.CacheConf) OrderModel {
return &customOrderModel{
defaultOrderModel: newOrderModel(conn, c),
}
}

View File

@ -0,0 +1,129 @@
// Code generated by goctl. DO NOT EDIT.
package model
import (
"context"
"database/sql"
"fmt"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/core/stringx"
)
var (
orderFieldNames = builder.RawFieldNames(&Order{})
orderRows = strings.Join(orderFieldNames, ",")
orderRowsExpectAutoSet = strings.Join(stringx.Remove(orderFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
orderRowsWithPlaceHolder = strings.Join(stringx.Remove(orderFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
cacheOrderIdPrefix = "cache:order:id:"
)
type (
orderModel interface {
Insert(ctx context.Context, data *Order) (sql.Result, error)
FindAllByUid(ctx context.Context, uid int64) ([]*Order, error)
FindOne(ctx context.Context, id int64) (*Order, error)
Update(ctx context.Context, data *Order) error
Delete(ctx context.Context, id int64) error
}
defaultOrderModel struct {
sqlc.CachedConn
table string
}
Order struct {
Id int64 `db:"id"`
Uid int64 `db:"uid"` // 用户ID
Pid int64 `db:"pid"` // 产品ID
Amount int64 `db:"amount"` // 订单金额
Status int64 `db:"status"` // 订单状态
CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"`
}
)
func newOrderModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultOrderModel {
return &defaultOrderModel{
CachedConn: sqlc.NewConn(conn, c),
table: "`order`",
}
}
func (m *defaultOrderModel) Delete(ctx context.Context, id int64) error {
orderIdKey := fmt.Sprintf("%s%v", cacheOrderIdPrefix, id)
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
return conn.ExecCtx(ctx, query, id)
}, orderIdKey)
return err
}
func (m *defaultOrderModel) FindOne(ctx context.Context, id int64) (*Order, error) {
orderIdKey := fmt.Sprintf("%s%v", cacheOrderIdPrefix, id)
var resp Order
err := m.QueryRowCtx(ctx, &resp, orderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", orderRows, m.table)
return conn.QueryRowCtx(ctx, v, query, id)
})
switch err {
case nil:
return &resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultOrderModel) FindAllByUid(ctx context.Context, uid int64) ([]*Order, error) {
var resp []*Order
query := fmt.Sprintf("select %s from %s where `uid` = ?", orderRows, m.table)
err := m.QueryRowNoCache(&resp, query, uid)
switch err {
case nil :
return resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultOrderModel) Insert(ctx context.Context, data *Order) (sql.Result, error) {
orderIdKey := fmt.Sprintf("%s%v", cacheOrderIdPrefix, data.Id)
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, orderRowsExpectAutoSet)
return conn.ExecCtx(ctx, query, data.Uid, data.Pid, data.Amount, data.Status)
}, orderIdKey)
return ret, err
}
func (m *defaultOrderModel) Update(ctx context.Context, data *Order) error {
orderIdKey := fmt.Sprintf("%s%v", cacheOrderIdPrefix, data.Id)
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, orderRowsWithPlaceHolder)
return conn.ExecCtx(ctx, query, data.Uid, data.Pid, data.Amount, data.Status, data.Id)
}, orderIdKey)
return err
}
func (m *defaultOrderModel) formatPrimary(primary any) string {
return fmt.Sprintf("%s%v", cacheOrderIdPrefix, primary)
}
func (m *defaultOrderModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", orderRows, m.table)
return conn.QueryRowCtx(ctx, v, query, primary)
}
func (m *defaultOrderModel) tableName() string {
return m.table
}

View File

@ -0,0 +1,5 @@
package model
import "github.com/zeromicro/go-zero/core/stores/sqlx"
var ErrNotFound = sqlx.ErrNotFound

View File

@ -0,0 +1,19 @@
package config
import (
"github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/zrpc"
)
type Config struct {
zrpc.RpcServerConf
Mysql struct {
DataSource string
}
CacheRedis cache.CacheConf
UserRpc zrpc.RpcClientConf
ProductRpc zrpc.RpcClientConf
}

View File

@ -0,0 +1,74 @@
package logic
import (
"context"
"mall/service/order/model"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"mall/service/product/rpc/product"
"mall/service/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type CreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogic {
return &CreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CreateLogic) Create(in *order.CreateRequest) (*order.CreateResponse, error) {
_, err := l.svcCtx.UserRpc.UserInfo(l.ctx, &user.UserInfoRequest{Id: in.Uid})
if err != nil {
return nil, err
}
productRes, err := l.svcCtx.ProductRpc.Detail(l.ctx, &product.DetailRequest{Id: in.Pid})
if err != nil {
return nil, err
}
if productRes.Stock <= 0 {
return nil, status.Error(500, "产品库存不足")
}
newOrder := model.Order{
Uid: in.Uid,
Pid: in.Pid,
Amount: in.Amount,
Status: 0,
}
res, err := l.svcCtx.OrderModel.Insert(l.ctx, &newOrder)
if err != nil {
return nil, status.Error(500, err.Error())
}
newOrder.Id, err = res.LastInsertId()
if err != nil {
return nil, status.Error(500, err.Error())
}
_, err = l.svcCtx.ProductRpc.Update(l.ctx, &product.UpdateRequest{
Id: productRes.Id,
Name: productRes.Name,
Desc: productRes.Desc,
Stock: productRes.Stock - 1,
Amount: productRes.Amount,
Status: productRes.Status,
})
if err != nil {
return nil, err
}
return &order.CreateResponse{Id: newOrder.Id}, nil
}

View File

@ -0,0 +1,44 @@
package logic
import (
"context"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"mall/service/product/model"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type DetailLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailLogic {
return &DetailLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DetailLogic) Detail(in *order.DetailRequest) (*order.DetailResponse, error) {
res, err := l.svcCtx.OrderModel.FindOne(l.ctx, in.Id)
if err != nil {
if err == model.ErrNotFound {
return nil, status.Error(100, "订单不存在")
}
return nil, status.Error(500, err.Error())
}
return &order.DetailResponse{
Id: res.Id,
Uid: res.Uid,
Pid: res.Pid,
Amount: res.Amount,
Status: res.Status,
}, nil
}

View File

@ -0,0 +1,60 @@
package logic
import (
"context"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"mall/service/product/model"
"mall/service/user/rpc/user"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type ListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
return &ListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ListLogic) List(in *order.ListRequest) (*order.ListResponse, error) {
_, err := l.svcCtx.UserRpc.UserInfo(l.ctx, &user.UserInfoRequest{
Id: in.Uid,
})
if err != nil {
return nil, err
}
list, err := l.svcCtx.OrderModel.FindAllByUid(l.ctx, in.Uid)
if err != nil {
if err == model.ErrNotFound {
return nil, status.Error(100, "订单不存在")
}
return nil, status.Error(500, err.Error())
}
orderList := make([]*order.DetailResponse, 0)
for _, item := range list {
orderList = append(orderList, &order.DetailResponse{
Id: item.Id,
Uid: item.Uid,
Pid: item.Pid,
Amount: item.Amount,
Status: item.Status,
})
}
return &order.ListResponse{
Data: orderList,
}, nil
}

View File

@ -0,0 +1,44 @@
package logic
import (
"context"
"mall/service/order/model"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type PaidLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewPaidLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PaidLogic {
return &PaidLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *PaidLogic) Paid(in *order.PaidRequest) (*order.PaidResponse, error) {
res, err := l.svcCtx.OrderModel.FindOne(l.ctx, in.Id)
if err != nil {
if err == model.ErrNotFound {
return nil, status.Error(100, "订单不存在")
}
return nil, status.Error(500, err.Error())
}
res.Status = 1
err = l.svcCtx.OrderModel.Update(l.ctx, res)
if err != nil {
return nil, status.Error(500, err.Error())
}
return &order.PaidResponse{}, nil
}

View File

@ -0,0 +1,43 @@
package logic
import (
"context"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"mall/service/product/model"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type RemoveLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewRemoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLogic {
return &RemoveLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *RemoveLogic) Remove(in *order.RemoveRequest) (*order.RemoveResponse, error) {
res, err := l.svcCtx.OrderModel.FindOne(l.ctx, in.Id)
if err != nil {
if err == model.ErrNotFound {
return nil, status.Error(100, "订单不存在")
}
return nil, status.Error(500, err.Error())
}
err = l.svcCtx.OrderModel.Delete(l.ctx, res.Id)
if err != nil {
return nil, status.Error(500, err.Error())
}
return &order.RemoveResponse{}, nil
}

View File

@ -0,0 +1,59 @@
package logic
import (
"context"
"mall/service/order/model"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/status"
)
type UpdateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
return &UpdateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *UpdateLogic) Update(in *order.UpdateRequest) (*order.UpdateResponse, error) {
res, err := l.svcCtx.OrderModel.FindOne(l.ctx, in.Id)
if err != nil {
if err == model.ErrNotFound {
return nil, status.Error(100, "订单不存在")
}
return nil, status.Error(500, err.Error())
}
if in.Uid != 0 {
res.Uid = in.Uid
}
if in.Pid != 0 {
res.Pid = in.Pid
}
if in.Amount != 0 {
res.Amount = in.Amount
}
if in.Status != 0 {
res.Status = in.Status
}
err = l.svcCtx.OrderModel.Update(l.ctx, res)
if err != nil {
return nil, status.Error(500, err.Error())
}
return &order.UpdateResponse{}, nil
}

View File

@ -0,0 +1,53 @@
// Code generated by goctl. DO NOT EDIT.
// Source: order.proto
package server
import (
"context"
"mall/service/order/rpc/internal/logic"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
)
type OrderServer struct {
svcCtx *svc.ServiceContext
order.UnimplementedOrderServer
}
func NewOrderServer(svcCtx *svc.ServiceContext) *OrderServer {
return &OrderServer{
svcCtx: svcCtx,
}
}
func (s *OrderServer) Create(ctx context.Context, in *order.CreateRequest) (*order.CreateResponse, error) {
l := logic.NewCreateLogic(ctx, s.svcCtx)
return l.Create(in)
}
func (s *OrderServer) Update(ctx context.Context, in *order.UpdateRequest) (*order.UpdateResponse, error) {
l := logic.NewUpdateLogic(ctx, s.svcCtx)
return l.Update(in)
}
func (s *OrderServer) Remove(ctx context.Context, in *order.RemoveRequest) (*order.RemoveResponse, error) {
l := logic.NewRemoveLogic(ctx, s.svcCtx)
return l.Remove(in)
}
func (s *OrderServer) Detail(ctx context.Context, in *order.DetailRequest) (*order.DetailResponse, error) {
l := logic.NewDetailLogic(ctx, s.svcCtx)
return l.Detail(in)
}
func (s *OrderServer) List(ctx context.Context, in *order.ListRequest) (*order.ListResponse, error) {
l := logic.NewListLogic(ctx, s.svcCtx)
return l.List(in)
}
func (s *OrderServer) Paid(ctx context.Context, in *order.PaidRequest) (*order.PaidResponse, error) {
l := logic.NewPaidLogic(ctx, s.svcCtx)
return l.Paid(in)
}

View File

@ -0,0 +1,30 @@
package svc
import (
"mall/service/order/model"
"mall/service/order/rpc/internal/config"
"mall/service/product/rpc/productclient"
"mall/service/user/rpc/userclient"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"github.com/zeromicro/go-zero/zrpc"
)
type ServiceContext struct {
Config config.Config
OrderModel model.OrderModel
UserRpc userclient.User
ProductRpc productclient.Product
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := sqlx.NewMysql(c.Mysql.DataSource)
return &ServiceContext{
Config: c,
OrderModel: model.NewOrderModel(conn, c.CacheRedis),
UserRpc: userclient.NewUser(zrpc.MustNewClient(c.UserRpc)),
ProductRpc: productclient.NewProduct(zrpc.MustNewClient(c.ProductRpc)),
}
}

View File

@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
"mall/service/order/rpc/internal/config"
"mall/service/order/rpc/internal/server"
"mall/service/order/rpc/internal/svc"
"mall/service/order/rpc/order"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/order.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
order.RegisterOrderServer(grpcServer, server.NewOrderServer(ctx))
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}

View File

@ -0,0 +1,70 @@
syntax = "proto3";
package orderclient;
option go_package = "./order";
message CreateRequest {
int64 Uid = 1;
int64 Pid = 2;
int64 Amount = 3;
int64 Status = 4;
}
message CreateResponse {
int64 id = 1;
}
message UpdateRequest {
int64 id = 1;
int64 Uid = 2;
int64 Pid = 3;
int64 Amount = 4;
int64 Status = 5;
}
message UpdateResponse {
}
message RemoveRequest {
int64 id = 1;
}
message RemoveResponse {
}
message DetailRequest {
int64 id = 1;
}
message DetailResponse {
int64 id = 1;
int64 Uid = 2;
int64 Pid = 3;
int64 Amount = 4;
int64 Status = 5;
}
message ListRequest {
int64 uid = 1;
}
message ListResponse {
repeated DetailResponse data = 1;
}
message PaidRequest {
int64 id = 1;
}
message PaidResponse {
}
service Order {
rpc Create(CreateRequest) returns(CreateResponse);
rpc Update(UpdateRequest) returns(UpdateResponse);
rpc Remove(RemoveRequest) returns(RemoveResponse);
rpc Detail(DetailRequest) returns(DetailResponse);
rpc List(ListRequest) returns(ListResponse);
rpc Paid(PaidRequest) returns(PaidResponse);
}

View File

@ -0,0 +1,937 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.21.5
// source: order.proto
package order
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CreateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Uid int64 `protobuf:"varint,1,opt,name=Uid,proto3" json:"Uid,omitempty"`
Pid int64 `protobuf:"varint,2,opt,name=Pid,proto3" json:"Pid,omitempty"`
Amount int64 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"`
Status int64 `protobuf:"varint,4,opt,name=Status,proto3" json:"Status,omitempty"`
}
func (x *CreateRequest) Reset() {
*x = CreateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateRequest) ProtoMessage() {}
func (x *CreateRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[0]
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 CreateRequest.ProtoReflect.Descriptor instead.
func (*CreateRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{0}
}
func (x *CreateRequest) GetUid() int64 {
if x != nil {
return x.Uid
}
return 0
}
func (x *CreateRequest) GetPid() int64 {
if x != nil {
return x.Pid
}
return 0
}
func (x *CreateRequest) GetAmount() int64 {
if x != nil {
return x.Amount
}
return 0
}
func (x *CreateRequest) GetStatus() int64 {
if x != nil {
return x.Status
}
return 0
}
type CreateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *CreateResponse) Reset() {
*x = CreateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateResponse) ProtoMessage() {}
func (x *CreateResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[1]
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 CreateResponse.ProtoReflect.Descriptor instead.
func (*CreateResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{1}
}
func (x *CreateResponse) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type UpdateRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Uid int64 `protobuf:"varint,2,opt,name=Uid,proto3" json:"Uid,omitempty"`
Pid int64 `protobuf:"varint,3,opt,name=Pid,proto3" json:"Pid,omitempty"`
Amount int64 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"`
Status int64 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"`
}
func (x *UpdateRequest) Reset() {
*x = UpdateRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateRequest) ProtoMessage() {}
func (x *UpdateRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[2]
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 UpdateRequest.ProtoReflect.Descriptor instead.
func (*UpdateRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{2}
}
func (x *UpdateRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *UpdateRequest) GetUid() int64 {
if x != nil {
return x.Uid
}
return 0
}
func (x *UpdateRequest) GetPid() int64 {
if x != nil {
return x.Pid
}
return 0
}
func (x *UpdateRequest) GetAmount() int64 {
if x != nil {
return x.Amount
}
return 0
}
func (x *UpdateRequest) GetStatus() int64 {
if x != nil {
return x.Status
}
return 0
}
type UpdateResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UpdateResponse) Reset() {
*x = UpdateResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateResponse) ProtoMessage() {}
func (x *UpdateResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[3]
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 UpdateResponse.ProtoReflect.Descriptor instead.
func (*UpdateResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{3}
}
type RemoveRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *RemoveRequest) Reset() {
*x = RemoveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RemoveRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RemoveRequest) ProtoMessage() {}
func (x *RemoveRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[4]
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 RemoveRequest.ProtoReflect.Descriptor instead.
func (*RemoveRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{4}
}
func (x *RemoveRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type RemoveResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *RemoveResponse) Reset() {
*x = RemoveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RemoveResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RemoveResponse) ProtoMessage() {}
func (x *RemoveResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[5]
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 RemoveResponse.ProtoReflect.Descriptor instead.
func (*RemoveResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{5}
}
type DetailRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *DetailRequest) Reset() {
*x = DetailRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DetailRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DetailRequest) ProtoMessage() {}
func (x *DetailRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[6]
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 DetailRequest.ProtoReflect.Descriptor instead.
func (*DetailRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{6}
}
func (x *DetailRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type DetailResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Uid int64 `protobuf:"varint,2,opt,name=Uid,proto3" json:"Uid,omitempty"`
Pid int64 `protobuf:"varint,3,opt,name=Pid,proto3" json:"Pid,omitempty"`
Amount int64 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"`
Status int64 `protobuf:"varint,5,opt,name=Status,proto3" json:"Status,omitempty"`
}
func (x *DetailResponse) Reset() {
*x = DetailResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DetailResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DetailResponse) ProtoMessage() {}
func (x *DetailResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[7]
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 DetailResponse.ProtoReflect.Descriptor instead.
func (*DetailResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{7}
}
func (x *DetailResponse) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *DetailResponse) GetUid() int64 {
if x != nil {
return x.Uid
}
return 0
}
func (x *DetailResponse) GetPid() int64 {
if x != nil {
return x.Pid
}
return 0
}
func (x *DetailResponse) GetAmount() int64 {
if x != nil {
return x.Amount
}
return 0
}
func (x *DetailResponse) GetStatus() int64 {
if x != nil {
return x.Status
}
return 0
}
type ListRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"`
}
func (x *ListRequest) Reset() {
*x = ListRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRequest) ProtoMessage() {}
func (x *ListRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[8]
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 ListRequest.ProtoReflect.Descriptor instead.
func (*ListRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{8}
}
func (x *ListRequest) GetUid() int64 {
if x != nil {
return x.Uid
}
return 0
}
type ListResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*DetailResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ListResponse) Reset() {
*x = ListResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListResponse) ProtoMessage() {}
func (x *ListResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_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 ListResponse.ProtoReflect.Descriptor instead.
func (*ListResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{9}
}
func (x *ListResponse) GetData() []*DetailResponse {
if x != nil {
return x.Data
}
return nil
}
type PaidRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (x *PaidRequest) Reset() {
*x = PaidRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PaidRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PaidRequest) ProtoMessage() {}
func (x *PaidRequest) ProtoReflect() protoreflect.Message {
mi := &file_order_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 PaidRequest.ProtoReflect.Descriptor instead.
func (*PaidRequest) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{10}
}
func (x *PaidRequest) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
type PaidResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *PaidResponse) Reset() {
*x = PaidResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_order_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PaidResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PaidResponse) ProtoMessage() {}
func (x *PaidResponse) ProtoReflect() protoreflect.Message {
mi := &file_order_proto_msgTypes[11]
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 PaidResponse.ProtoReflect.Descriptor instead.
func (*PaidResponse) Descriptor() ([]byte, []int) {
return file_order_proto_rawDescGZIP(), []int{11}
}
var File_order_proto protoreflect.FileDescriptor
var file_order_proto_rawDesc = []byte{
0x0a, 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x22, 0x63, 0x0a, 0x0d, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x55,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x50, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x50, 0x69, 0x64, 0x12,
0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52,
0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75,
0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22,
0x20, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69,
0x64, 0x22, 0x73, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x03, 0x55, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
0x03, 0x52, 0x03, 0x50, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16,
0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f,
0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x65, 0x6d,
0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x0a, 0x0d, 0x44,
0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x74, 0x0a, 0x0e,
0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10,
0x0a, 0x03, 0x55, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x69, 0x64,
0x12, 0x10, 0x0a, 0x03, 0x50, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x50,
0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01,
0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74,
0x75, 0x73, 0x22, 0x1f, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03,
0x75, 0x69, 0x64, 0x22, 0x3f, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x1b, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e,
0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x22, 0x1d, 0x0a, 0x0b, 0x50, 0x61, 0x69, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x02, 0x69, 0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x61, 0x69, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x32, 0x8d, 0x03, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x41, 0x0a,
0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x41, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x2e, 0x6f, 0x72, 0x64,
0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x1a, 0x2e,
0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x6d, 0x6f,
0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c,
0x12, 0x1a, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x44,
0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6f,
0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x44, 0x65, 0x74, 0x61, 0x69,
0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x4c, 0x69, 0x73,
0x74, 0x12, 0x18, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e,
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6f, 0x72,
0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x64, 0x12, 0x18,
0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x69,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72,
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x50, 0x61, 0x69, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_order_proto_rawDescOnce sync.Once
file_order_proto_rawDescData = file_order_proto_rawDesc
)
func file_order_proto_rawDescGZIP() []byte {
file_order_proto_rawDescOnce.Do(func() {
file_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_order_proto_rawDescData)
})
return file_order_proto_rawDescData
}
var file_order_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_order_proto_goTypes = []interface{}{
(*CreateRequest)(nil), // 0: orderclient.CreateRequest
(*CreateResponse)(nil), // 1: orderclient.CreateResponse
(*UpdateRequest)(nil), // 2: orderclient.UpdateRequest
(*UpdateResponse)(nil), // 3: orderclient.UpdateResponse
(*RemoveRequest)(nil), // 4: orderclient.RemoveRequest
(*RemoveResponse)(nil), // 5: orderclient.RemoveResponse
(*DetailRequest)(nil), // 6: orderclient.DetailRequest
(*DetailResponse)(nil), // 7: orderclient.DetailResponse
(*ListRequest)(nil), // 8: orderclient.ListRequest
(*ListResponse)(nil), // 9: orderclient.ListResponse
(*PaidRequest)(nil), // 10: orderclient.PaidRequest
(*PaidResponse)(nil), // 11: orderclient.PaidResponse
}
var file_order_proto_depIdxs = []int32{
7, // 0: orderclient.ListResponse.data:type_name -> orderclient.DetailResponse
0, // 1: orderclient.Order.Create:input_type -> orderclient.CreateRequest
2, // 2: orderclient.Order.Update:input_type -> orderclient.UpdateRequest
4, // 3: orderclient.Order.Remove:input_type -> orderclient.RemoveRequest
6, // 4: orderclient.Order.Detail:input_type -> orderclient.DetailRequest
8, // 5: orderclient.Order.List:input_type -> orderclient.ListRequest
10, // 6: orderclient.Order.Paid:input_type -> orderclient.PaidRequest
1, // 7: orderclient.Order.Create:output_type -> orderclient.CreateResponse
3, // 8: orderclient.Order.Update:output_type -> orderclient.UpdateResponse
5, // 9: orderclient.Order.Remove:output_type -> orderclient.RemoveResponse
7, // 10: orderclient.Order.Detail:output_type -> orderclient.DetailResponse
9, // 11: orderclient.Order.List:output_type -> orderclient.ListResponse
11, // 12: orderclient.Order.Paid:output_type -> orderclient.PaidResponse
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
}
func init() { file_order_proto_init() }
func file_order_proto_init() {
if File_order_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_order_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RemoveRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RemoveResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DetailRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DetailResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PaidRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_order_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PaidResponse); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_order_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_order_proto_goTypes,
DependencyIndexes: file_order_proto_depIdxs,
MessageInfos: file_order_proto_msgTypes,
}.Build()
File_order_proto = out.File
file_order_proto_rawDesc = nil
file_order_proto_goTypes = nil
file_order_proto_depIdxs = nil
}

View File

@ -0,0 +1,294 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.21.5
// source: order.proto
package order
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Order_Create_FullMethodName = "/orderclient.Order/Create"
Order_Update_FullMethodName = "/orderclient.Order/Update"
Order_Remove_FullMethodName = "/orderclient.Order/Remove"
Order_Detail_FullMethodName = "/orderclient.Order/Detail"
Order_List_FullMethodName = "/orderclient.Order/List"
Order_Paid_FullMethodName = "/orderclient.Order/Paid"
)
// OrderClient is the client API for Order 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 OrderClient interface {
Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error)
Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error)
Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error)
Detail(ctx context.Context, in *DetailRequest, opts ...grpc.CallOption) (*DetailResponse, error)
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
Paid(ctx context.Context, in *PaidRequest, opts ...grpc.CallOption) (*PaidResponse, error)
}
type orderClient struct {
cc grpc.ClientConnInterface
}
func NewOrderClient(cc grpc.ClientConnInterface) OrderClient {
return &orderClient{cc}
}
func (c *orderClient) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) {
out := new(CreateResponse)
err := c.cc.Invoke(ctx, Order_Create_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orderClient) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) {
out := new(UpdateResponse)
err := c.cc.Invoke(ctx, Order_Update_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orderClient) Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error) {
out := new(RemoveResponse)
err := c.cc.Invoke(ctx, Order_Remove_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orderClient) Detail(ctx context.Context, in *DetailRequest, opts ...grpc.CallOption) (*DetailResponse, error) {
out := new(DetailResponse)
err := c.cc.Invoke(ctx, Order_Detail_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orderClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) {
out := new(ListResponse)
err := c.cc.Invoke(ctx, Order_List_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *orderClient) Paid(ctx context.Context, in *PaidRequest, opts ...grpc.CallOption) (*PaidResponse, error) {
out := new(PaidResponse)
err := c.cc.Invoke(ctx, Order_Paid_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// OrderServer is the server API for Order service.
// All implementations must embed UnimplementedOrderServer
// for forward compatibility
type OrderServer interface {
Create(context.Context, *CreateRequest) (*CreateResponse, error)
Update(context.Context, *UpdateRequest) (*UpdateResponse, error)
Remove(context.Context, *RemoveRequest) (*RemoveResponse, error)
Detail(context.Context, *DetailRequest) (*DetailResponse, error)
List(context.Context, *ListRequest) (*ListResponse, error)
Paid(context.Context, *PaidRequest) (*PaidResponse, error)
mustEmbedUnimplementedOrderServer()
}
// UnimplementedOrderServer must be embedded to have forward compatible implementations.
type UnimplementedOrderServer struct {
}
func (UnimplementedOrderServer) Create(context.Context, *CreateRequest) (*CreateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
}
func (UnimplementedOrderServer) Update(context.Context, *UpdateRequest) (*UpdateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
}
func (UnimplementedOrderServer) Remove(context.Context, *RemoveRequest) (*RemoveResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented")
}
func (UnimplementedOrderServer) Detail(context.Context, *DetailRequest) (*DetailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Detail not implemented")
}
func (UnimplementedOrderServer) List(context.Context, *ListRequest) (*ListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (UnimplementedOrderServer) Paid(context.Context, *PaidRequest) (*PaidResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Paid not implemented")
}
func (UnimplementedOrderServer) mustEmbedUnimplementedOrderServer() {}
// UnsafeOrderServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to OrderServer will
// result in compilation errors.
type UnsafeOrderServer interface {
mustEmbedUnimplementedOrderServer()
}
func RegisterOrderServer(s grpc.ServiceRegistrar, srv OrderServer) {
s.RegisterService(&Order_ServiceDesc, srv)
}
func _Order_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).Create(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_Create_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).Create(ctx, req.(*CreateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Order_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).Update(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_Update_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).Update(ctx, req.(*UpdateRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Order_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RemoveRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).Remove(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_Remove_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).Remove(ctx, req.(*RemoveRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Order_Detail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DetailRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).Detail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_Detail_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).Detail(ctx, req.(*DetailRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Order_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).List(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_List_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).List(ctx, req.(*ListRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Order_Paid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PaidRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(OrderServer).Paid(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Order_Paid_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(OrderServer).Paid(ctx, req.(*PaidRequest))
}
return interceptor(ctx, in, info, handler)
}
// Order_ServiceDesc is the grpc.ServiceDesc for Order service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Order_ServiceDesc = grpc.ServiceDesc{
ServiceName: "orderclient.Order",
HandlerType: (*OrderServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Create",
Handler: _Order_Create_Handler,
},
{
MethodName: "Update",
Handler: _Order_Update_Handler,
},
{
MethodName: "Remove",
Handler: _Order_Remove_Handler,
},
{
MethodName: "Detail",
Handler: _Order_Detail_Handler,
},
{
MethodName: "List",
Handler: _Order_List_Handler,
},
{
MethodName: "Paid",
Handler: _Order_Paid_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "order.proto",
}

View File

@ -0,0 +1,77 @@
// Code generated by goctl. DO NOT EDIT.
// Source: order.proto
package orderclient
import (
"context"
"mall/service/order/rpc/order"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
CreateRequest = order.CreateRequest
CreateResponse = order.CreateResponse
DetailRequest = order.DetailRequest
DetailResponse = order.DetailResponse
ListRequest = order.ListRequest
ListResponse = order.ListResponse
PaidRequest = order.PaidRequest
PaidResponse = order.PaidResponse
RemoveRequest = order.RemoveRequest
RemoveResponse = order.RemoveResponse
UpdateRequest = order.UpdateRequest
UpdateResponse = order.UpdateResponse
Order interface {
Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error)
Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error)
Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error)
Detail(ctx context.Context, in *DetailRequest, opts ...grpc.CallOption) (*DetailResponse, error)
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
Paid(ctx context.Context, in *PaidRequest, opts ...grpc.CallOption) (*PaidResponse, error)
}
defaultOrder struct {
cli zrpc.Client
}
)
func NewOrder(cli zrpc.Client) Order {
return &defaultOrder{
cli: cli,
}
}
func (m *defaultOrder) Create(ctx context.Context, in *CreateRequest, opts ...grpc.CallOption) (*CreateResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.Create(ctx, in, opts...)
}
func (m *defaultOrder) Update(ctx context.Context, in *UpdateRequest, opts ...grpc.CallOption) (*UpdateResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.Update(ctx, in, opts...)
}
func (m *defaultOrder) Remove(ctx context.Context, in *RemoveRequest, opts ...grpc.CallOption) (*RemoveResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.Remove(ctx, in, opts...)
}
func (m *defaultOrder) Detail(ctx context.Context, in *DetailRequest, opts ...grpc.CallOption) (*DetailResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.Detail(ctx, in, opts...)
}
func (m *defaultOrder) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.List(ctx, in, opts...)
}
func (m *defaultOrder) Paid(ctx context.Context, in *PaidRequest, opts ...grpc.CallOption) (*PaidResponse, error) {
client := order.NewOrderClient(m.cli.Conn())
return client.Paid(ctx, in, opts...)
}