Use usual book widget for collection form view

This commit is contained in:
2026-04-07 16:16:11 +02:00
parent a537c12a3b
commit f2899b968c
6 changed files with 63 additions and 83 deletions

View File

@@ -10,19 +10,6 @@ import (
"gorm.io/gorm"
)
func CollectionQueryToCollectionDto(collectionsQueryResult []query.CollectionsQueryResult) dto.CollectionGet {
var collection dto.CollectionGet
for _, collectionsDb := range collectionsQueryResult {
collection.Name = collectionsDb.Name
book := collectionDbToBookItem(&collectionsDb)
if book != nil {
collection.Books = append(collection.Books, *book)
}
collection.UserID = collectionsDb.UserID
}
return collection
}
func CollectionQueryToCollectionItemDto(collectionsQueryResult []query.CollectionsQueryResult) []dto.CollectionItemGet {
var collections []dto.CollectionItemGet
for _, collectionDb := range collectionsQueryResult {
@@ -35,7 +22,7 @@ func CollectionQueryToCollectionItemDto(collectionsQueryResult []query.Collectio
//current collection is the last element
i = len(collections) - 1
}
book := collectionDbToBookItem(&collectionDb)
book := collectionDbToCollectionBookItem(&collectionDb)
if book != nil {
collections[i].Books = append(collections[i].Books, *book)
}
@@ -43,7 +30,7 @@ func CollectionQueryToCollectionItemDto(collectionsQueryResult []query.Collectio
return collections
}
func collectionDbToBookItem(collectionDb *query.CollectionsQueryResult) *dto.CollectionBookItemGet {
func collectionDbToCollectionBookItem(collectionDb *query.CollectionsQueryResult) *dto.CollectionBookItemGet {
if collectionDb.BookId > 0 {
bookItem := dto.CollectionBookItemGet{
ID: collectionDb.BookId,