mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 05:53:45 +03:00
[hw-8] add: repo layer
This commit is contained in:
102
api/comments/v1/comments.proto
Normal file
102
api/comments/v1/comments.proto
Normal file
@@ -0,0 +1,102 @@
|
||||
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/comments/v1;comments";
|
||||
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "Comments Service";
|
||||
version: "1.0.0";
|
||||
};
|
||||
schemes: HTTP;
|
||||
schemes: HTTPS;
|
||||
consumes: "application/json";
|
||||
produces: "application/json";
|
||||
};
|
||||
|
||||
|
||||
message Comment {
|
||||
int64 id = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
int64 user_id = 2 [(validate.rules).int64 = {gt: 0}];
|
||||
int64 sku = 3 [(validate.rules).int64 = {gt: 0}];
|
||||
string text = 4 [(validate.rules).string = {min_len:1, max_len:255}];
|
||||
string created_at = 5; // RFC3339 with ms
|
||||
}
|
||||
|
||||
message CreateCommentRequest {
|
||||
int64 user_id = 1 [(validate.rules).int64 = {gt: 0}];
|
||||
int64 sku = 2 [(validate.rules).int64 = {gt: 0}];
|
||||
string text = 3 [(validate.rules).string = {min_len:1, max_len:255}];
|
||||
}
|
||||
message CreateCommentResponse { Comment comment = 1; }
|
||||
|
||||
message GetCommentRequest {
|
||||
int64 id = 1 [(validate.rules).int64 = {gt:0}];
|
||||
}
|
||||
message GetCommentResponse { Comment comment = 1; }
|
||||
|
||||
message UpdateCommentRequest {
|
||||
int64 id = 1 [(validate.rules).int64 = {gt:0}];
|
||||
int64 user_id = 2 [(validate.rules).int64 = {gt: 0}];
|
||||
string text = 3 [(validate.rules).string = {min_len:1, max_len:255}];
|
||||
}
|
||||
message UpdateCommentResponse { Comment comment = 1; }
|
||||
|
||||
message ListBySkuRequest {
|
||||
int64 sku = 1 [(validate.rules).int64 = {gt:0}];
|
||||
}
|
||||
message ListBySkuResponse { repeated Comment comments = 1; }
|
||||
|
||||
message ListByUserRequest {
|
||||
int64 user_id = 1 [(validate.rules).int64 = {gt:0}];
|
||||
}
|
||||
message ListByUserResponse { repeated Comment comments = 1; }
|
||||
|
||||
service Comments {
|
||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
|
||||
description: "Comment 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 Add(CreateCommentRequest) returns (CreateCommentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/comment/add"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetById(GetCommentRequest) returns (GetCommentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/comment/get-by-id"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc Edit(UpdateCommentRequest) returns (UpdateCommentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/comment/edit"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListBySku(ListBySkuRequest) returns (ListBySkuResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/comment/list-by-sku"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ListByUser(ListByUserRequest) returns (ListByUserResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/comment/list-by-user"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
350
api/openapiv2/comments/v1/comments.swagger.json
Normal file
350
api/openapiv2/comments/v1/comments.swagger.json
Normal file
@@ -0,0 +1,350 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Comments Service",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "Comments",
|
||||
"description": "Comment 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": {
|
||||
"/comment/add": {
|
||||
"post": {
|
||||
"operationId": "Comments_Add",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateCommentResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/CreateCommentRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Comments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/comment/edit": {
|
||||
"post": {
|
||||
"operationId": "Comments_Edit",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UpdateCommentResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UpdateCommentRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Comments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/comment/get-by-id": {
|
||||
"post": {
|
||||
"operationId": "Comments_GetById",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/GetCommentResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/GetCommentRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Comments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/comment/list-by-sku": {
|
||||
"post": {
|
||||
"operationId": "Comments_ListBySku",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ListBySkuResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ListBySkuRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Comments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/comment/list-by-user": {
|
||||
"post": {
|
||||
"operationId": "Comments_ListByUser",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ListByUserResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ListByUserRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Comments"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Comment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"text": {
|
||||
"type": "string"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"title": "RFC3339 with ms"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CreateCommentRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"text": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"CreateCommentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"$ref": "#/definitions/Comment"
|
||||
}
|
||||
}
|
||||
},
|
||||
"GetCommentRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"GetCommentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"$ref": "#/definitions/Comment"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ListBySkuRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ListBySkuResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"comments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/Comment"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ListByUserRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ListByUserResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"comments": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/Comment"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateCommentRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"userId": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"text": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UpdateCommentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"$ref": "#/definitions/Comment"
|
||||
}
|
||||
}
|
||||
},
|
||||
"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