Files
kurious/internal/kurious/domain/repository.go
2023-12-04 01:24:24 +03:00

66 lines
1.7 KiB
Go

package domain
import (
"context"
"time"
"git.loyso.art/frx/kurious/internal/common/nullable"
)
type ListCoursesParams struct {
OrganizationID string
CategoryID string
Keyword string
}
type CreateCourseParams struct {
ID string
ExternalID nullable.Value[string]
Name string
SourceType SourceType
SourceName nullable.Value[string]
OrganizationID string
OriginLink string
ImageLink string
Description string
FullPrice float64
Discount float64
Duration time.Duration
StartsAt time.Time
}
//go:generate mockery --name CourseRepository
type CourseRepository interface {
// List courses by specifid parameters.
List(ctx context.Context, params ListCoursesParams) ([]Course, error)
// Get course by id.
// Should return ErrNotFound in case course not found.
Get(ctx context.Context, id string) (Course, error)
// GetByExternalID finds course by external id.
// Should return ErrNotFound in case course not found.
GetByExternalID(ctx context.Context, id string) (Course, error)
// Create course, but might fail in case of
// unique constraint violation.
Create(context.Context, CreateCourseParams) (Course, error)
// Delete course by id.
Delete(ctx context.Context, id string) error
}
type CreateOrganizationParams struct {
ID string
ExternalID nullable.Value[string]
Alias string
Name string
Site string
LogoLink string
}
//go:generate mockery --name OrganizationRepository
type OrganizationRepository interface {
Get(ctx context.Context) (Organization, error)
Create(context.Context, CreateOrganizationParams) (Organization, error)
Delete(ctx context.Context, id string) error
}