69 lines
1.8 KiB
Go
69 lines
1.8 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]
|
|
CourseThematic string
|
|
LearningType 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)
|
|
|
|
CreateBatch(context.Context, ...CreateCourseParams) 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
|
|
}
|