mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 05:53:45 +03:00
[hw-3] loms service
This commit is contained in:
125
api/loms/v1/loms.proto
Normal file
125
api/loms/v1/loms.proto
Normal file
@@ -0,0 +1,125 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "validate/validate.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||
|
||||
option go_package = "route256/pkg/api/loms/v1;loms";
|
||||
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "LOMS Service";
|
||||
version: "1.0.0";
|
||||
};
|
||||
schemes: HTTP;
|
||||
schemes: HTTPS;
|
||||
consumes: "application/json";
|
||||
produces: "application/json";
|
||||
};
|
||||
|
||||
service LOMS {
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
|
||||
description: "LOMS Service"
|
||||
external_docs: {
|
||||
url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/a_bit_of_everything.proto";
|
||||
description: "Find out more about grpc-gateway";
|
||||
}
|
||||
};
|
||||
|
||||
rpc OrderCreate(OrderCreateRequest) returns (OrderCreateResponse) {
|
||||
option(google.api.http) = {
|
||||
post: "/order/create"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc OrderInfo(OrderInfoRequest) returns (OrderInfoResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/order/info"
|
||||
};
|
||||
}
|
||||
|
||||
rpc OrderPay(OrderPayRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/order/pay"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc OrderCancel(OrderCancelRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/order/cancel"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc StocksInfo(StocksInfoRequest) returns (StocksInfoResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/stock/info"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message OrderItem {
|
||||
int64 sku = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
uint32 count = 2 [(validate.rules).uint32 = {gt: 0}];
|
||||
}
|
||||
|
||||
// OrderCreate
|
||||
|
||||
message OrderCreateRequest {
|
||||
int64 user_id = 1 [
|
||||
(validate.rules).int64 = {gt: 0}
|
||||
];
|
||||
repeated OrderItem items = 2 [
|
||||
(validate.rules).repeated = {min_items: 1}
|
||||
];
|
||||
}
|
||||
|
||||
message OrderCreateResponse {
|
||||
int64 orderId = 1;
|
||||
}
|
||||
|
||||
// OrderInfo
|
||||
|
||||
message OrderInfoRequest {
|
||||
int64 orderId = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
}
|
||||
|
||||
message OrderInfoResponse {
|
||||
string status = 1;
|
||||
int64 user_id = 2;
|
||||
repeated OrderItem items = 3;
|
||||
}
|
||||
|
||||
enum OrderStatus {
|
||||
ORDER_STATUS_UNSPECIFIED = 0;
|
||||
ORDER_STATUS_NEW = 1;
|
||||
ORDER_STATUS_AWAITING_PAYMENT = 2;
|
||||
ORDER_STATUS_FAILED = 3;
|
||||
ORDER_STATUS_PAYED = 4;
|
||||
ORDER_STATUS_CANCELLED = 5;
|
||||
}
|
||||
|
||||
// OrderPay
|
||||
|
||||
message OrderPayRequest {
|
||||
int64 order_id = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
}
|
||||
|
||||
// OrderCancel
|
||||
|
||||
message OrderCancelRequest {
|
||||
int64 order_id = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
}
|
||||
|
||||
// StocksInfo
|
||||
|
||||
message StocksInfoRequest {
|
||||
int64 sku = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
}
|
||||
|
||||
message StocksInfoResponse {
|
||||
uint32 count = 1;
|
||||
}
|
||||
303
api/openapiv2/loms/v1/loms.swagger.json
Normal file
303
api/openapiv2/loms/v1/loms.swagger.json
Normal file
@@ -0,0 +1,303 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "LOMS Service",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "LOMS",
|
||||
"description": "LOMS Service",
|
||||
"externalDocs": {
|
||||
"description": "Find out more about grpc-gateway",
|
||||
"url": "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/a_bit_of_everything.proto"
|
||||
}
|
||||
}
|
||||
],
|
||||
"schemes": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/order/cancel": {
|
||||
"post": {
|
||||
"operationId": "LOMS_OrderCancel",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OrderCancelRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"LOMS"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/order/create": {
|
||||
"post": {
|
||||
"operationId": "LOMS_OrderCreate",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OrderCreateResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OrderCreateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"LOMS"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/order/info": {
|
||||
"get": {
|
||||
"operationId": "LOMS_OrderInfo",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OrderInfoResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "orderId",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"LOMS"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/order/pay": {
|
||||
"post": {
|
||||
"operationId": "LOMS_OrderPay",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/OrderPayRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"LOMS"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/stock/info": {
|
||||
"get": {
|
||||
"operationId": "LOMS_StocksInfo",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/StocksInfoResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "sku",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"LOMS"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"OrderCancelRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"orderId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"OrderCreateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/OrderItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"OrderCreateResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"orderId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"OrderInfoResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/OrderItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"OrderItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"OrderPayRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"orderId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"StocksInfoResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"count": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"@type": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {}
|
||||
},
|
||||
"rpcStatus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/protobufAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user