Implement atomic collection item creation API with unified content engine approach
Updates collection creation to use database-first atomic operations for reliable collection item management. Replaces manual database calls with unified content engine methods that handle content extraction, storage, and structural template generation consistently. Key changes: - Replace manual database operations in CreateCollectionItem handler with DatabaseClient.CreateCollectionItemAtomic() - Implement unified content engine approach for API-based collection item creation - Add atomic collection item creation methods across all content clients - Enhance reconstruction to use stored structural templates with content ID hydration - Add comprehensive collection management API methods in JavaScript client - Implement collection manager UI with create, delete, and reorder functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -516,3 +516,36 @@ func (c *DatabaseClient) CreateCollectionItem(siteID, collectionID, itemID strin
|
||||
return nil, fmt.Errorf("unsupported database type: %s", c.database.GetDBType())
|
||||
}
|
||||
}
|
||||
|
||||
// CreateCollectionItemAtomic creates a collection item with all its content entries atomically
|
||||
func (c *DatabaseClient) CreateCollectionItemAtomic(
|
||||
siteID, collectionID string,
|
||||
templateID int,
|
||||
lastEditedBy string,
|
||||
) (*CollectionItemWithTemplate, error) {
|
||||
// Get template HTML for processing
|
||||
templates, err := c.GetCollectionTemplates(siteID, collectionID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get templates: %w", err)
|
||||
}
|
||||
|
||||
var templateHTML string
|
||||
for _, template := range templates {
|
||||
if template.TemplateID == templateID {
|
||||
templateHTML = template.HTMLTemplate
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if templateHTML == "" {
|
||||
return nil, fmt.Errorf("template %d not found", templateID)
|
||||
}
|
||||
|
||||
// Use unified engine approach (no more TemplateProcessor)
|
||||
engine := NewContentEngine(c)
|
||||
|
||||
// Create collection item using unified engine method
|
||||
return engine.CreateCollectionItemFromTemplate(
|
||||
siteID, collectionID, templateID, templateHTML, lastEditedBy,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user