Files
kurious/internal/kurious/app/command/updatecoursedescription.go
2023-12-18 00:14:07 +03:00

36 lines
816 B
Go

package command
import (
"context"
"log/slog"
"git.loyso.art/frx/kurious/internal/common/decorator"
"git.loyso.art/frx/kurious/internal/kurious/domain"
)
type UpdateCourseDescription struct {
ID string
Description string
}
type UpdateCourseDescriptionHandler decorator.CommandHandler[UpdateCourseDescription]
type updateCourseDescriptionHandler struct {
repo domain.CourseRepository
}
func NewUpdateCourseDescriptionHandler(
repo domain.CourseRepository,
log *slog.Logger,
) UpdateCourseDescriptionHandler {
h := updateCourseDescriptionHandler{
repo: repo,
}
return decorator.ApplyCommandDecorators(h, log)
}
func (h updateCourseDescriptionHandler) Handle(ctx context.Context, cmd UpdateCourseDescription) error {
return h.repo.UpdateCourseDescription(ctx, cmd.ID, cmd.Description)
}