add add user to budget route
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-11-24 22:24:44 +07:00
parent 95fe8b530e
commit 130a3236e0
9 changed files with 483 additions and 413 deletions
+23
View File
@@ -0,0 +1,23 @@
package app
import (
"git.3crabs.ru/save_my_money/smm_core/internal/services/budget"
"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),
}
}
+9 -18
View File
@@ -60,13 +60,6 @@ func (s *Server) Login(ctx context.Context, req *proto.LoginReq) (*proto.User, e
return mapUser(user), nil
}
func mapUser(user *user.UserEntity) *proto.User {
return &proto.User{
Id: int32(user.Id),
Username: user.Username,
}
}
func (s *Server) AddBudget(ctx context.Context, req *proto.AddBudgetReq) (*proto.Budget, error) {
budget, err := s.budgetService.AddBudget(
ctx,
@@ -98,13 +91,16 @@ func (s *Server) GetBudgets(ctx context.Context, req *proto.GetBudgetsReq) (*pro
}, nil
}
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),
func (s *Server) AddUserToBudget(ctx context.Context, req *proto.AddUserToBudgetReq) (*proto.OK, error) {
_, err := s.budgetService.AddUserToBudget(
ctx,
int(req.BudgetId),
int(req.UserId),
)
if err != nil {
return nil, err
}
return &proto.OK{}, nil
}
// AddCategory implements proto.SmmCoreServer.
@@ -112,11 +108,6 @@ func (s *Server) AddCategory(context.Context, *proto.AddCategoryReq) (*proto.Cat
panic("unimplemented")
}
// AddUserToBudget implements proto.SmmCoreServer.
func (s *Server) AddUserToBudget(context.Context, *proto.AddUserToBudgetReq) (*proto.Budget, error) {
panic("unimplemented")
}
// AddWaste implements proto.SmmCoreServer.
func (s *Server) AddWaste(context.Context, *proto.AddWasteReq) (*proto.Waste, error) {
panic("unimplemented")