generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
964 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "data/v1/data.proto", | ||
"version": "version not set" | ||
}, | ||
"tags": [ | ||
{ | ||
"name": "DataAPI" | ||
} | ||
], | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"paths": { | ||
"/api/data": { | ||
"get": { | ||
"operationId": "DataAPI_ExportDBV1", | ||
"responses": { | ||
"200": { | ||
"description": "A successful response.", | ||
"schema": { | ||
"$ref": "#/definitions/v1ExportDBV1Response" | ||
} | ||
}, | ||
"default": { | ||
"description": "An unexpected error response.", | ||
"schema": { | ||
"$ref": "#/definitions/rpcStatus" | ||
} | ||
} | ||
}, | ||
"tags": [ | ||
"DataAPI" | ||
] | ||
}, | ||
"post": { | ||
"operationId": "DataAPI_ImportDBV1", | ||
"responses": { | ||
"200": { | ||
"description": "A successful response.", | ||
"schema": { | ||
"$ref": "#/definitions/v1ImportDBV1Response" | ||
} | ||
}, | ||
"default": { | ||
"description": "An unexpected error response.", | ||
"schema": { | ||
"$ref": "#/definitions/rpcStatus" | ||
} | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"name": "body", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/v1ImportDBV1Request" | ||
} | ||
} | ||
], | ||
"tags": [ | ||
"DataAPI" | ||
] | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"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" | ||
} | ||
} | ||
} | ||
}, | ||
"v1ExportDBV1Response": { | ||
"type": "object", | ||
"properties": { | ||
"db": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"v1ImportDBV1Request": { | ||
"type": "object", | ||
"properties": { | ||
"db": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"v1ImportDBV1Response": { | ||
"type": "object" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package plants | ||
|
||
import ( | ||
"context" | ||
|
||
api "plants/internal/pkg/pb/plants/v1" | ||
|
||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
func (h *Handler) GetActivePlantsV1( | ||
ctx context.Context, | ||
req *api.GetActivePlantsV1Request, | ||
) (*api.GetActivePlantsV1Response, error) { | ||
plants, err := h.storage.GetPlantsByUserId(ctx, req.UserId, false) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "cannot find plants due to %v", err) | ||
} | ||
result := make([]*api.Plant, len(plants)) | ||
for i, p := range plants { | ||
result[i] = &api.Plant{ | ||
Id: p.ID.Hex(), | ||
Image: p.Image, | ||
Species: p.Species, | ||
Price: p.Price, | ||
CreatedAt: timestamppb.New(p.CreatedAt), | ||
Place: p.Place, | ||
} | ||
} | ||
return &api.GetActivePlantsV1Response{ | ||
Plants: result, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package plants | ||
|
||
import ( | ||
"context" | ||
|
||
api "plants/internal/pkg/pb/plants/v1" | ||
|
||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
func (h *Handler) GetArchivedPlantsV1( | ||
ctx context.Context, | ||
req *api.GetArchivedPlantsV1Request, | ||
) (*api.GetArchivedPlantsV1Response, error) { | ||
plants, err := h.storage.GetPlantsByUserId(ctx, req.UserId, true) | ||
if err != nil { | ||
return nil, status.Errorf(codes.Internal, "cannot find plants due to %v", err) | ||
} | ||
result := make([]*api.Plant, len(plants)) | ||
for i, p := range plants { | ||
result[i] = &api.Plant{ | ||
Id: p.ID.Hex(), | ||
Image: p.Image, | ||
Species: p.Species, | ||
Price: p.Price, | ||
CreatedAt: timestamppb.New(p.CreatedAt), | ||
Place: p.Place, | ||
} | ||
} | ||
return &api.GetArchivedPlantsV1Response{ | ||
Plants: result, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.