add login
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-11-21 16:02:36 +07:00
parent f2011b953c
commit 866009cf09
3 changed files with 34 additions and 5 deletions
+15 -4
View File
@@ -28,7 +28,6 @@ func (s *Server) Ping(context.Context, *proto.PingReq) (*proto.PingRsp, error) {
return &proto.PingRsp{}, nil
}
// AddUser implements proto.SmmCoreServer.
func (s *Server) AddUser(ctx context.Context, req *proto.AddUserReq) (*proto.User, error) {
user, err := s.userService.AddUser(
ctx,
@@ -46,9 +45,21 @@ func (s *Server) AddUser(ctx context.Context, req *proto.AddUserReq) (*proto.Use
}, nil
}
// Login implements proto.SmmCoreServer.
func (s *Server) Login(context.Context, *proto.LoginReq) (*proto.User, error) {
panic("unimplemented")
func (s *Server) Login(ctx context.Context, req *proto.LoginReq) (*proto.User, error) {
user, err := s.userService.Login(
ctx,
&user.UserEntity{
Username: req.Username,
Password: req.Password,
},
)
if err != nil {
return nil, err
}
return &proto.User{
Id: int32(user.Id),
Username: req.Username,
}, nil
}
// AddBudget implements proto.SmmCoreServer.