add tysc handlers to kontor-gin
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Publisher 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"`
|
||||
WebLink string `gorm:"column:weblink" json:"weblink"`
|
||||
ParentPublisherID *string `gorm:"column:parent_publisher_id" json:"parent_publisher_id"`
|
||||
ParentPublisher *Publisher `gorm:"foreignKey:ParentPublisherID"`
|
||||
Imprints []Publisher `gorm:"foreignKey:ParentPublisherID"`
|
||||
Comics []Comic `gorm:"foreignKey:PublisherID"`
|
||||
}
|
||||
|
||||
func (publisher *Publisher) TableName() string {
|
||||
return "publisher"
|
||||
}
|
||||
|
||||
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"`
|
||||
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 {
|
||||
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,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type CreatePublisherDTO struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
WebLink string `json:"weblink" binding:"required"`
|
||||
}
|
||||
Reference in New Issue
Block a user