This commit is contained in:
@@ -3,19 +3,47 @@ package models
|
||||
import "time"
|
||||
|
||||
type ComicWork struct {
|
||||
ID string `gorm:"type:string;primary_key;"`
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
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"`
|
||||
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID"`
|
||||
Artist *Artist `gorm:"foreignKey:ArtistID" json:"artist"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
WorkTypeID *string `gorm:"column:work_type_id" json:"work_type_id"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID"`
|
||||
WorkType *WorkType `gorm:"foreignKey:WorkTypeID" json:"work_type"`
|
||||
}
|
||||
|
||||
func (comic_work *ComicWork) TableName() string {
|
||||
return "comic_work"
|
||||
}
|
||||
|
||||
type ComicworkDTO 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"`
|
||||
ArtistID *string `json:"artist_id"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertComicworksToDtos(comicworks []ComicWork) []ComicworkDTO {
|
||||
dtos := make([]ComicworkDTO, len(comicworks))
|
||||
for i, comicwork := range comicworks {
|
||||
dtos[i] = ComicworkDTO{
|
||||
ID: comicwork.ID,
|
||||
CreatedAt: comicwork.CreatedAt,
|
||||
UpdatedAt: comicwork.UpdatedAt,
|
||||
DeletedAt: comicwork.DeletedAt,
|
||||
Version: comicwork.Version,
|
||||
ArtistID: comicwork.ArtistID,
|
||||
ComicID: comicwork.ComicID,
|
||||
WorkTypeID: comicwork.WorkTypeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user