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" "git.3crabs.ru/save_my_money/smm_core/internal/services/waste" 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), 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 } func mapWaste(waste *waste.WasteEntity) *proto.Waste { return &proto.Waste{ Id: int32(waste.Id), Name: waste.Name, Price: int32(waste.Price), Amount: waste.Amount, } }