This commit is contained in:
+31
-8
@@ -103,9 +103,37 @@ func (s *Server) AddUserToBudget(ctx context.Context, req *proto.AddUserToBudget
|
||||
return &proto.OK{}, nil
|
||||
}
|
||||
|
||||
// AddCategory implements proto.SmmCoreServer.
|
||||
func (s *Server) AddCategory(context.Context, *proto.AddCategoryReq) (*proto.Category, error) {
|
||||
panic("unimplemented")
|
||||
func (s *Server) AddCategory(ctx context.Context, req *proto.AddCategoryReq) (*proto.Category, error) {
|
||||
category, err := s.categoryService.AddCategory(
|
||||
ctx,
|
||||
&category.CategoryEntity{
|
||||
Name: req.Name,
|
||||
BudgetId: int(req.BudgetId),
|
||||
Favorite: req.Favorite,
|
||||
MonthlyLimit: int(req.MonthlyLimit),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapCategory(category), nil
|
||||
}
|
||||
|
||||
func (s *Server) GetBudgetCategories(ctx context.Context, req *proto.GetBudgetCategoriesReq) (*proto.Categories, error) {
|
||||
categories, err := s.budgetService.GetBudgetCategories(
|
||||
ctx,
|
||||
int(req.BudgetId),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := make([]*proto.Category, 0, len(categories))
|
||||
for _, category := range categories {
|
||||
res = append(res, mapCategory(category))
|
||||
}
|
||||
return &proto.Categories{
|
||||
Categories: res,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AddWaste implements proto.SmmCoreServer.
|
||||
@@ -133,11 +161,6 @@ func (s *Server) GetBudgetUsers(context.Context, *proto.GetBudgetUsersReq) (*pro
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// GetCategories implements proto.SmmCoreServer.
|
||||
func (s *Server) GetCategories(context.Context, *proto.GetCategoriesReq) (*proto.Categories, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
// GetCategoriesStat implements proto.SmmCoreServer.
|
||||
func (s *Server) GetCategoriesStat(context.Context, *proto.GetCategoriesStatReq) (*proto.CategoriesStat, error) {
|
||||
panic("unimplemented")
|
||||
|
||||
Reference in New Issue
Block a user