Skip to content

Commit

Permalink
Merge pull request #52 from moevm/back-37
Browse files Browse the repository at this point in the history
Back 37
  • Loading branch information
AnjeZenda authored Dec 3, 2024
2 parents bd42e97 + 7affdc8 commit bbaf713
Show file tree
Hide file tree
Showing 31 changed files with 3,027 additions and 1,226 deletions.
2 changes: 1 addition & 1 deletion mongo-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ db.users.insertMany([
"species": "Финиковая пальма",
"created_at": ISODate("2024-09-29T12:00:00Z"),
"place": "Казань",
"sold_at": ISODate(ISODate("0001-01-01T00:00:00Z"))
"sold_at": ISODate("0001-01-01T00:00:00Z")
}
],
"trades": [
Expand Down
169 changes: 108 additions & 61 deletions server/api/plants/v1/plants.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import "google/protobuf/timestamp.proto";
service PlantsAPI {
rpc GetPlantsWithCareRulesV1 (GetPlantsWithCareRulesV1Request) returns (GetPlantsWithCareRulesV1Response) {
option (google.api.http) = {
get: "/api/care"
post: "/api/care/{page}/{size}"
body: "*"
};
};

Expand All @@ -32,26 +33,20 @@ service PlantsAPI {
};
};

rpc GetPlantsV1 (GetPlantsV1Request) returns (GetPlantsV1Response) {
option (google.api.http) = {
get: "/api/plants/{page}/{size}/{sort}"
};
};

rpc CreatePlantV1 (CreatePlantV1Request) returns (CreatePlantV1Response) {
option (google.api.http) = {
post: "/api/plants/add"
body: "*"
};
};


rpc GetPlantsForTradeV1 (GetPlantsForTradeV1Request) returns (GetPlantsForTradeV1Response) {
option (google.api.http) = {
get: "/api/plants/trade/{user_id}"
get: "/api/plants/trade/{userId}"
};
};
rpc GetFilteredPlantsV1 (GetFilteredPlantsV1Request) returns (GetFilteredPlantsV1Response) {

rpc GetPlantsV1 (GetPlantsV1Request) returns (GetPlantsV1Response) {
option (google.api.http) = {
post: "/api/palnts/{page}/{size}/{sort}"
body: "*"
Expand All @@ -64,6 +59,46 @@ service PlantsAPI {
body: "*"
};
};

rpc GetBoughtPlantsV1 (GetBoughtPlantsV1Request) returns (GetBoughtPlantsV1Response) {
option (google.api.http) = {
post: "/api/plants/buy/{userId}"
body: "*"
};
};

rpc GetTradedPlantsV1 (GetTradedPlantsV1Request) returns (GetTradedPlantsV1Response) {
option (google.api.http) = {
post: "/api/plants/trade/{userId}"
body: "*"
};
};

rpc GetActivePlantsV1 (GetActivePlantsV1Request) returns (GetActivePlantsV1Response) {
option (google.api.http) = {
get: "/api/plants/active/{userId}"
};
};

rpc GetArchivedPlantsV1 (GetArchivedPlantsV1Request) returns (GetArchivedPlantsV1Response) {
option (google.api.http) = {
get: "/api/plants/archive/{userId}"
};
};
}

message Filter {
string species = 1;
string type = 2;
repeated string size = 3;
repeated string lightCondition = 4;
repeated string wateringFrequency = 5;
repeated string temperatureRegime = 6;
repeated string careComplexity = 7;
string description = 8;
string place = 9;
float priceFrom = 10;
float priceTo = 11;
}

message CreatePlantV1Request {
Expand All @@ -74,66 +109,26 @@ message CreatePlantV1Request {
string lightCondition = 5;
string wateringFrequency = 6;
string temperatureRegime = 7;
string care_complexity = 8;
string careComplexity = 8;
string description = 9;
string type = 10;
string species = 11;
string care_rules = 12;
string careRules = 12;
google.protobuf.Timestamp createdAt = 13;
string userId = 14;
}

message CreatePlantV1Response {}

message GetFilteredPlantsV1Request{
int64 page = 1;
int64 size = 2;
string sort = 3;
bool isDesc = 4;
message Filter {
string species = 1;
string type = 2;
repeated string size = 3;
repeated string lightCondition = 4;
repeated string wateringFrequency = 5;
repeated string temperatureRegime = 6;
repeated string careComplexity = 7;
string description = 8;
string place = 9;
float priceFrom = 10;
float priceTo = 11;
}
Filter filter = 5;
}

message GetFilteredPlantsV1Response{
message Plant {
string id = 1;
string image = 2;
string species = 3;
float price = 4;
google.protobuf.Timestamp createdAt = 5;
string place = 6;
}
repeated Plant plants = 1;
}

message GetPlantsV1Request {
int64 page = 1;
int64 size = 2;
string sort = 3;
bool isDesc = 4;
Filter filter = 5;
}

message GetPlantsV1Response {
message Plant {
string id = 1;
string image = 2;
string species = 3;
float price = 4;
google.protobuf.Timestamp createdAt = 5;
string place = 6;
}
repeated Plant plants = 1;
}

Expand Down Expand Up @@ -161,35 +156,49 @@ message CreateNewCareRuleV1Request {
string species = 1;
string userId = 2;
string descriptionAddition = 3;
string type = 4;
string lightCondition = 5;
string temperatureRegime = 6;
string image = 7;
}

message CreateNewCareRuleV1Response {}

message GetPlantsWithCareRulesV1Request {}
message GetPlantsWithCareRulesV1Request {
message Filter {
string species = 1;
string type = 2;
repeated string lightCondition = 3;
repeated string temperatureRegime = 4;
}
Filter filter = 1;
int64 page = 2;
int64 size = 3;
}

message GetPlantsWithCareRulesV1Response {
message Plant {
message PlantInfo {
string species = 1;
string image = 2;
string id = 3;
}
repeated Plant plants = 1;
repeated PlantInfo plants = 1;
}


message GetPlantsForTradeV1Request {
string user_id = 1;
string userId = 1;
}

message GetPlantsForTradeV1Response {
message Plant{
message PlantInfo{
string species = 1;
string price = 2;
string place = 3;
google.protobuf.Timestamp createdAt = 4;

}
repeated Plant plants = 1;
repeated PlantInfo plants = 1;
}

message GetExampleV1Request {}
Expand All @@ -198,7 +207,7 @@ message GetPlantByIdV1Request{
string id = 1;
}
message GetPlantByIdV1Response{
message Plant {
message PlantInfo {
string species = 1;
string type = 2;
string size = 3;
Expand All @@ -217,7 +226,7 @@ message GetPlantByIdV1Response{
string surname = 3;
string fatherName = 4;
}
Plant plant = 1;
PlantInfo plant = 1;
User user = 2;
}

Expand All @@ -230,5 +239,43 @@ message BuyPlantV1Request{
}
message BuyPlantV1Response{

}

message GetBoughtPlantsV1Request{
string userId = 1;
Filter filter = 2;
}
message GetBoughtPlantsV1Response{
repeated Plant plants = 1;
}

message GetTradedPlantsV1Request{
string userId = 1;
Filter filter = 2;
}
message GetTradedPlantsV1Response{
repeated Plant plants = 1;
}

message Plant {
string id = 1;
string image = 2;
string species = 3;
float price = 4;
google.protobuf.Timestamp createdAt = 5;
string place = 6;
}

message GetActivePlantsV1Request{
string userId = 1;
}
message GetActivePlantsV1Response{
repeated Plant plants = 1;
}

message GetArchivedPlantsV1Request{
string userId = 1;
}
message GetArchivedPlantsV1Response{
repeated Plant plants = 1;
}
Loading

0 comments on commit bbaf713

Please sign in to comment.