- Add comprehensive nested route structure with proper authentication layers - Implement UpdateContent and ReorderCollectionItems handlers with repository pattern - Add automatic mock JWT token fetching for seamless development workflow - Restore content editing and collection reordering functionality broken after database refactoring - Provide production-ready authentication architecture with development convenience - Enable full CMS operations in browser with proper CRUD and bulk transaction support
68 lines
2.4 KiB
Go
68 lines
2.4 KiB
Go
package api
|
|
|
|
import "github.com/insertr/insertr/internal/db"
|
|
|
|
// Use db package types directly for API responses - no duplication needed
|
|
// Request models are kept below as they're different (input DTOs)
|
|
|
|
// Element context for backend ID generation
|
|
type ElementContext struct {
|
|
Tag string `json:"tag"`
|
|
Classes []string `json:"classes"`
|
|
OriginalContent string `json:"original_content"`
|
|
ParentContext string `json:"parent_context"`
|
|
Purpose string `json:"purpose"`
|
|
}
|
|
|
|
// Request models
|
|
type CreateContentRequest struct {
|
|
HTMLMarkup string `json:"html_markup"` // HTML markup of the element
|
|
FilePath string `json:"file_path"` // File path for consistent ID generation
|
|
HTMLContent string `json:"html_content"` // HTML content value
|
|
OriginalTemplate string `json:"original_template"` // Original template markup
|
|
SiteID string `json:"site_id,omitempty"` // Site identifier
|
|
CreatedBy string `json:"created_by,omitempty"` // User who created the content
|
|
}
|
|
|
|
type RollbackContentRequest struct {
|
|
VersionID int64 `json:"version_id"`
|
|
RolledBackBy string `json:"rolled_back_by,omitempty"`
|
|
}
|
|
|
|
// Collection response types also use db package directly
|
|
|
|
// Collection request models
|
|
type CreateCollectionRequest struct {
|
|
ContainerHTML string `json:"container_html"`
|
|
SiteID string `json:"site_id,omitempty"`
|
|
CreatedBy string `json:"created_by,omitempty"`
|
|
}
|
|
|
|
type CreateCollectionTemplateRequest struct {
|
|
Name string `json:"name"`
|
|
HTMLTemplate string `json:"html_template"`
|
|
IsDefault bool `json:"is_default"`
|
|
CollectionID string `json:"collection_id,omitempty"`
|
|
SiteID string `json:"site_id,omitempty"`
|
|
}
|
|
|
|
type CreateCollectionItemRequest struct {
|
|
TemplateID int `json:"template_id"`
|
|
HTMLContent string `json:"html_content"`
|
|
Position int `json:"position"`
|
|
CollectionID string `json:"collection_id,omitempty"`
|
|
SiteID string `json:"site_id,omitempty"`
|
|
CreatedBy string `json:"created_by,omitempty"`
|
|
}
|
|
|
|
type UpdateCollectionItemRequest struct {
|
|
HTMLContent string `json:"html_content"`
|
|
Position int `json:"position"`
|
|
UpdatedBy string `json:"updated_by,omitempty"`
|
|
}
|
|
|
|
type ReorderCollectionRequest struct {
|
|
Items []db.CollectionItemPosition `json:"items"`
|
|
UpdatedBy string `json:"updated_by,omitempty"`
|
|
}
|