add add user method

This commit is contained in:
2026-06-29 02:11:28 +07:00
parent 0f9bf8dfc1
commit 18fad25b27
5 changed files with 113 additions and 9 deletions
+17 -4
View File
@@ -2,15 +2,22 @@ package app
import (
"context"
"evening_detective_server/internal/services/users_service"
proto "evening_detective_server/proto"
)
type server struct {
proto.UnsafeEveningDetectiveServerServer
usersService *users_service.UsersService
}
func NewServer() proto.EveningDetectiveServerServer {
return &server{}
func NewServer(
usersService *users_service.UsersService,
) proto.EveningDetectiveServerServer {
return &server{
usersService: usersService,
}
}
func (s *server) Ping(_ context.Context, _ *proto.PingReq) (*proto.PingRsp, error) {
@@ -21,6 +28,12 @@ func (s *server) Echo(_ context.Context, req *proto.EchoReq) (*proto.EchoRsp, er
return &proto.EchoRsp{Text: req.Text}, nil
}
func (s *server) Signup(context.Context, *proto.SignupReq) (*proto.SignupRsp, error) {
panic("unimplemented")
func (s *server) Signup(ctx context.Context, signupReq *proto.SignupReq) (*proto.SignupRsp, error) {
err := s.usersService.AddUser(ctx, signupReq.Username, signupReq.Email)
if err != nil {
return &proto.SignupRsp{
Error: err.Error(),
}, nil
}
return &proto.SignupRsp{}, nil
}