smm_core/internal/app/server.go

123 lines
3.6 KiB
Go
Raw Normal View History

2024-11-09 11:18:51 +00:00
package app
import (
"context"
2024-11-19 15:45:31 +00:00
"git.3crabs.ru/save_my_money/smm_core/internal/services/category"
2024-11-20 08:32:43 +00:00
"git.3crabs.ru/save_my_money/smm_core/internal/services/user"
2024-11-09 11:18:51 +00:00
proto "git.3crabs.ru/save_my_money/smm_core/proto"
)
type Server struct {
proto.UnsafeSmmCoreServer
2024-11-19 15:45:31 +00:00
categoryService *category.CategoryService
2024-11-20 08:32:43 +00:00
userService *user.UserService
2024-11-09 11:18:51 +00:00
}
2024-11-19 15:45:31 +00:00
func NewServer(
categoryService *category.CategoryService,
2024-11-20 08:32:43 +00:00
userService *user.UserService,
2024-11-19 15:45:31 +00:00
) proto.SmmCoreServer {
return &Server{
categoryService: categoryService,
2024-11-20 08:32:43 +00:00
userService: userService,
2024-11-19 15:45:31 +00:00
}
2024-11-09 11:18:51 +00:00
}
2024-11-21 08:11:21 +00:00
func (s *Server) Ping(context.Context, *proto.PingReq) (*proto.PingRsp, error) {
2024-11-09 11:18:51 +00:00
return &proto.PingRsp{}, nil
}
2024-11-19 08:16:01 +00:00
2024-11-21 08:11:21 +00:00
// AddUser implements proto.SmmCoreServer.
func (s *Server) AddUser(ctx context.Context, req *proto.AddUserReq) (*proto.User, error) {
user, err := s.userService.AddUser(
2024-11-20 08:32:43 +00:00
ctx,
&user.UserEntity{
Username: req.Username,
2024-11-20 17:47:44 +00:00
Password: req.Password,
2024-11-20 08:32:43 +00:00
},
)
if err != nil {
return nil, err
}
return &proto.User{
2024-11-21 08:11:21 +00:00
Id: int32(user.Id),
Username: req.Username,
2024-11-20 08:32:43 +00:00
}, nil
}
2024-11-21 08:11:21 +00:00
// Login implements proto.SmmCoreServer.
func (s *Server) Login(context.Context, *proto.LoginReq) (*proto.User, error) {
panic("unimplemented")
}
// AddBudget implements proto.SmmCoreServer.
func (s *Server) AddBudget(context.Context, *proto.AddBudgetReq) (*proto.Budget, error) {
panic("unimplemented")
}
// AddCategory implements proto.SmmCoreServer.
func (s *Server) AddCategory(context.Context, *proto.AddCategoryReq) (*proto.Category, error) {
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")
}
// DeleteBudget implements proto.SmmCoreServer.
func (s *Server) DeleteBudget(context.Context, *proto.DeleteBudgetReq) (*proto.Budget, error) {
panic("unimplemented")
}
// DeleteCategories implements proto.SmmCoreServer.
func (s *Server) DeleteCategories(context.Context, *proto.DeleteCategoriesReq) (*proto.Category, error) {
panic("unimplemented")
}
// DeleteWaste implements proto.SmmCoreServer.
func (s *Server) DeleteWaste(context.Context, *proto.DeleteWasteReq) (*proto.Waste, error) {
panic("unimplemented")
}
// GetBudgetUsers implements proto.SmmCoreServer.
func (s *Server) GetBudgetUsers(context.Context, *proto.GetBudgetUsersReq) (*proto.Users, error) {
panic("unimplemented")
}
// GetBudgets implements proto.SmmCoreServer.
func (s *Server) GetBudgets(context.Context, *proto.GetBudgetsReq) (*proto.Budgets, error) {
panic("unimplemented")
2024-11-19 08:16:01 +00:00
}
// GetCategories implements proto.SmmCoreServer.
2024-11-21 08:11:21 +00:00
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")
}
// RemoveUserFromBudget implements proto.SmmCoreServer.
func (s *Server) RemoveUserFromBudget(context.Context, *proto.RemoveUserFromBudgetReq) (*proto.Budget, error) {
panic("unimplemented")
}
// UpdateBudget implements proto.SmmCoreServer.
func (s *Server) UpdateBudget(context.Context, *proto.UpdateBudgetReq) (*proto.Budget, error) {
2024-11-19 08:16:01 +00:00
panic("unimplemented")
}
// UpdateCategory implements proto.SmmCoreServer.
func (s *Server) UpdateCategory(context.Context, *proto.UpdateCategoryReq) (*proto.Category, error) {
panic("unimplemented")
}