user_command_service.go 606 B

12345678910111213141516171819202122232425
  1. package service
  2. import (
  3. "github.com/CesarSSH/cqrs-api-go/internal/command"
  4. "github.com/CesarSSH/cqrs-api-go/internal/models"
  5. "github.com/CesarSSH/cqrs-api-go/internal/repository"
  6. )
  7. type UserCommandService struct {
  8. userRepository repository.UserRepository
  9. }
  10. func NewUserCommandService(repo repository.UserRepository) *UserCommandService {
  11. return &UserCommandService{
  12. userRepository: repo,
  13. }
  14. }
  15. func (s *UserCommandService) CreateUser(cmd *command.CreateUserCommand) error {
  16. user := &models.User{
  17. FirstName: cmd.FirstName,
  18. LastName: cmd.LastName,
  19. }
  20. return s.userRepository.Create(user)
  21. }