add missing models
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s

This commit is contained in:
2026-10-04 01:56:25 +02:00
parent ea648082be
commit d9007ba0e4
28 changed files with 927 additions and 105 deletions
@@ -0,0 +1,44 @@
package models
import (
"kontor-api-gin/internal/helpers"
"time"
)
type BookshelfPublisher struct {
ID string `gorm:"type:string;primary_key;"`
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
Version int `gorm:"default:0" json:"version"`
Name string `gorm:"uniqueIndex" json:"name"`
Books []Book `gorm:"foreignKey:PublisherID"`
}
func (publisher *BookshelfPublisher) TableName() string {
return "bookshelf_publisher"
}
type BookshelfPublisherDTO struct {
ID string `json:"id" binding:"required"`
CreatedAt helpers.KontorTime `json:"created_date"`
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
DeletedAt *time.Time `json:"deleted_date,omitempty"`
Version int `json:"version"`
Name string `json:"name"`
}
func ConvertBookshelfPublishersToDtos(publishers []BookshelfPublisher) []BookshelfPublisherDTO {
dtos := make([]BookshelfPublisherDTO, len(publishers))
for i, publisher := range publishers {
dtos[i] = BookshelfPublisherDTO{
ID: publisher.ID,
CreatedAt: helpers.KontorTime{Time: publisher.CreatedAt},
UpdatedAt: helpers.KontorTime{Time: publisher.UpdatedAt},
DeletedAt: publisher.DeletedAt,
Version: publisher.Version,
Name: publisher.Name,
}
}
return dtos
}