Skip to content

Commit

Permalink
style(gomall/idl):rename some fields
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyutang committed Jan 5, 2024
1 parent 2ad65fb commit a1e69e8
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 36 deletions.
20 changes: 13 additions & 7 deletions gomall/idl/cart.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,38 @@ 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 {
uint32 product_id = 1;
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 {}
4 changes: 2 additions & 2 deletions gomall/idl/checkout.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,7 +27,7 @@ message CheckoutReq {
payment.CreditCardInfo credit_card = 6;
}

message CheckoutRes{
message CheckoutResp {
string order_id = 1;
string transaction_id = 2;
}
18 changes: 9 additions & 9 deletions gomall/idl/order.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -55,6 +55,6 @@ message Order {
int32 created_at = 7;
}

message ListOrderResponse {
message ListOrderResp {
repeated Order orders = 1;
}
6 changes: 3 additions & 3 deletions gomall/idl/payment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option go_package = "payment";


service PaymentService {
rpc Charge(ChargeRequest) returns (ChargeResponse) {}
rpc Charge(ChargeReq) returns (ChargeResp) {}
}

message CreditCardInfo {
Expand All @@ -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;
}
18 changes: 11 additions & 7 deletions gomall/idl/product.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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;
}
16 changes: 8 additions & 8 deletions gomall/idl/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {}
}

0 comments on commit a1e69e8

Please sign in to comment.