package adminuser

import "errors"

var (
	ErrDependencyUnavailable = errors.New("dependency unavailable")
	ErrInvalidUser           = errors.New("invalid user")
)

type Service struct {
	repo *Repository
}

func NewService(repo *Repository) *Service {
	return &Service{repo: repo}
}

func (s *Service) List(page, pageSize int) (*PaginatedResult, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	return s.repo.List(page, pageSize)
}

func (s *Service) Freeze(adminID uint64, userID uint64, req FreezeRequest, meta AuditMeta) (*UserDTO, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	if userID == 0 {
		return nil, ErrInvalidUser
	}
	return s.repo.Freeze(adminID, userID, req, meta)
}

func (s *Service) Unfreeze(adminID uint64, userID uint64, meta AuditMeta) (*UserDTO, error) {
	if s.repo == nil {
		return nil, ErrDependencyUnavailable
	}
	if userID == 0 {
		return nil, ErrInvalidUser
	}
	return s.repo.Unfreeze(adminID, userID, meta)
}
