add create categories route
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-11-25 13:36:14 +07:00
parent 130a3236e0
commit 675c2884b7
12 changed files with 621 additions and 518 deletions
+19
View File
@@ -2,6 +2,7 @@ package app
import (
"git.3crabs.ru/save_my_money/smm_core/internal/services/budget"
"git.3crabs.ru/save_my_money/smm_core/internal/services/category"
"git.3crabs.ru/save_my_money/smm_core/internal/services/user"
proto "git.3crabs.ru/save_my_money/smm_core/proto"
)
@@ -19,5 +20,23 @@ func mapBudget(budget *budget.BudgetEntity) *proto.Budget {
Name: budget.Name,
StartDay: int32(budget.StartDay),
MonthlyLimit: int32(budget.MonthlyLimit),
Categories: mapCategories(budget.Categories),
}
}
func mapCategory(category *category.CategoryEntity) *proto.Category {
return &proto.Category{
Id: int32(category.Id),
Name: category.Name,
Favorite: category.Favorite,
MonthlyLimit: int32(category.MonthlyLimit),
}
}
func mapCategories(categories []*category.CategoryEntity) []*proto.Category {
res := make([]*proto.Category, 0, len(categories))
for _, item := range categories {
res = append(res, mapCategory(item))
}
return res
}