Files
david 358f844073 Remove unnecessary comments from codebase
Clean up obvious and redundant comments that don't add value:
- Remove step-by-step comments in command handlers
- Remove obvious test setup comments
- Keep only meaningful comments that explain why, not what
2025-11-27 00:48:50 +01:00

39 lines
730 B
Go

package commands
import (
"context"
"apocapoc-api/internal/domain/repositories"
"apocapoc-api/internal/shared/errors"
)
type ArchiveHabitCommand struct {
HabitID string
UserID string
}
type ArchiveHabitHandler struct {
habitRepo repositories.HabitRepository
}
func NewArchiveHabitHandler(habitRepo repositories.HabitRepository) *ArchiveHabitHandler {
return &ArchiveHabitHandler{
habitRepo: habitRepo,
}
}
func (h *ArchiveHabitHandler) Handle(ctx context.Context, cmd ArchiveHabitCommand) error {
habit, err := h.habitRepo.FindByID(ctx, cmd.HabitID)
if err != nil {
return err
}
if habit.UserID != cmd.UserID {
return errors.ErrUnauthorized
}
habit.Archive()
return h.habitRepo.Update(ctx, habit)
}