Skip to content

Commit

Permalink
Merge pull request #57 from moevm/back-fix-4
Browse files Browse the repository at this point in the history
changed species to id and added type
  • Loading branch information
AnjeZenda authored Dec 5, 2024
2 parents 9115a46 + b59b277 commit 9c4ade5
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 337 deletions.
7 changes: 4 additions & 3 deletions server/api/plants/v1/plants.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ service PlantsAPI {
};
rpc GetCareRuleV1 (GetCareRuleV1Request) returns (GetCareRuleV1Response) {
option (google.api.http) = {
get: "/api/care/{species}"
get: "/api/care/{id}"
};
};

Expand Down Expand Up @@ -133,7 +133,7 @@ message GetPlantsV1Response {
}

message GetCareRuleV1Request {
string species = 1;
string id = 1;
}

message GetCareRuleV1Response {
Expand Down Expand Up @@ -180,7 +180,8 @@ message GetPlantsWithCareRulesV1Response {
message PlantInfo {
string species = 1;
string image = 2;
string id = 3;
string ruleId = 3;
string type = 4;
}
repeated PlantInfo plants = 1;
}
Expand Down
61 changes: 32 additions & 29 deletions server/gen/docs/plants/v1/plants.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@
]
}
},
"/api/care/{page}/{size}": {
"post": {
"operationId": "PlantsAPI_GetPlantsWithCareRulesV1",
"/api/care/{id}": {
"get": {
"operationId": "PlantsAPI_GetCareRuleV1",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetPlantsWithCareRulesV1Response"
"$ref": "#/definitions/v1GetCareRuleV1Response"
}
},
"default": {
Expand All @@ -67,41 +67,25 @@
},
"parameters": [
{
"name": "page",
"in": "path",
"required": true,
"type": "string",
"format": "int64"
},
{
"name": "size",
"name": "id",
"in": "path",
"required": true,
"type": "string",
"format": "int64"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/PlantsAPIGetPlantsWithCareRulesV1Body"
}
"type": "string"
}
],
"tags": [
"PlantsAPI"
]
}
},
"/api/care/{species}": {
"get": {
"operationId": "PlantsAPI_GetCareRuleV1",
"/api/care/{page}/{size}": {
"post": {
"operationId": "PlantsAPI_GetPlantsWithCareRulesV1",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetCareRuleV1Response"
"$ref": "#/definitions/v1GetPlantsWithCareRulesV1Response"
}
},
"default": {
Expand All @@ -113,10 +97,26 @@
},
"parameters": [
{
"name": "species",
"name": "page",
"in": "path",
"required": true,
"type": "string"
"type": "string",
"format": "int64"
},
{
"name": "size",
"in": "path",
"required": true,
"type": "string",
"format": "int64"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/PlantsAPIGetPlantsWithCareRulesV1Body"
}
}
],
"tags": [
Expand Down Expand Up @@ -892,7 +892,10 @@
"image": {
"type": "string"
},
"id": {
"ruleId": {
"type": "string"
},
"type": {
"type": "string"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func (h *Handler) GetPlantsWithCareRulesV1(
result = append(result, &api.GetPlantsWithCareRulesV1Response_PlantInfo{
Species: r.Species,
Image: r.Image,
Id: r.ID.Hex(),
RuleId: r.ID.Hex(),
Type: r.Type,
})
}
return &api.GetPlantsWithCareRulesV1Response{
Expand Down
2 changes: 1 addition & 1 deletion server/internal/handlers/plants/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type Storage interface {
GetPlantsWithCareRules(ctx context.Context, fltr *models.Filter) ([]*models.CareRules, error)
CreateNewCareRule(ctx context.Context, rule *models.CareRules) error
GetCareRulesForPlant(ctx context.Context, species string) (*models.CareRules, error)
GetCareRulesForPlant(ctx context.Context, id string) (*models.CareRules, error)
GetPlants(ctx context.Context, fltr *models.Filter) ([]*models.Plant, error)
AddPlant(ctx context.Context, plant *models.Plant) error
GetPlantsForTrade(ctx context.Context, id string) ([]*models.Plant, error)
Expand Down
Loading

0 comments on commit 9c4ade5

Please sign in to comment.