From a1e69e872292421e6953b08f52e2c1c48652864a Mon Sep 17 00:00:00 2001 From: baiyutang Date: Fri, 5 Jan 2024 11:40:52 +0800 Subject: [PATCH] style(gomall/idl):rename some fields --- gomall/idl/cart.proto | 20 +++++++++++++------- gomall/idl/checkout.proto | 4 ++-- gomall/idl/order.proto | 18 +++++++++--------- gomall/idl/payment.proto | 6 +++--- gomall/idl/product.proto | 18 +++++++++++------- gomall/idl/user.proto | 16 ++++++++-------- 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/gomall/idl/cart.proto b/gomall/idl/cart.proto index 96c7a58f..c5ba360a 100644 --- a/gomall/idl/cart.proto +++ b/gomall/idl/cart.proto @@ -5,9 +5,9 @@ package cart; option go_package = '/cart'; service CartService { - rpc AddItem(AddItemRequest) returns (Empty) {} - rpc GetCart(GetCartRequest) returns (Cart) {} - rpc EmptyCart(EmptyCartRequest) returns (Empty) {} + rpc AddItem(AddItemReq) returns (AddItemResp) {} + rpc GetCart(GetCartReq) returns (GetCartResp) {} + rpc EmptyCart(EmptyCartReq) returns (EmptyCartResp) {} } message CartItem { @@ -15,22 +15,28 @@ message CartItem { int32 quantity = 2; } -message AddItemRequest { +message AddItemReq { uint32 user_id = 1; CartItem item = 2; } -message EmptyCartRequest { +message AddItemResp {} + +message EmptyCartReq { uint32 user_id = 1; } -message GetCartRequest { +message GetCartReq { uint32 user_id = 1; } +message GetCartResp { + Cart cart = 1; +} + message Cart { uint32 user_id = 1; repeated CartItem items = 2; } -message Empty {} +message EmptyCartResp {} diff --git a/gomall/idl/checkout.proto b/gomall/idl/checkout.proto index 233e2e82..fe050e50 100644 --- a/gomall/idl/checkout.proto +++ b/gomall/idl/checkout.proto @@ -7,7 +7,7 @@ import "payment.proto"; option go_package = "/checkout"; service CheckoutService { - rpc Checkout(CheckoutReq) returns (CheckoutRes) {} + rpc Checkout(CheckoutReq) returns (CheckoutResp) {} } message Address { @@ -27,7 +27,7 @@ message CheckoutReq { payment.CreditCardInfo credit_card = 6; } -message CheckoutRes{ +message CheckoutResp { string order_id = 1; string transaction_id = 2; } \ No newline at end of file diff --git a/gomall/idl/order.proto b/gomall/idl/order.proto index 17fb1176..923caa4f 100644 --- a/gomall/idl/order.proto +++ b/gomall/idl/order.proto @@ -7,8 +7,8 @@ import "cart.proto"; option go_package = "order"; service OrderService { - rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} - rpc ListOrder(ListOrderRequest) returns (ListOrderResponse) {} + rpc PlaceOrder(PlaceOrderReq) returns (PlaceOrderResp) {} + rpc ListOrder(ListOrderReq) returns (ListOrderResp) {} } message Address { @@ -19,13 +19,13 @@ message Address { int32 zip_code = 5; } -message PlaceOrderRequest { +message PlaceOrderReq { uint32 user_id = 1; string user_currency = 2; Address address = 3; - string email = 5; - repeated OrderItem orderItems = 6; + string email = 4; + repeated OrderItem order_items = 5; } message OrderItem { @@ -37,16 +37,16 @@ message OrderResult { string order_id = 1; } -message PlaceOrderResponse { +message PlaceOrderResp { OrderResult order = 1; } -message ListOrderRequest { +message ListOrderReq { uint32 user_id = 1; } message Order { - repeated OrderItem orderItems = 1; + repeated OrderItem order_items = 1; string order_id = 2; uint32 user_id = 3; string user_currency = 4; @@ -55,6 +55,6 @@ message Order { int32 created_at = 7; } -message ListOrderResponse { +message ListOrderResp { repeated Order orders = 1; } diff --git a/gomall/idl/payment.proto b/gomall/idl/payment.proto index 193dc33f..852617e4 100644 --- a/gomall/idl/payment.proto +++ b/gomall/idl/payment.proto @@ -6,7 +6,7 @@ option go_package = "payment"; service PaymentService { - rpc Charge(ChargeRequest) returns (ChargeResponse) {} + rpc Charge(ChargeReq) returns (ChargeResp) {} } message CreditCardInfo { @@ -16,13 +16,13 @@ message CreditCardInfo { int32 credit_card_expiration_month = 4; } -message ChargeRequest { +message ChargeReq { float amount = 1; CreditCardInfo credit_card = 2; string order_id = 3; uint32 user_id = 4; } -message ChargeResponse { +message ChargeResp { string transaction_id = 1; } diff --git a/gomall/idl/product.proto b/gomall/idl/product.proto index 5bd33254..5307142a 100644 --- a/gomall/idl/product.proto +++ b/gomall/idl/product.proto @@ -5,9 +5,9 @@ package product; option go_package = "/product"; service ProductCatalogService { - rpc ListProducts(ListProductsReq) returns (ListProductsResponse) {} - rpc GetProduct(GetProductRequest) returns (Product) {} - rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} + rpc ListProducts(ListProductsReq) returns (ListProductsResp) {} + rpc GetProduct(GetProductReq) returns (GetProductResp) {} + rpc SearchProducts(SearchProductsReq) returns (SearchProductsResp) {} } message ListProductsReq{ @@ -27,18 +27,22 @@ message Product { repeated string categories = 6; } -message ListProductsResponse { +message ListProductsResp { repeated Product products = 1; } -message GetProductRequest { +message GetProductReq { uint32 id = 1; } -message SearchProductsRequest { +message GetProductResp { + Product product = 1; +} + +message SearchProductsReq { string query = 1; } -message SearchProductsResponse { +message SearchProductsResp { repeated Product results = 1; } diff --git a/gomall/idl/user.proto b/gomall/idl/user.proto index 3b58f4c4..9cee3e8b 100644 --- a/gomall/idl/user.proto +++ b/gomall/idl/user.proto @@ -4,14 +4,19 @@ package user; option go_package="/user"; +service UserService { + rpc Register(RegisterReq) returns (RegisterResp) {} + rpc Login(LoginReq) returns (LoginRes) {} +} + message RegisterReq { string email = 1; string password = 2; string confirm_password = 3; } -message RegisterRes { - int32 userid = 1; +message RegisterResp { + int32 user_id = 1; } message LoginReq { @@ -20,10 +25,5 @@ message LoginReq { } message LoginRes { - int32 userid = 1; + int32 user_id = 1; } - -service UserService { - rpc Register(RegisterReq) returns (RegisterRes) {} - rpc Login(LoginReq) returns (LoginRes) {} -} \ No newline at end of file