domain

package
v0.0.0-...-cd399ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Course

type Course struct {
	UUID        uuid.UUID `json:"uuid"`
	Code        string    `json:"code"`
	Name        string    `json:"name"`
	Underline   string    `json:"underline"`
	Image       string    `json:"image,omitempty"`
	ImageCover  string    `db:"image_cover"             json:"image_cover,omitempty"`
	Excerpt     string    `json:"excerpt"`
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `db:"created_at"              json:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"              json:"updated_at"`
}

type CourseRepository

type CourseRepository interface {
	Course(courseUUID uuid.UUID) (Course, error)
	Courses() ([]Course, error)
	CreateCourse(course *Course) error
	UpdateCourse(course *Course) error
	DeleteCourse(course *DeletedCourse) error
}

type DeletedCourse

type DeletedCourse struct {
	UUID      uuid.UUID `db:"uuid"       json:"uuid"`
	DeletedAt time.Time `db:"deleted_at" json:"deleted_at"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfgs ...ServiceConfiguration) (*Service, error)

NewService creates a new domain Service instance.

func (*Service) Course

func (s *Service) Course(_ context.Context, courseUUID uuid.UUID) (Course, error)

func (*Service) Courses

func (s *Service) Courses(_ context.Context) ([]Course, error)

func (*Service) CreateCourse

func (s *Service) CreateCourse(_ context.Context, course *Course) error

func (*Service) DeleteCourse

func (s *Service) DeleteCourse(_ context.Context, course *DeletedCourse) error

func (*Service) UpdateCourse

func (s *Service) UpdateCourse(_ context.Context, course *Course) error

type ServiceConfiguration

type ServiceConfiguration func(svc *Service) error

func WithCourseRepository

func WithCourseRepository(cr CourseRepository) ServiceConfiguration

WithCourseRepository injects the course repository to the domain Service.

func WithLogger

func WithLogger(l log.Logger) ServiceConfiguration

WithLogger injects the logger to the domain Service.

type ServiceInterface

type ServiceInterface interface {
	Course(ctx context.Context, id uuid.UUID) (Course, error)
	Courses(ctx context.Context) ([]Course, error)
	CreateCourse(ctx context.Context, course *Course) error
	UpdateCourse(ctx context.Context, course *Course) error
	DeleteCourse(ctx context.Context, course *DeletedCourse) error
}

ServiceInterface defines the domains Service interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址