Complete tasks 4.1-4.2: Page management service and HTTP endpoints

- Implemented PageService with full CRUD operations
- Added GetPages, CreatePage, UpdatePage, DeletePage, ReorderPages methods
- Cascade deletion of widgets when page is deleted
- Prevention of last page deletion
- Created page HTTP endpoints (GET, POST, PUT, DELETE, reorder)
- HTMX-friendly HTML fragment responses
- Comprehensive unit tests for service and handlers
- Updated dashboard to use PageService and create default pages
This commit is contained in:
2026-02-19 00:08:05 -05:00
parent 9f07b0c6f9
commit 299ac03939
16 changed files with 1572 additions and 31 deletions

View File

@@ -0,0 +1,17 @@
package services
import (
"context"
"custom-start-page/internal/models"
)
// PageServiceInterface defines the interface for page operations
type PageServiceInterface interface {
GetPages(ctx context.Context, userID string) ([]*models.Page, error)
CreatePage(ctx context.Context, userID, name string) (*models.Page, error)
CreateDefaultPage(ctx context.Context, userID string) (*models.Page, error)
UpdatePage(ctx context.Context, userID, pageID, name string) (*models.Page, error)
DeletePage(ctx context.Context, userID, pageID string) error
ReorderPages(ctx context.Context, userID string, pageOrder []string) error
}