package service import ( "context" "fmt" "gitea.dwysokinski.me/twhelp/core/internal/domain" ) type VersionRepository interface { List(ctx context.Context) ([]domain.Version, error) ListCount(ctx context.Context) ([]domain.Version, int64, error) GetByCode(ctx context.Context, code string) (domain.Version, error) } type Version struct { repo VersionRepository } func NewVersion(repo VersionRepository) *Version { return &Version{repo: repo} } func (v *Version) List(ctx context.Context) ([]domain.Version, error) { versions, err := v.repo.List(ctx) if err != nil { return nil, fmt.Errorf("VersionRepository.List: %w", err) } return versions, nil } func (v *Version) ListCount(ctx context.Context) ([]domain.Version, int64, error) { versions, count, err := v.repo.ListCount(ctx) if err != nil { return nil, 0, fmt.Errorf("VersionRepository.ListCount: %w", err) } return versions, count, nil } func (v *Version) GetByCode(ctx context.Context, code string) (domain.Version, error) { version, err := v.repo.GetByCode(ctx, code) if err != nil { return domain.Version{}, fmt.Errorf("VersionRepository.GetByCode: %w", err) } return version, nil }