From 0ed38b7cc0bcefb5e90488758703fb85e13a4428 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Thu, 28 Nov 2024 06:43:05 +0700 Subject: [PATCH] add text waste route --- .vscode/settings.json | 2 + api/smm_core.proto | 21 +- go.mod | 13 +- go.sum | 23 + internal/app/server.go | 30 +- internal/services/budget/budget_service.go | 17 - .../services/category/category_service.go | 11 +- internal/services/requests.restbook | 2 +- internal/services/user/user_service.go | 30 +- internal/services/waste/waste_service.go | 158 +++++- internal/services/waste/waste_service_test.go | 83 ++++ proto/smm_core.pb.go | 453 ++++++++++-------- proto/smm_core.pb.gw.go | 154 +++--- proto/smm_core_grpc.pb.go | 80 ++-- resources/smm_core.swagger.json | 97 ++-- 15 files changed, 744 insertions(+), 430 deletions(-) create mode 100644 internal/services/waste/waste_service_test.go diff --git a/.vscode/settings.json b/.vscode/settings.json index 92ac17c..c1c7151 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,8 @@ } ], "cSpell.words": [ + "рублей", + "caser", "dbpool", "jackc", "pgconn", diff --git a/api/smm_core.proto b/api/smm_core.proto index e7a9aec..2f8d1c3 100644 --- a/api/smm_core.proto +++ b/api/smm_core.proto @@ -18,13 +18,7 @@ service SmmCore { }; } - // users - rpc AddUser(AddUserReq) returns (User) { - option (google.api.http) = { - post: "/users", - body: "*" - }; - } + // login rpc Login(LoginReq) returns (User) { option (google.api.http) = { post: "/login", @@ -104,6 +98,12 @@ service SmmCore { body: "*" }; } + rpc AddWasteByText(AddWasteTextReq) returns (Waste) { + option (google.api.http) = { + post: "/wastes/text", + body: "*" + }; + } rpc DeleteWaste(DeleteWasteReq) returns (Waste) { option (google.api.http) = { delete: "/wastes/{id}" @@ -227,6 +227,13 @@ message AddWasteReq { int32 price = 2; float amount = 3; int32 category_id = 4; + int32 budget_id = 5; +} + +message AddWasteTextReq { + string text = 1; + int32 category_id = 2; + int32 budget_id = 3; } message Waste { diff --git a/go.mod b/go.mod index 8df85cd..f8fa8e0 100644 --- a/go.mod +++ b/go.mod @@ -10,15 +10,18 @@ require ( ) require ( + github.com/cweill/gotests v1.6.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/pgx/v5 v5.7.1 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/mod v0.22.0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.9.0 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/tools v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 1774b05..227c209 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/cweill/gotests v1.6.0 h1:KJx+/p4EweijYzqPb4Y/8umDCip1Cv6hEVyOx0mE9W8= +github.com/cweill/gotests v1.6.0/go.mod h1:CaRYbxQZGQOxXDvM9l0XJVV2Tjb2E5H53vq+reR2GrA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -15,18 +17,39 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/tools v0.0.0-20191109212701-97ad0ed33101/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw= google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc= google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI= diff --git a/internal/app/server.go b/internal/app/server.go index 4c21724..44371b6 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -36,20 +36,6 @@ func (s *Server) Ping(context.Context, *proto.PingReq) (*proto.PingRsp, error) { return &proto.PingRsp{}, nil } -func (s *Server) AddUser(ctx context.Context, req *proto.AddUserReq) (*proto.User, error) { - user, err := s.userService.AddUser( - ctx, - &user.UserEntity{ - Username: req.Username, - Password: req.Password, - }, - ) - if err != nil { - return nil, err - } - return mapUser(user), nil -} - func (s *Server) Login(ctx context.Context, req *proto.LoginReq) (*proto.User, error) { user, err := s.userService.Login( ctx, @@ -148,6 +134,22 @@ func (s *Server) AddWaste(ctx context.Context, req *proto.AddWasteReq) (*proto.W Price: int(req.Price), Amount: req.Amount, CategoryId: int(req.CategoryId), + BudgetId: int(req.BudgetId), + }, + ) + if err != nil { + return nil, err + } + return mapWaste(waste), nil +} + +func (s *Server) AddWasteByText(ctx context.Context, req *proto.AddWasteTextReq) (*proto.Waste, error) { + waste, err := s.wasteService.AddWasteByText( + ctx, + &waste.WasteTextEntity{ + Text: req.Text, + CategoryId: int(req.CategoryId), + BudgetId: int(req.BudgetId), }, ) if err != nil { diff --git a/internal/services/budget/budget_service.go b/internal/services/budget/budget_service.go index 77fcab5..bade0a8 100644 --- a/internal/services/budget/budget_service.go +++ b/internal/services/budget/budget_service.go @@ -60,23 +60,6 @@ func (s *BudgetService) AddBudget(ctx context.Context, budget *BudgetEntity) (*B return nil, err } - defaultCategories := []*category.CategoryEntity{ - { - Name: "Транспорт", - BudgetId: budget.Id, - }, - { - Name: "Продукты", - BudgetId: budget.Id, - }, - } - for _, category := range defaultCategories { - _, err = s.categoryService.AddCategory(ctx, category) - if err != nil { - return nil, err - } - } - if err = tx.Commit(ctx); err != nil { return nil, err } diff --git a/internal/services/category/category_service.go b/internal/services/category/category_service.go index bda43b5..6edcba6 100644 --- a/internal/services/category/category_service.go +++ b/internal/services/category/category_service.go @@ -42,10 +42,10 @@ func (s *CategoryService) AddCategory(ctx context.Context, category *CategoryEnt return category, nil } -func (s *CategoryService) GetCategory(ctx context.Context, categoryId int) (*CategoryEntity, error) { - query := `SELECT id, name, budget_id, favorite, monthly_limit FROM categories WHERE id = @id` +func (s *CategoryService) GetCategory(ctx context.Context, budgetId int, name string) (*CategoryEntity, error) { + query := `SELECT id, name, budget_id, favorite, monthly_limit FROM categories WHERE LOWER(name) = LOWER(@name)` args := pgx.NamedArgs{ - "id": categoryId, + "name": name, } rows, err := s.db.Query(ctx, query, args) if err != nil { @@ -61,5 +61,8 @@ func (s *CategoryService) GetCategory(ctx context.Context, categoryId int) (*Cat } categories = append(categories, category) } - return categories[0], nil + if len(categories) > 0 { + return categories[0], nil + } + return nil, nil } diff --git a/internal/services/requests.restbook b/internal/services/requests.restbook index 4e715c3..bb81fdc 100644 --- a/internal/services/requests.restbook +++ b/internal/services/requests.restbook @@ -1 +1 @@ -[{"kind":1,"language":"markdown","value":"# Добавление пользователя","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/users\nauthorization: Y3JhYjpjcmFi\n\n{\n \"username\": \"foo\",\n \"password\": \"bar\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:47 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:47 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Авторизация","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/login\nauthorization: Y3JhYjpjcmFi\n\n{\n \"username\": \"foo\",\n \"password\": \"bar\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:18:53 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/login","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:18:53 GMT","Content-Type":"application/json","Content-Length":"25"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/login","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление бюджета","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/budgets\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"name\": \"Семейный\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:52 GMT","Content-Type":"application/json","Content-Length":"80"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":27}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Семейный"}},"data":{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[]}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:52 GMT","Content-Type":"application/json","Content-Length":"80"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":27}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Семейный"}},"data":{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[]}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Запрос бюджетов","outputs":[]},{"kind":2,"language":"rest-book","value":"GET http://localhost:8090/budgets\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:56 GMT","Content-Type":"application/json","Content-Length":"259"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4"}},"request":{"method":"GET","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"}},"data":{"budgets":[{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[{"id":1,"name":"Транспорт","budgetId":0,"favorite":false,"monthlyLimit":0},{"id":2,"name":"Продукты","budgetId":0,"favorite":false,"monthlyLimit":0}]}]}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:56 GMT","Content-Type":"application/json","Content-Length":"259"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4"}},"request":{"method":"GET","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"}},"data":{"budgets":[{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[{"id":1,"name":"Транспорт","budgetId":0,"favorite":false,"monthlyLimit":0},{"id":2,"name":"Продукты","budgetId":0,"favorite":false,"monthlyLimit":0}]}]}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление пользователя в бюджет","outputs":[]},{"kind":2,"language":"rest-book","value":"PUT http://localhost:8090/budgets/1/users\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"user_id\": \"2\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:21:36 GMT","Content-Type":"application/json","Content-Length":"2"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":15}},"request":{"method":"PUT","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets/1/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"user_id":"2"}},"data":{}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:21:36 GMT","Content-Type":"application/json","Content-Length":"2"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":15}},"request":{"method":"PUT","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets/1/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"user_id":"2"}},"data":{}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление траты","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/wastes\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"name\": \"Молоко\",\n \"price\": 10000,\n \"amount\": 1,\n \"category_id\": 1\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:36:48 GMT","Content-Type":"application/json","Content-Length":"55"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":64}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Молоко","price":10000,"amount":1,"category_id":1}},"data":{"id":3,"name":"Молоко","price":10000,"amount":1}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:36:48 GMT","Content-Type":"application/json","Content-Length":"55"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":64}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Молоко","price":10000,"amount":1,"category_id":1}},"data":{"id":3,"name":"Молоко","price":10000,"amount":1}}},{"mime":"text/html","value":"[object Object]"}]}] \ No newline at end of file +[{"kind":1,"language":"markdown","value":"# Авторизация","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/login\nauthorization: Y3JhYjpjcmFi\n\n{\n \"username\": \"foo\",\n \"password\": \"bar\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:39:08 GMT","Content-Type":"application/json","Content-Length":"26"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/login","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:39:08 GMT","Content-Type":"application/json","Content-Length":"26"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Agent":"axios/0.21.4","Content-Length":35}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/login","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi"},"data":{"username":"foo","password":"bar"}},"data":{"id":1,"username":"foo"}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление бюджета","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/budgets\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"name\": \"Семейный\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:39:10 GMT","Content-Type":"application/json","Content-Length":"84"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":27}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Семейный"}},"data":{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[]}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:39:10 GMT","Content-Type":"application/json","Content-Length":"84"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":27}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Семейный"}},"data":{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[]}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Запрос бюджетов","outputs":[]},{"kind":2,"language":"rest-book","value":"GET http://localhost:8090/budgets\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:56 GMT","Content-Type":"application/json","Content-Length":"259"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4"}},"request":{"method":"GET","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"}},"data":{"budgets":[{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[{"id":1,"name":"Транспорт","budgetId":0,"favorite":false,"monthlyLimit":0},{"id":2,"name":"Продукты","budgetId":0,"favorite":false,"monthlyLimit":0}]}]}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:33:56 GMT","Content-Type":"application/json","Content-Length":"259"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4"}},"request":{"method":"GET","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"}},"data":{"budgets":[{"id":1,"name":"Семейный","startDay":0,"monthlyLimit":0,"categories":[{"id":1,"name":"Транспорт","budgetId":0,"favorite":false,"monthlyLimit":0},{"id":2,"name":"Продукты","budgetId":0,"favorite":false,"monthlyLimit":0}]}]}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление пользователя в бюджет","outputs":[]},{"kind":2,"language":"rest-book","value":"PUT http://localhost:8090/budgets/1/users\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"user_id\": \"2\"\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:21:36 GMT","Content-Type":"application/json","Content-Length":"2"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":15}},"request":{"method":"PUT","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets/1/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"user_id":"2"}},"data":{}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Sun, 24 Nov 2024 15:21:36 GMT","Content-Type":"application/json","Content-Length":"2"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":15}},"request":{"method":"PUT","httpVersion":"1.1","responseUrl":"http://localhost:8090/budgets/1/users","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"user_id":"2"}},"data":{}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление траты","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/wastes\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"name\": \"Молоко\",\n \"price\": 10000,\n \"amount\": 1,\n \"budget_id\": 1,\n \"category_id\": 1\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:36:48 GMT","Content-Type":"application/json","Content-Length":"55"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":64}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Молоко","price":10000,"amount":1,"category_id":1}},"data":{"id":3,"name":"Молоко","price":10000,"amount":1}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Mon, 25 Nov 2024 09:36:48 GMT","Content-Type":"application/json","Content-Length":"55"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":64}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"name":"Молоко","price":10000,"amount":1,"category_id":1}},"data":{"id":3,"name":"Молоко","price":10000,"amount":1}}},{"mime":"text/html","value":"[object Object]"}]},{"kind":1,"language":"markdown","value":"# Добавление траты","outputs":[]},{"kind":2,"language":"rest-book","value":"POST http://localhost:8090/wastes/text\nauthorization: Y3JhYjpjcmFi\nUser-Id: 1\n\n{\n \"text\": \"ранспорт: акси 3 200\",\n \"budget_id\": 1\n}","outputs":[{"mime":"x-application/rest-book","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:42:25 GMT","Content-Type":"application/json","Content-Length":"54"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":57}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes/text","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"text":"ранспорт: акси 3 200","budget_id":1}},"data":{"id":6,"name":"Акси","price":20000,"amount":3}}},{"mime":"text/x-json","value":{"status":200,"statusText":"OK","headers":{"Date":"Wed, 27 Nov 2024 23:42:25 GMT","Content-Type":"application/json","Content-Length":"54"},"config":{"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","authorization":"Y3JhYjpjcmFi","User-Id":"1","User-Agent":"axios/0.21.4","Content-Length":57}},"request":{"method":"POST","httpVersion":"1.1","responseUrl":"http://localhost:8090/wastes/text","timeout":10000,"headers":{"authorization":"Y3JhYjpjcmFi","User-Id":"1"},"data":{"text":"ранспорт: акси 3 200","budget_id":1}},"data":{"id":6,"name":"Акси","price":20000,"amount":3}}},{"mime":"text/html","value":"[object Object]"}]}] \ No newline at end of file diff --git a/internal/services/user/user_service.go b/internal/services/user/user_service.go index 4596869..7f63f70 100644 --- a/internal/services/user/user_service.go +++ b/internal/services/user/user_service.go @@ -4,11 +4,8 @@ import ( "context" "crypto/md5" "encoding/hex" - "errors" - "fmt" "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgxpool" ) @@ -42,33 +39,20 @@ func NewUserService( } } -func (s *UserService) AddUser(ctx context.Context, user *UserEntity) (*UserEntity, error) { - query := `INSERT INTO users (username, password) VALUES (@username, @password) RETURNING id` - args := pgx.NamedArgs{ - "username": user.Username, - "password": hashPassword(user.Username, user.Password, "crab"), - } - if err := s.db.QueryRow(ctx, query, args).Scan(&user.Id); err != nil { - var pgErr *pgconn.PgError - if errors.As(err, &pgErr) { - if pgErr.Code == "23505" && pgErr.ConstraintName == "users_username_key" { // unique_violation - return nil, &UsernameAlreadyExistsErr{} - } - } - return nil, fmt.Errorf("unable to insert row: %w", err) - } - return user, nil -} - func (s *UserService) Login(ctx context.Context, user *UserEntity) (*UserEntity, error) { - query := `SELECT id FROM users WHERE username = @username AND password = @password` args := pgx.NamedArgs{ "username": user.Username, "password": hashPassword(user.Username, user.Password, "crab"), } + + query := `SELECT id FROM users WHERE username = @username AND password = @password LIMIT 1` if err := s.db.QueryRow(ctx, query, args).Scan(&user.Id); err != nil { - return nil, &UserNotFoundErr{} + query := `INSERT INTO users (username, password) VALUES (@username, @password) RETURNING id` + if err := s.db.QueryRow(ctx, query, args).Scan(&user.Id); err != nil { + return user, err + } } + return user, nil } diff --git a/internal/services/waste/waste_service.go b/internal/services/waste/waste_service.go index bc854e1..44d40eb 100644 --- a/internal/services/waste/waste_service.go +++ b/internal/services/waste/waste_service.go @@ -3,19 +3,30 @@ package waste import ( "context" "fmt" + "strconv" + "strings" "git.3crabs.ru/save_my_money/smm_core/internal/services/category" "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgxpool" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) type WasteEntity struct { - Id int - Name string - Price int - Amount float32 - BudgetId int + Id int + Name string + Price int + Amount float32 + CategoryId int + CategoryName string + BudgetId int +} + +type WasteTextEntity struct { + Text string CategoryId int + BudgetId int } type WasteService struct { @@ -34,17 +45,12 @@ func NewWasteService( } func (s *WasteService) AddWaste(ctx context.Context, waste *WasteEntity) (*WasteEntity, error) { - category, err := s.categoryService.GetCategory(ctx, waste.CategoryId) - if err != nil { - return nil, err - } - query := `INSERT INTO wastes (name, price, amount, budget_id, category_id) VALUES (@name, @price, @amount, @budget_id, @category_id) RETURNING id` args := pgx.NamedArgs{ "name": waste.Name, "price": waste.Price, "amount": waste.Amount, - "budget_id": category.BudgetId, + "budget_id": waste.BudgetId, "category_id": waste.CategoryId, } if err := s.db.QueryRow(ctx, query, args).Scan(&waste.Id); err != nil { @@ -52,3 +58,133 @@ func (s *WasteService) AddWaste(ctx context.Context, waste *WasteEntity) (*Waste } return waste, nil } + +func (s *WasteService) GetWaste(ctx context.Context, budgetId int, name string) (*WasteEntity, error) { + query := `SELECT id, name, price, amount, budget_id, category_id FROM wastes WHERE budget_id = @budget_id AND LOWER(name) = LOWER(@name) LIMIT 1` + args := pgx.NamedArgs{ + "name": name, + "budget_id": budgetId, + } + rows, err := s.db.Query(ctx, query, args) + if err != nil { + return nil, err + } + wastes := []*WasteEntity{} + defer rows.Close() + for rows.Next() { + waste := &WasteEntity{} + err = rows.Scan(&waste.Id, &waste.Name, &waste.Price, &waste.Amount, &waste.BudgetId, &waste.CategoryId) + if err != nil { + return nil, err + } + wastes = append(wastes, waste) + } + if len(wastes) > 0 { + return wastes[0], nil + } + return nil, nil +} + +func (s *WasteService) AddWasteByText(ctx context.Context, wasteText *WasteTextEntity) (*WasteEntity, error) { + waste := s.parseWaste(wasteText.Text) + + var categoryId *int + if waste.CategoryName != "" { + c, err := s.categoryService.GetCategory(ctx, wasteText.BudgetId, waste.CategoryName) + if err != nil { + return nil, err + } + if c == nil { + c, err = s.categoryService.AddCategory(ctx, &category.CategoryEntity{ + Name: waste.CategoryName, + BudgetId: int(wasteText.BudgetId), + }) + if err != nil { + return nil, err + } + } + categoryId = &c.Id + } + if categoryId == nil { + w, err := s.GetWaste(ctx, wasteText.BudgetId, waste.Name) + if err != nil { + return nil, err + } + if w != nil { + categoryId = &w.CategoryId + } + } + + if categoryId == nil { + return nil, fmt.Errorf("bad request") + } + + query := `INSERT INTO wastes (name, price, amount, budget_id, category_id) VALUES (@name, @price, @amount, @budget_id, @category_id) RETURNING id` + args := pgx.NamedArgs{ + "name": waste.Name, + "price": waste.Price, + "amount": waste.Amount, + "budget_id": wasteText.BudgetId, + "category_id": *categoryId, + } + if err := s.db.QueryRow(ctx, query, args).Scan(&waste.Id); err != nil { + return nil, fmt.Errorf("unable to insert row: %w", err) + } + return waste, nil +} + +func (s *WasteService) parseWaste(text string) *WasteEntity { + text = strings.TrimSpace(text) + arr := strings.Split(text, ":") + + waste := &WasteEntity{} + switch len(arr) { + case 1: + arr = strings.Split(strings.TrimSpace(arr[0]), " ") + case 2: + waste.CategoryName = strToName(arr[0]) + arr = strings.Split(strings.TrimSpace(arr[1]), " ") + } + + switch len(arr) { + case 2: + waste.Name = strToName(arr[0]) + waste.Amount = 1 + waste.Price = strToPrice(arr[1]) + case 3: + waste.Name = strToName(arr[0]) + waste.Amount = strToAmount(arr[1]) + waste.Price = strToPrice(arr[2]) + } + return waste +} + +func strToFloat(s string) float32 { + a, err := strconv.ParseFloat(s, 32) + if err != nil { + panic(err) + } + return float32(a) +} + +func strToPrice(s string) int { + s = strings.TrimSpace(s) + s = strings.TrimSuffix(s, "/кг") + s = strings.TrimSuffix(s, "/шт") + s = strings.TrimSuffix(s, "р") + s = strings.TrimSuffix(s, "руб") + s = strings.TrimSuffix(s, "рублей") + return int(strToFloat(s) * 100) +} + +func strToAmount(s string) float32 { + s = strings.TrimSpace(s) + s = strings.TrimSuffix(s, "шт") + s = strings.TrimSuffix(s, "кг") + return strToFloat(s) +} + +func strToName(s string) string { + caser := cases.Title(language.Russian) + return caser.String(strings.TrimSpace(strings.ToLower(s))) +} diff --git a/internal/services/waste/waste_service_test.go b/internal/services/waste/waste_service_test.go new file mode 100644 index 0000000..ce43f39 --- /dev/null +++ b/internal/services/waste/waste_service_test.go @@ -0,0 +1,83 @@ +package waste + +import ( + "reflect" + "testing" +) + +func TestWasteService_parseWaste(t *testing.T) { + type args struct { + text string + } + tests := []struct { + name string + args args + want *WasteEntity + }{ + { + name: "full", + args: args{ + text: "Транспорт: такси 2 200", + }, + want: &WasteEntity{ + CategoryName: "транспорт", + Name: "такси", + Amount: 2, + Price: 20000, + }, + }, + { + name: "full without amount", + args: args{ + text: "Транспорт: такси 200", + }, + want: &WasteEntity{ + CategoryName: "транспорт", + Name: "такси", + Amount: 1, + Price: 20000, + }, + }, + { + name: "without category", + args: args{ + text: "такси 2 200", + }, + want: &WasteEntity{ + Name: "такси", + Amount: 2, + Price: 20000, + }, + }, + { + name: "without amount", + args: args{ + text: "такси 200", + }, + want: &WasteEntity{ + Name: "такси", + Amount: 1, + Price: 20000, + }, + }, + { + name: "р", + args: args{ + text: "такси 200р", + }, + want: &WasteEntity{ + Name: "такси", + Amount: 1, + Price: 20000, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + s := &WasteService{} + if got := s.parseWaste(tt.args.text); !reflect.DeepEqual(got, tt.want) { + t.Errorf("WasteService.parseWaste() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/proto/smm_core.pb.go b/proto/smm_core.pb.go index 24dc03a..91f146b 100644 --- a/proto/smm_core.pb.go +++ b/proto/smm_core.pb.go @@ -1177,6 +1177,7 @@ type AddWasteReq struct { Price int32 `protobuf:"varint,2,opt,name=price,proto3" json:"price,omitempty"` Amount float32 `protobuf:"fixed32,3,opt,name=amount,proto3" json:"amount,omitempty"` CategoryId int32 `protobuf:"varint,4,opt,name=category_id,json=categoryId,proto3" json:"category_id,omitempty"` + BudgetId int32 `protobuf:"varint,5,opt,name=budget_id,json=budgetId,proto3" json:"budget_id,omitempty"` } func (x *AddWasteReq) Reset() { @@ -1237,6 +1238,74 @@ func (x *AddWasteReq) GetCategoryId() int32 { return 0 } +func (x *AddWasteReq) GetBudgetId() int32 { + if x != nil { + return x.BudgetId + } + return 0 +} + +type AddWasteTextReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` + CategoryId int32 `protobuf:"varint,2,opt,name=category_id,json=categoryId,proto3" json:"category_id,omitempty"` + BudgetId int32 `protobuf:"varint,3,opt,name=budget_id,json=budgetId,proto3" json:"budget_id,omitempty"` +} + +func (x *AddWasteTextReq) Reset() { + *x = AddWasteTextReq{} + mi := &file_smm_core_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AddWasteTextReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddWasteTextReq) ProtoMessage() {} + +func (x *AddWasteTextReq) ProtoReflect() protoreflect.Message { + mi := &file_smm_core_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddWasteTextReq.ProtoReflect.Descriptor instead. +func (*AddWasteTextReq) Descriptor() ([]byte, []int) { + return file_smm_core_proto_rawDescGZIP(), []int{23} +} + +func (x *AddWasteTextReq) GetText() string { + if x != nil { + return x.Text + } + return "" +} + +func (x *AddWasteTextReq) GetCategoryId() int32 { + if x != nil { + return x.CategoryId + } + return 0 +} + +func (x *AddWasteTextReq) GetBudgetId() int32 { + if x != nil { + return x.BudgetId + } + return 0 +} + type Waste struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1250,7 +1319,7 @@ type Waste struct { func (x *Waste) Reset() { *x = Waste{} - mi := &file_smm_core_proto_msgTypes[23] + mi := &file_smm_core_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1262,7 +1331,7 @@ func (x *Waste) String() string { func (*Waste) ProtoMessage() {} func (x *Waste) ProtoReflect() protoreflect.Message { - mi := &file_smm_core_proto_msgTypes[23] + mi := &file_smm_core_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1275,7 +1344,7 @@ func (x *Waste) ProtoReflect() protoreflect.Message { // Deprecated: Use Waste.ProtoReflect.Descriptor instead. func (*Waste) Descriptor() ([]byte, []int) { - return file_smm_core_proto_rawDescGZIP(), []int{23} + return file_smm_core_proto_rawDescGZIP(), []int{24} } func (x *Waste) GetId() int32 { @@ -1316,7 +1385,7 @@ type DeleteWasteReq struct { func (x *DeleteWasteReq) Reset() { *x = DeleteWasteReq{} - mi := &file_smm_core_proto_msgTypes[24] + mi := &file_smm_core_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1328,7 +1397,7 @@ func (x *DeleteWasteReq) String() string { func (*DeleteWasteReq) ProtoMessage() {} func (x *DeleteWasteReq) ProtoReflect() protoreflect.Message { - mi := &file_smm_core_proto_msgTypes[24] + mi := &file_smm_core_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1341,7 +1410,7 @@ func (x *DeleteWasteReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteWasteReq.ProtoReflect.Descriptor instead. func (*DeleteWasteReq) Descriptor() ([]byte, []int) { - return file_smm_core_proto_rawDescGZIP(), []int{24} + return file_smm_core_proto_rawDescGZIP(), []int{25} } func (x *DeleteWasteReq) GetId() int32 { @@ -1361,7 +1430,7 @@ type GetCategoriesStatReq struct { func (x *GetCategoriesStatReq) Reset() { *x = GetCategoriesStatReq{} - mi := &file_smm_core_proto_msgTypes[25] + mi := &file_smm_core_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1373,7 +1442,7 @@ func (x *GetCategoriesStatReq) String() string { func (*GetCategoriesStatReq) ProtoMessage() {} func (x *GetCategoriesStatReq) ProtoReflect() protoreflect.Message { - mi := &file_smm_core_proto_msgTypes[25] + mi := &file_smm_core_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1386,7 +1455,7 @@ func (x *GetCategoriesStatReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetCategoriesStatReq.ProtoReflect.Descriptor instead. func (*GetCategoriesStatReq) Descriptor() ([]byte, []int) { - return file_smm_core_proto_rawDescGZIP(), []int{25} + return file_smm_core_proto_rawDescGZIP(), []int{26} } func (x *GetCategoriesStatReq) GetIds() []int32 { @@ -1406,7 +1475,7 @@ type CategoriesStat struct { func (x *CategoriesStat) Reset() { *x = CategoriesStat{} - mi := &file_smm_core_proto_msgTypes[26] + mi := &file_smm_core_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1418,7 +1487,7 @@ func (x *CategoriesStat) String() string { func (*CategoriesStat) ProtoMessage() {} func (x *CategoriesStat) ProtoReflect() protoreflect.Message { - mi := &file_smm_core_proto_msgTypes[26] + mi := &file_smm_core_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1431,7 +1500,7 @@ func (x *CategoriesStat) ProtoReflect() protoreflect.Message { // Deprecated: Use CategoriesStat.ProtoReflect.Descriptor instead. func (*CategoriesStat) Descriptor() ([]byte, []int) { - return file_smm_core_proto_rawDescGZIP(), []int{26} + return file_smm_core_proto_rawDescGZIP(), []int{27} } func (x *CategoriesStat) GetStat() []*CategoriesStat { @@ -1453,7 +1522,7 @@ type CategoryStat struct { func (x *CategoryStat) Reset() { *x = CategoryStat{} - mi := &file_smm_core_proto_msgTypes[27] + mi := &file_smm_core_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1465,7 +1534,7 @@ func (x *CategoryStat) String() string { func (*CategoryStat) ProtoMessage() {} func (x *CategoryStat) ProtoReflect() protoreflect.Message { - mi := &file_smm_core_proto_msgTypes[27] + mi := &file_smm_core_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1478,7 +1547,7 @@ func (x *CategoryStat) ProtoReflect() protoreflect.Message { // Deprecated: Use CategoryStat.ProtoReflect.Descriptor instead. func (*CategoryStat) Descriptor() ([]byte, []int) { - return file_smm_core_proto_rawDescGZIP(), []int{27} + return file_smm_core_proto_rawDescGZIP(), []int{28} } func (x *CategoryStat) GetName() string { @@ -1607,143 +1676,152 @@ var file_smm_core_proto_rawDesc = []byte{ 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0x25, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x70, - 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x1f, 0x0a, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, - 0x22, 0x59, 0x0a, 0x05, 0x57, 0x61, 0x73, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, - 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x20, 0x0a, 0x0e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x28, 0x0a, - 0x14, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, - 0x61, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x05, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x44, 0x0a, 0x0e, 0x43, 0x61, 0x74, 0x65, 0x67, - 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x12, 0x32, 0x0a, 0x04, 0x73, 0x74, 0x61, - 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, - 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, - 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x5f, 0x0a, - 0x0c, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, - 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0x9a, - 0x0d, 0x0a, 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x47, 0x0a, 0x04, 0x50, 0x69, - 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, - 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x70, - 0x69, 0x6e, 0x67, 0x12, 0x4e, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x8d, + 0x01, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x49, + 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x49, 0x64, 0x22, 0x63, + 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, + 0x71, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, + 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x75, 0x64, 0x67, 0x65, + 0x74, 0x49, 0x64, 0x22, 0x59, 0x0a, 0x05, 0x57, 0x61, 0x73, 0x74, 0x65, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x20, + 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, + 0x22, 0x28, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, + 0x73, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x03, 0x69, 0x64, 0x73, 0x22, 0x44, 0x0a, 0x0e, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x12, 0x32, 0x0a, 0x04, + 0x73, 0x74, 0x61, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x72, 0x61, + 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, + 0x22, 0x5f, 0x0a, 0x0c, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x6f, 0x6e, + 0x74, 0x68, 0x6c, 0x79, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x32, 0xad, 0x0d, 0x0a, 0x07, 0x53, 0x6d, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x47, 0x0a, + 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, + 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, - 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x63, 0x72, 0x61, - 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, 0x06, 0x2f, 0x75, 0x73, - 0x65, 0x72, 0x73, 0x12, 0x4a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x2e, 0x63, - 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, - 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x11, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, 0x06, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, - 0x56, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x1c, 0x2e, 0x63, - 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, - 0x64, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, 0x61, + 0x50, 0x69, 0x6e, 0x67, 0x52, 0x73, 0x70, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, + 0x05, 0x2f, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x4a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, + 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, + 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x3a, 0x01, 0x2a, 0x22, 0x06, 0x2f, 0x6c, 0x6f, 0x67, + 0x69, 0x6e, 0x12, 0x56, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, + 0x1c, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x41, 0x64, 0x64, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, + 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, + 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x3a, 0x01, 0x2a, + 0x22, 0x08, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x61, 0x0a, 0x0c, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x63, 0x72, 0x61, + 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, + 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, + 0x67, 0x65, 0x74, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x1a, 0x0d, + 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x56, 0x0a, + 0x0a, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x63, 0x72, + 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, + 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, - 0x65, 0x74, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x3a, 0x01, 0x2a, 0x22, 0x08, 0x2f, - 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x61, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, - 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, - 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, - 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, - 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x1a, 0x0d, 0x2f, 0x62, 0x75, - 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x56, 0x0a, 0x0a, 0x47, 0x65, - 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, - 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, - 0x67, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, - 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, - 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x73, 0x12, 0x5e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x75, 0x64, 0x67, - 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, - 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x15, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0f, 0x2a, 0x0d, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, - 0x64, 0x7d, 0x12, 0x70, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x42, - 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x22, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, - 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, - 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x63, 0x72, 0x61, 0x62, - 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x4b, 0x22, 0x25, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x01, 0x2a, 0x1a, 0x1a, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x75, - 0x73, 0x65, 0x72, 0x73, 0x12, 0x67, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, - 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, 0x61, 0x62, - 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x73, - 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x85, 0x01, - 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x55, 0x73, 0x65, 0x72, 0x46, 0x72, 0x6f, 0x6d, - 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x27, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, - 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, - 0x16, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, 0x2a, - 0x24, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, 0x64, 0x67, 0x65, - 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x82, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, - 0x67, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x26, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, - 0x65, 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, - 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, - 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, - 0x73, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x12, 0x1f, 0x2f, 0x62, 0x75, 0x64, 0x67, - 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x2f, - 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x5f, 0x0a, 0x0b, 0x41, 0x64, - 0x64, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1e, 0x2e, 0x63, 0x72, 0x61, 0x62, - 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, - 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, - 0x6f, 0x72, 0x79, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a, 0x01, 0x2a, 0x22, 0x0b, - 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x67, 0x0a, 0x0e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x21, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x65, 0x74, 0x73, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x62, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x73, 0x12, 0x5e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, + 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x1f, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, + 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x75, 0x64, + 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, + 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x15, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x2a, 0x0d, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, + 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x70, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, + 0x54, 0x6f, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x22, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, + 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, + 0x72, 0x54, 0x6f, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x4b, + 0x22, 0x25, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x3a, 0x01, 0x2a, 0x1a, 0x1a, 0x2f, 0x62, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, + 0x7d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x67, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x62, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x12, 0x85, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x55, 0x73, 0x65, 0x72, 0x46, + 0x72, 0x6f, 0x6d, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x27, 0x2e, 0x63, 0x72, 0x61, 0x62, + 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x26, 0x2a, 0x24, 0x2f, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, + 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x7d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x82, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, + 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, + 0x12, 0x26, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, + 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, + 0x72, 0x69, 0x65, 0x73, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x12, 0x1f, 0x2f, 0x62, + 0x75, 0x64, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x5f, 0x69, + 0x64, 0x7d, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x5f, 0x0a, + 0x0b, 0x41, 0x64, 0x64, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x1e, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, + 0x64, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a, 0x01, + 0x2a, 0x22, 0x0b, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x67, + 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x12, 0x21, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x18, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x1a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, + 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x6b, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x23, 0x2e, 0x63, 0x72, + 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x65, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x12, 0x1a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x2f, - 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x6b, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x23, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, - 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x2a, - 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, - 0x7d, 0x12, 0x52, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x12, 0x1b, 0x2e, - 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, - 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, 0x61, + 0x02, 0x12, 0x2a, 0x10, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x2f, + 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x52, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, + 0x12, 0x1b, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x41, 0x64, 0x64, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, + 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x57, + 0x61, 0x73, 0x74, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x3a, 0x01, 0x2a, 0x22, + 0x07, 0x2f, 0x77, 0x61, 0x73, 0x74, 0x65, 0x73, 0x12, 0x61, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x57, + 0x61, 0x73, 0x74, 0x65, 0x42, 0x79, 0x54, 0x65, 0x78, 0x74, 0x12, 0x1f, 0x2e, 0x63, 0x72, 0x61, + 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x57, + 0x61, 0x73, 0x74, 0x65, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, + 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x61, 0x73, + 0x74, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a, 0x01, 0x2a, 0x22, 0x0c, 0x2f, + 0x77, 0x61, 0x73, 0x74, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x12, 0x5a, 0x0a, 0x0b, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x61, 0x73, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x63, 0x72, 0x61, + 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x65, 0x57, 0x61, 0x73, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x61, 0x73, 0x74, - 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x3a, 0x01, 0x2a, 0x22, 0x07, 0x2f, 0x77, - 0x61, 0x73, 0x74, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, - 0x61, 0x73, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, - 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x61, 0x73, 0x74, - 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, - 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x57, 0x61, 0x73, 0x74, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x0e, 0x2a, 0x0c, 0x2f, 0x77, 0x61, 0x73, 0x74, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, - 0x7d, 0x12, 0x68, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, - 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x12, 0x24, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, - 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, - 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x63, - 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x22, 0x0d, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x42, 0x0e, 0x92, 0x41, 0x00, - 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x2a, 0x0c, 0x2f, 0x77, 0x61, 0x73, 0x74, + 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x68, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x61, + 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x12, 0x24, 0x2e, 0x63, + 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, + 0x74, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x52, + 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x73, 0x6d, 0x6d, 0x5f, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x53, 0x74, + 0x61, 0x74, 0x22, 0x0d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x07, 0x12, 0x05, 0x2f, 0x73, 0x74, 0x61, + 0x74, 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1758,7 +1836,7 @@ func file_smm_core_proto_rawDescGZIP() []byte { return file_smm_core_proto_rawDescData } -var file_smm_core_proto_msgTypes = make([]protoimpl.MessageInfo, 28) +var file_smm_core_proto_msgTypes = make([]protoimpl.MessageInfo, 29) var file_smm_core_proto_goTypes = []any{ (*PingReq)(nil), // 0: crabs.smm_core.PingReq (*PingRsp)(nil), // 1: crabs.smm_core.PingRsp @@ -1783,52 +1861,53 @@ var file_smm_core_proto_goTypes = []any{ (*Categories)(nil), // 20: crabs.smm_core.Categories (*DeleteCategoriesReq)(nil), // 21: crabs.smm_core.DeleteCategoriesReq (*AddWasteReq)(nil), // 22: crabs.smm_core.AddWasteReq - (*Waste)(nil), // 23: crabs.smm_core.Waste - (*DeleteWasteReq)(nil), // 24: crabs.smm_core.DeleteWasteReq - (*GetCategoriesStatReq)(nil), // 25: crabs.smm_core.GetCategoriesStatReq - (*CategoriesStat)(nil), // 26: crabs.smm_core.CategoriesStat - (*CategoryStat)(nil), // 27: crabs.smm_core.CategoryStat + (*AddWasteTextReq)(nil), // 23: crabs.smm_core.AddWasteTextReq + (*Waste)(nil), // 24: crabs.smm_core.Waste + (*DeleteWasteReq)(nil), // 25: crabs.smm_core.DeleteWasteReq + (*GetCategoriesStatReq)(nil), // 26: crabs.smm_core.GetCategoriesStatReq + (*CategoriesStat)(nil), // 27: crabs.smm_core.CategoriesStat + (*CategoryStat)(nil), // 28: crabs.smm_core.CategoryStat } var file_smm_core_proto_depIdxs = []int32{ 18, // 0: crabs.smm_core.Budget.categories:type_name -> crabs.smm_core.Category 7, // 1: crabs.smm_core.Budgets.budgets:type_name -> crabs.smm_core.Budget 4, // 2: crabs.smm_core.Users.users:type_name -> crabs.smm_core.User 18, // 3: crabs.smm_core.Categories.categories:type_name -> crabs.smm_core.Category - 26, // 4: crabs.smm_core.CategoriesStat.stat:type_name -> crabs.smm_core.CategoriesStat + 27, // 4: crabs.smm_core.CategoriesStat.stat:type_name -> crabs.smm_core.CategoriesStat 0, // 5: crabs.smm_core.SmmCore.Ping:input_type -> crabs.smm_core.PingReq - 3, // 6: crabs.smm_core.SmmCore.AddUser:input_type -> crabs.smm_core.AddUserReq - 5, // 7: crabs.smm_core.SmmCore.Login:input_type -> crabs.smm_core.LoginReq - 6, // 8: crabs.smm_core.SmmCore.AddBudget:input_type -> crabs.smm_core.AddBudgetReq - 8, // 9: crabs.smm_core.SmmCore.UpdateBudget:input_type -> crabs.smm_core.UpdateBudgetReq - 9, // 10: crabs.smm_core.SmmCore.GetBudgets:input_type -> crabs.smm_core.GetBudgetsReq - 11, // 11: crabs.smm_core.SmmCore.DeleteBudget:input_type -> crabs.smm_core.DeleteBudgetReq - 12, // 12: crabs.smm_core.SmmCore.AddUserToBudget:input_type -> crabs.smm_core.AddUserToBudgetReq - 13, // 13: crabs.smm_core.SmmCore.GetBudgetUsers:input_type -> crabs.smm_core.GetBudgetUsersReq - 15, // 14: crabs.smm_core.SmmCore.RemoveUserFromBudget:input_type -> crabs.smm_core.RemoveUserFromBudgetReq - 16, // 15: crabs.smm_core.SmmCore.GetBudgetCategories:input_type -> crabs.smm_core.GetBudgetCategoriesReq - 17, // 16: crabs.smm_core.SmmCore.AddCategory:input_type -> crabs.smm_core.AddCategoryReq - 19, // 17: crabs.smm_core.SmmCore.UpdateCategory:input_type -> crabs.smm_core.UpdateCategoryReq - 21, // 18: crabs.smm_core.SmmCore.DeleteCategories:input_type -> crabs.smm_core.DeleteCategoriesReq - 22, // 19: crabs.smm_core.SmmCore.AddWaste:input_type -> crabs.smm_core.AddWasteReq - 24, // 20: crabs.smm_core.SmmCore.DeleteWaste:input_type -> crabs.smm_core.DeleteWasteReq - 25, // 21: crabs.smm_core.SmmCore.GetCategoriesStat:input_type -> crabs.smm_core.GetCategoriesStatReq + 5, // 6: crabs.smm_core.SmmCore.Login:input_type -> crabs.smm_core.LoginReq + 6, // 7: crabs.smm_core.SmmCore.AddBudget:input_type -> crabs.smm_core.AddBudgetReq + 8, // 8: crabs.smm_core.SmmCore.UpdateBudget:input_type -> crabs.smm_core.UpdateBudgetReq + 9, // 9: crabs.smm_core.SmmCore.GetBudgets:input_type -> crabs.smm_core.GetBudgetsReq + 11, // 10: crabs.smm_core.SmmCore.DeleteBudget:input_type -> crabs.smm_core.DeleteBudgetReq + 12, // 11: crabs.smm_core.SmmCore.AddUserToBudget:input_type -> crabs.smm_core.AddUserToBudgetReq + 13, // 12: crabs.smm_core.SmmCore.GetBudgetUsers:input_type -> crabs.smm_core.GetBudgetUsersReq + 15, // 13: crabs.smm_core.SmmCore.RemoveUserFromBudget:input_type -> crabs.smm_core.RemoveUserFromBudgetReq + 16, // 14: crabs.smm_core.SmmCore.GetBudgetCategories:input_type -> crabs.smm_core.GetBudgetCategoriesReq + 17, // 15: crabs.smm_core.SmmCore.AddCategory:input_type -> crabs.smm_core.AddCategoryReq + 19, // 16: crabs.smm_core.SmmCore.UpdateCategory:input_type -> crabs.smm_core.UpdateCategoryReq + 21, // 17: crabs.smm_core.SmmCore.DeleteCategories:input_type -> crabs.smm_core.DeleteCategoriesReq + 22, // 18: crabs.smm_core.SmmCore.AddWaste:input_type -> crabs.smm_core.AddWasteReq + 23, // 19: crabs.smm_core.SmmCore.AddWasteByText:input_type -> crabs.smm_core.AddWasteTextReq + 25, // 20: crabs.smm_core.SmmCore.DeleteWaste:input_type -> crabs.smm_core.DeleteWasteReq + 26, // 21: crabs.smm_core.SmmCore.GetCategoriesStat:input_type -> crabs.smm_core.GetCategoriesStatReq 1, // 22: crabs.smm_core.SmmCore.Ping:output_type -> crabs.smm_core.PingRsp - 4, // 23: crabs.smm_core.SmmCore.AddUser:output_type -> crabs.smm_core.User - 4, // 24: crabs.smm_core.SmmCore.Login:output_type -> crabs.smm_core.User - 7, // 25: crabs.smm_core.SmmCore.AddBudget:output_type -> crabs.smm_core.Budget - 7, // 26: crabs.smm_core.SmmCore.UpdateBudget:output_type -> crabs.smm_core.Budget - 10, // 27: crabs.smm_core.SmmCore.GetBudgets:output_type -> crabs.smm_core.Budgets - 7, // 28: crabs.smm_core.SmmCore.DeleteBudget:output_type -> crabs.smm_core.Budget - 2, // 29: crabs.smm_core.SmmCore.AddUserToBudget:output_type -> crabs.smm_core.OK - 14, // 30: crabs.smm_core.SmmCore.GetBudgetUsers:output_type -> crabs.smm_core.Users - 7, // 31: crabs.smm_core.SmmCore.RemoveUserFromBudget:output_type -> crabs.smm_core.Budget - 20, // 32: crabs.smm_core.SmmCore.GetBudgetCategories:output_type -> crabs.smm_core.Categories - 18, // 33: crabs.smm_core.SmmCore.AddCategory:output_type -> crabs.smm_core.Category - 18, // 34: crabs.smm_core.SmmCore.UpdateCategory:output_type -> crabs.smm_core.Category - 18, // 35: crabs.smm_core.SmmCore.DeleteCategories:output_type -> crabs.smm_core.Category - 23, // 36: crabs.smm_core.SmmCore.AddWaste:output_type -> crabs.smm_core.Waste - 23, // 37: crabs.smm_core.SmmCore.DeleteWaste:output_type -> crabs.smm_core.Waste - 26, // 38: crabs.smm_core.SmmCore.GetCategoriesStat:output_type -> crabs.smm_core.CategoriesStat + 4, // 23: crabs.smm_core.SmmCore.Login:output_type -> crabs.smm_core.User + 7, // 24: crabs.smm_core.SmmCore.AddBudget:output_type -> crabs.smm_core.Budget + 7, // 25: crabs.smm_core.SmmCore.UpdateBudget:output_type -> crabs.smm_core.Budget + 10, // 26: crabs.smm_core.SmmCore.GetBudgets:output_type -> crabs.smm_core.Budgets + 7, // 27: crabs.smm_core.SmmCore.DeleteBudget:output_type -> crabs.smm_core.Budget + 2, // 28: crabs.smm_core.SmmCore.AddUserToBudget:output_type -> crabs.smm_core.OK + 14, // 29: crabs.smm_core.SmmCore.GetBudgetUsers:output_type -> crabs.smm_core.Users + 7, // 30: crabs.smm_core.SmmCore.RemoveUserFromBudget:output_type -> crabs.smm_core.Budget + 20, // 31: crabs.smm_core.SmmCore.GetBudgetCategories:output_type -> crabs.smm_core.Categories + 18, // 32: crabs.smm_core.SmmCore.AddCategory:output_type -> crabs.smm_core.Category + 18, // 33: crabs.smm_core.SmmCore.UpdateCategory:output_type -> crabs.smm_core.Category + 18, // 34: crabs.smm_core.SmmCore.DeleteCategories:output_type -> crabs.smm_core.Category + 24, // 35: crabs.smm_core.SmmCore.AddWaste:output_type -> crabs.smm_core.Waste + 24, // 36: crabs.smm_core.SmmCore.AddWasteByText:output_type -> crabs.smm_core.Waste + 24, // 37: crabs.smm_core.SmmCore.DeleteWaste:output_type -> crabs.smm_core.Waste + 27, // 38: crabs.smm_core.SmmCore.GetCategoriesStat:output_type -> crabs.smm_core.CategoriesStat 22, // [22:39] is the sub-list for method output_type 5, // [5:22] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -1847,7 +1926,7 @@ func file_smm_core_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_smm_core_proto_rawDesc, NumEnums: 0, - NumMessages: 28, + NumMessages: 29, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/smm_core.pb.gw.go b/proto/smm_core.pb.gw.go index 41acd51..9ac8dfc 100644 --- a/proto/smm_core.pb.gw.go +++ b/proto/smm_core.pb.gw.go @@ -49,32 +49,6 @@ func local_request_SmmCore_Ping_0(ctx context.Context, marshaler runtime.Marshal } -func request_SmmCore_AddUser_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq AddUserReq - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.AddUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_SmmCore_AddUser_0(ctx context.Context, marshaler runtime.Marshaler, server SmmCoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq AddUserReq - var metadata runtime.ServerMetadata - - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.AddUser(ctx, &protoReq) - return msg, metadata, err - -} - func request_SmmCore_Login_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq LoginReq var metadata runtime.ServerMetadata @@ -667,6 +641,32 @@ func local_request_SmmCore_AddWaste_0(ctx context.Context, marshaler runtime.Mar } +func request_SmmCore_AddWasteByText_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddWasteTextReq + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AddWasteByText(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SmmCore_AddWasteByText_0(ctx context.Context, marshaler runtime.Marshaler, server SmmCoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddWasteTextReq + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AddWasteByText(ctx, &protoReq) + return msg, metadata, err + +} + func request_SmmCore_DeleteWaste_0(ctx context.Context, marshaler runtime.Marshaler, client SmmCoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq DeleteWasteReq var metadata runtime.ServerMetadata @@ -787,31 +787,6 @@ func RegisterSmmCoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, se }) - mux.Handle("POST", pattern_SmmCore_AddUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.smm_core.SmmCore/AddUser", runtime.WithHTTPPathPattern("/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_SmmCore_AddUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_SmmCore_AddUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("POST", pattern_SmmCore_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1137,6 +1112,31 @@ func RegisterSmmCoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, se }) + mux.Handle("POST", pattern_SmmCore_AddWasteByText_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.smm_core.SmmCore/AddWasteByText", runtime.WithHTTPPathPattern("/wastes/text")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SmmCore_AddWasteByText_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SmmCore_AddWasteByText_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("DELETE", pattern_SmmCore_DeleteWaste_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1250,28 +1250,6 @@ func RegisterSmmCoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl }) - mux.Handle("POST", pattern_SmmCore_AddUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.smm_core.SmmCore/AddUser", runtime.WithHTTPPathPattern("/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_SmmCore_AddUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_SmmCore_AddUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("POST", pattern_SmmCore_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1558,6 +1536,28 @@ func RegisterSmmCoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl }) + mux.Handle("POST", pattern_SmmCore_AddWasteByText_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.smm_core.SmmCore/AddWasteByText", runtime.WithHTTPPathPattern("/wastes/text")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SmmCore_AddWasteByText_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SmmCore_AddWasteByText_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("DELETE", pattern_SmmCore_DeleteWaste_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1608,8 +1608,6 @@ func RegisterSmmCoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl var ( pattern_SmmCore_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ping"}, "")) - pattern_SmmCore_AddUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"users"}, "")) - pattern_SmmCore_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"login"}, "")) pattern_SmmCore_AddBudget_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"budgets"}, "")) @@ -1636,6 +1634,8 @@ var ( pattern_SmmCore_AddWaste_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"wastes"}, "")) + pattern_SmmCore_AddWasteByText_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"wastes", "text"}, "")) + pattern_SmmCore_DeleteWaste_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"wastes", "id"}, "")) pattern_SmmCore_GetCategoriesStat_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"stat"}, "")) @@ -1644,8 +1644,6 @@ var ( var ( forward_SmmCore_Ping_0 = runtime.ForwardResponseMessage - forward_SmmCore_AddUser_0 = runtime.ForwardResponseMessage - forward_SmmCore_Login_0 = runtime.ForwardResponseMessage forward_SmmCore_AddBudget_0 = runtime.ForwardResponseMessage @@ -1672,6 +1670,8 @@ var ( forward_SmmCore_AddWaste_0 = runtime.ForwardResponseMessage + forward_SmmCore_AddWasteByText_0 = runtime.ForwardResponseMessage + forward_SmmCore_DeleteWaste_0 = runtime.ForwardResponseMessage forward_SmmCore_GetCategoriesStat_0 = runtime.ForwardResponseMessage diff --git a/proto/smm_core_grpc.pb.go b/proto/smm_core_grpc.pb.go index 7b2f990..5223fb8 100644 --- a/proto/smm_core_grpc.pb.go +++ b/proto/smm_core_grpc.pb.go @@ -20,7 +20,6 @@ const _ = grpc.SupportPackageIsVersion9 const ( SmmCore_Ping_FullMethodName = "/crabs.smm_core.SmmCore/Ping" - SmmCore_AddUser_FullMethodName = "/crabs.smm_core.SmmCore/AddUser" SmmCore_Login_FullMethodName = "/crabs.smm_core.SmmCore/Login" SmmCore_AddBudget_FullMethodName = "/crabs.smm_core.SmmCore/AddBudget" SmmCore_UpdateBudget_FullMethodName = "/crabs.smm_core.SmmCore/UpdateBudget" @@ -34,6 +33,7 @@ const ( SmmCore_UpdateCategory_FullMethodName = "/crabs.smm_core.SmmCore/UpdateCategory" SmmCore_DeleteCategories_FullMethodName = "/crabs.smm_core.SmmCore/DeleteCategories" SmmCore_AddWaste_FullMethodName = "/crabs.smm_core.SmmCore/AddWaste" + SmmCore_AddWasteByText_FullMethodName = "/crabs.smm_core.SmmCore/AddWasteByText" SmmCore_DeleteWaste_FullMethodName = "/crabs.smm_core.SmmCore/DeleteWaste" SmmCore_GetCategoriesStat_FullMethodName = "/crabs.smm_core.SmmCore/GetCategoriesStat" ) @@ -44,8 +44,7 @@ const ( type SmmCoreClient interface { // ping Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error) - // users - AddUser(ctx context.Context, in *AddUserReq, opts ...grpc.CallOption) (*User, error) + // login Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*User, error) // budgets AddBudget(ctx context.Context, in *AddBudgetReq, opts ...grpc.CallOption) (*Budget, error) @@ -63,6 +62,7 @@ type SmmCoreClient interface { DeleteCategories(ctx context.Context, in *DeleteCategoriesReq, opts ...grpc.CallOption) (*Category, error) // wastes AddWaste(ctx context.Context, in *AddWasteReq, opts ...grpc.CallOption) (*Waste, error) + AddWasteByText(ctx context.Context, in *AddWasteTextReq, opts ...grpc.CallOption) (*Waste, error) DeleteWaste(ctx context.Context, in *DeleteWasteReq, opts ...grpc.CallOption) (*Waste, error) // stat GetCategoriesStat(ctx context.Context, in *GetCategoriesStatReq, opts ...grpc.CallOption) (*CategoriesStat, error) @@ -86,16 +86,6 @@ func (c *smmCoreClient) Ping(ctx context.Context, in *PingReq, opts ...grpc.Call return out, nil } -func (c *smmCoreClient) AddUser(ctx context.Context, in *AddUserReq, opts ...grpc.CallOption) (*User, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(User) - err := c.cc.Invoke(ctx, SmmCore_AddUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *smmCoreClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(User) @@ -226,6 +216,16 @@ func (c *smmCoreClient) AddWaste(ctx context.Context, in *AddWasteReq, opts ...g return out, nil } +func (c *smmCoreClient) AddWasteByText(ctx context.Context, in *AddWasteTextReq, opts ...grpc.CallOption) (*Waste, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Waste) + err := c.cc.Invoke(ctx, SmmCore_AddWasteByText_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *smmCoreClient) DeleteWaste(ctx context.Context, in *DeleteWasteReq, opts ...grpc.CallOption) (*Waste, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Waste) @@ -252,8 +252,7 @@ func (c *smmCoreClient) GetCategoriesStat(ctx context.Context, in *GetCategories type SmmCoreServer interface { // ping Ping(context.Context, *PingReq) (*PingRsp, error) - // users - AddUser(context.Context, *AddUserReq) (*User, error) + // login Login(context.Context, *LoginReq) (*User, error) // budgets AddBudget(context.Context, *AddBudgetReq) (*Budget, error) @@ -271,6 +270,7 @@ type SmmCoreServer interface { DeleteCategories(context.Context, *DeleteCategoriesReq) (*Category, error) // wastes AddWaste(context.Context, *AddWasteReq) (*Waste, error) + AddWasteByText(context.Context, *AddWasteTextReq) (*Waste, error) DeleteWaste(context.Context, *DeleteWasteReq) (*Waste, error) // stat GetCategoriesStat(context.Context, *GetCategoriesStatReq) (*CategoriesStat, error) @@ -287,9 +287,6 @@ type UnimplementedSmmCoreServer struct{} func (UnimplementedSmmCoreServer) Ping(context.Context, *PingReq) (*PingRsp, error) { return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") } -func (UnimplementedSmmCoreServer) AddUser(context.Context, *AddUserReq) (*User, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddUser not implemented") -} func (UnimplementedSmmCoreServer) Login(context.Context, *LoginReq) (*User, error) { return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") } @@ -329,6 +326,9 @@ func (UnimplementedSmmCoreServer) DeleteCategories(context.Context, *DeleteCateg func (UnimplementedSmmCoreServer) AddWaste(context.Context, *AddWasteReq) (*Waste, error) { return nil, status.Errorf(codes.Unimplemented, "method AddWaste not implemented") } +func (UnimplementedSmmCoreServer) AddWasteByText(context.Context, *AddWasteTextReq) (*Waste, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddWasteByText not implemented") +} func (UnimplementedSmmCoreServer) DeleteWaste(context.Context, *DeleteWasteReq) (*Waste, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteWaste not implemented") } @@ -374,24 +374,6 @@ func _SmmCore_Ping_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _SmmCore_AddUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddUserReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SmmCoreServer).AddUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: SmmCore_AddUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SmmCoreServer).AddUser(ctx, req.(*AddUserReq)) - } - return interceptor(ctx, in, info, handler) -} - func _SmmCore_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LoginReq) if err := dec(in); err != nil { @@ -626,6 +608,24 @@ func _SmmCore_AddWaste_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _SmmCore_AddWasteByText_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddWasteTextReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SmmCoreServer).AddWasteByText(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SmmCore_AddWasteByText_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SmmCoreServer).AddWasteByText(ctx, req.(*AddWasteTextReq)) + } + return interceptor(ctx, in, info, handler) +} + func _SmmCore_DeleteWaste_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DeleteWasteReq) if err := dec(in); err != nil { @@ -673,10 +673,6 @@ var SmmCore_ServiceDesc = grpc.ServiceDesc{ MethodName: "Ping", Handler: _SmmCore_Ping_Handler, }, - { - MethodName: "AddUser", - Handler: _SmmCore_AddUser_Handler, - }, { MethodName: "Login", Handler: _SmmCore_Login_Handler, @@ -729,6 +725,10 @@ var SmmCore_ServiceDesc = grpc.ServiceDesc{ MethodName: "AddWaste", Handler: _SmmCore_AddWaste_Handler, }, + { + MethodName: "AddWasteByText", + Handler: _SmmCore_AddWasteByText_Handler, + }, { MethodName: "DeleteWaste", Handler: _SmmCore_DeleteWaste_Handler, diff --git a/resources/smm_core.swagger.json b/resources/smm_core.swagger.json index ef70744..b4c50f8 100644 --- a/resources/smm_core.swagger.json +++ b/resources/smm_core.swagger.json @@ -391,6 +391,7 @@ }, "/login": { "post": { + "summary": "login", "operationId": "SmmCore_Login", "responses": { "200": { @@ -480,39 +481,6 @@ ] } }, - "/users": { - "post": { - "summary": "users", - "operationId": "SmmCore_AddUser", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/smm_coreUser" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/smm_coreAddUserReq" - } - } - ], - "tags": [ - "SmmCore" - ] - } - }, "/wastes": { "post": { "summary": "wastes", @@ -546,6 +514,38 @@ ] } }, + "/wastes/text": { + "post": { + "operationId": "SmmCore_AddWasteByText", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/smm_coreWaste" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/smm_coreAddWasteTextReq" + } + } + ], + "tags": [ + "SmmCore" + ] + } + }, "/wastes/{id}": { "delete": { "operationId": "SmmCore_DeleteWaste", @@ -667,17 +667,6 @@ } } }, - "smm_coreAddUserReq": { - "type": "object", - "properties": { - "username": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, "smm_coreAddWasteReq": { "type": "object", "properties": { @@ -695,6 +684,26 @@ "categoryId": { "type": "integer", "format": "int32" + }, + "budgetId": { + "type": "integer", + "format": "int32" + } + } + }, + "smm_coreAddWasteTextReq": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "categoryId": { + "type": "integer", + "format": "int32" + }, + "budgetId": { + "type": "integer", + "format": "int32" } } },