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 CourseClient

type CourseClient interface {
	CourseExists(ctx context.Context, id uuid.UUID) error
}

type DeletedMatrix

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

type Matrix

type Matrix struct {
	UUID        uuid.UUID `db:"uuid"        json:"uuid"`
	Code        string    `db:"code"        json:"code"`
	Name        string    `db:"name"        json:"name"`
	Description string    `db:"description" json:"description"`
	CourseUUID  uuid.UUID `db:"course_uuid" json:"course_uuid"`
	CreatedAt   time.Time `db:"created_at"  json:"created_at"`
	UpdatedAt   time.Time `db:"updated_at"  json:"updated_at"`
}

type MatrixFilters

type MatrixFilters struct {
	CourseUUID uuid.UUID `json:"course_uuid,omitempty"`
}

type MatrixRepository

type MatrixRepository interface {
	// CREATE.
	CreateMatrix(matrix *Matrix) error
	AddSubject(matrixSubject *MatrixSubject) error
	// READ.
	Matrix(matrixUUID uuid.UUID) (Matrix, error)
	CourseMatrixExists(courseUUID uuid.UUID, matrixUUID uuid.UUID) (bool, error)
	Matrices() ([]Matrix, error)
	CourseMatrices(courseUUID uuid.UUID) ([]Matrix, error)
	// UPDATE.
	UpdateMatrix(matrix *Matrix) error
	// DELETE.
	DeleteMatrix(matrix *DeletedMatrix) error
	RemoveSubject(matrixUUID, subjectUUID uuid.UUID) error
}

type MatrixSubject

type MatrixSubject struct {
	ID         uint      `json:"id"`
	SubjectID  uuid.UUID `db:"subject_id"  json:"subject_id"`
	MatrixID   uuid.UUID `db:"matrix_id"   json:"matrix_id"`
	IsRequired bool      `db:"is_required" json:"is_required"`
}

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) AddSubject

func (s *Service) AddSubject(_ context.Context, matrixSubject *MatrixSubject) error

func (*Service) CourseMatrixExists

func (s *Service) CourseMatrixExists(_ context.Context, courseUUID uuid.UUID, matrixUUID uuid.UUID) (bool, error)

func (*Service) CreateMatrix

func (s *Service) CreateMatrix(ctx context.Context, matrix *Matrix) error

func (*Service) CreateSubject

func (s *Service) CreateSubject(_ context.Context, sub *Subject) error

func (*Service) DeleteMatrix

func (s *Service) DeleteMatrix(_ context.Context, matrix *DeletedMatrix) error

func (*Service) DeleteSubject

func (s *Service) DeleteSubject(_ context.Context, id uuid.UUID) error

func (*Service) Matrices

func (s *Service) Matrices(_ context.Context, filters *MatrixFilters) ([]Matrix, error)

func (*Service) Matrix

func (s *Service) Matrix(_ context.Context, matrixUUID uuid.UUID) (Matrix, error)

func (*Service) RemoveSubject

func (s *Service) RemoveSubject(_ context.Context, matrixUUID, subjectUUID uuid.UUID) error

func (*Service) Subject

func (s *Service) Subject(_ context.Context, id uuid.UUID) (Subject, error)

func (*Service) Subjects

func (s *Service) Subjects(_ context.Context) ([]Subject, error)

func (*Service) UpdateMatrix

func (s *Service) UpdateMatrix(_ context.Context, matrix *Matrix) error

func (*Service) UpdateSubject

func (s *Service) UpdateSubject(_ context.Context, sub *Subject) error

type ServiceConfiguration

type ServiceConfiguration func(svc *Service) error

func WithCourseClient

func WithCourseClient(courses CourseClient) ServiceConfiguration

func WithLogger

func WithLogger(l log.Logger) ServiceConfiguration

WithLogger injects the logger to the domain Service.

func WithMatrixRepository

func WithMatrixRepository(cr MatrixRepository) ServiceConfiguration

WithMatrixRepository injects the course repository to the domain Service.

func WithSubjectRepository

func WithSubjectRepository(sr SubjectRepository) ServiceConfiguration

WithSubjectRepository injects the subscription repository to the domain Service.

type ServiceInterface

type ServiceInterface interface {
	Matrix(ctx context.Context, matrixUUID uuid.UUID) (Matrix, error)
	CourseMatrixExists(ctx context.Context, courseUUID uuid.UUID, matrixUUID uuid.UUID) (bool, error)
	Matrices(ctx context.Context, filters *MatrixFilters) ([]Matrix, error)
	CreateMatrix(ctx context.Context, matrix *Matrix) error
	UpdateMatrix(ctx context.Context, matrix *Matrix) error
	DeleteMatrix(ctx context.Context, matrix *DeletedMatrix) error
	AddSubject(ctx context.Context, matrixSubject *MatrixSubject) error
	RemoveSubject(ctx context.Context, matrixID, SubjectID uuid.UUID) error

	Subject(ctx context.Context, id uuid.UUID) (Subject, error)
	Subjects(ctx context.Context) ([]Subject, error)
	CreateSubject(ctx context.Context, subject *Subject) error
	UpdateSubject(ctx context.Context, subject *Subject) error
	DeleteSubject(ctx context.Context, id uuid.UUID) error
}

type Subject

type Subject struct {
	ID        uint       `json:"id"`
	UUID      uuid.UUID  `json:"uuid"`
	Code      string     `json:"code"`
	Name      string     `json:"name"`
	Objective string     `json:"objective"`
	Credit    float32    `json:"credit"`
	Workload  float32    `json:"workload"`
	CreatedAt time.Time  `db:"created_at"  json:"created_at"`
	UpdatedAt time.Time  `db:"updated_at"  json:"updated_at"`
	DeletedAt *time.Time `db:"deleted_at"  json:"deleted_at"`
}

Subject struct.

type SubjectRepository

type SubjectRepository interface {
	Subject(uuid.UUID) (Subject, error)
	Subjects() ([]Subject, error)
	CreateSubject(*Subject) error
	UpdateSubject(*Subject) error
	DeleteSubject(uuid.UUID) error
}

Jump to

Keyboard shortcuts

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