2024-11-24 15:24:44 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.3crabs.ru/save_my_money/smm_core/internal/services/budget"
|
2024-11-25 06:36:14 +00:00
|
|
|
"git.3crabs.ru/save_my_money/smm_core/internal/services/category"
|
2024-11-24 15:24:44 +00:00
|
|
|
"git.3crabs.ru/save_my_money/smm_core/internal/services/user"
|
|
|
|
proto "git.3crabs.ru/save_my_money/smm_core/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
func mapUser(user *user.UserEntity) *proto.User {
|
|
|
|
return &proto.User{
|
|
|
|
Id: int32(user.Id),
|
|
|
|
Username: user.Username,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mapBudget(budget *budget.BudgetEntity) *proto.Budget {
|
|
|
|
return &proto.Budget{
|
|
|
|
Id: int32(budget.Id),
|
|
|
|
Name: budget.Name,
|
|
|
|
StartDay: int32(budget.StartDay),
|
|
|
|
MonthlyLimit: int32(budget.MonthlyLimit),
|
2024-11-25 06:36:14 +00:00
|
|
|
Categories: mapCategories(budget.Categories),
|
2024-11-24 15:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
2024-11-25 06:36:14 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|