This commit is contained in:
@@ -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
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user