This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"kontor-api-gin/internal/helpers"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Publisher struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
@@ -21,28 +24,28 @@ func (publisher *Publisher) TableName() string {
|
||||
}
|
||||
|
||||
type PublisherDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date"`
|
||||
UpdatedAt time.Time `json:"last_modified_date"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
ParentPublisherID *string `json:"parent_publisher_id"`
|
||||
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"`
|
||||
WebLink string `json:"weblink"`
|
||||
ParentPublisherID *string `json:"parent_publisher_id"`
|
||||
}
|
||||
|
||||
func ConvertPublishersToDtos(publishers []Publisher) []PublisherDTO {
|
||||
dtos := make([]PublisherDTO, len(publishers))
|
||||
for i, comic := range publishers {
|
||||
for i, publisher := range publishers {
|
||||
dtos[i] = PublisherDTO{
|
||||
ID: comic.ID,
|
||||
CreatedAt: comic.CreatedAt,
|
||||
UpdatedAt: comic.UpdatedAt,
|
||||
DeletedAt: comic.DeletedAt,
|
||||
Version: comic.Version,
|
||||
Name: comic.Name,
|
||||
WebLink: comic.WebLink,
|
||||
ParentPublisherID: comic.ParentPublisherID,
|
||||
ID: publisher.ID,
|
||||
CreatedAt: helpers.KontorTime{Time: publisher.CreatedAt},
|
||||
UpdatedAt: helpers.KontorTime{Time: publisher.UpdatedAt},
|
||||
DeletedAt: publisher.DeletedAt,
|
||||
Version: publisher.Version,
|
||||
Name: publisher.Name,
|
||||
WebLink: publisher.WebLink,
|
||||
ParentPublisherID: publisher.ParentPublisherID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
|
||||
Reference in New Issue
Block a user