2024-08-20 11:18:23 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-08-25 16:52:00 +00:00
|
|
|
"git.sch9.ru/new_gate/ms-tester/pkg/models"
|
2024-08-20 11:18:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserStorage interface {
|
|
|
|
CreateUser(ctx context.Context, user *models.User) error
|
|
|
|
ReadUserById(ctx context.Context, userId int32) (*models.User, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserService struct {
|
|
|
|
userStorage UserStorage
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserService(userStorage UserStorage) *UserService {
|
|
|
|
return &UserService{
|
|
|
|
userStorage: userStorage,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *UserService) CreateUser(ctx context.Context, user *models.User) error {
|
|
|
|
return s.userStorage.CreateUser(ctx, user)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *UserService) ReadUserById(ctx context.Context, userId int32) (*models.User, error) {
|
|
|
|
return s.userStorage.ReadUserById(ctx, userId)
|
|
|
|
}
|