This commit is contained in:
@@ -16,6 +16,32 @@ func (artist *Artist) TableName() string {
|
||||
return "artist"
|
||||
}
|
||||
|
||||
type ArtistDTO struct {
|
||||
ID string `json:"id"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func ConvertArtistsToDtos(artists []Artist) []ArtistDTO {
|
||||
dtos := make([]ArtistDTO, len(artists))
|
||||
for i, artist := range artists {
|
||||
dtos[i] = ArtistDTO{
|
||||
ID: artist.ID,
|
||||
CreatedAt: artist.CreatedAt,
|
||||
UpdatedAt: artist.UpdatedAt,
|
||||
DeletedAt: artist.DeletedAt,
|
||||
Version: artist.Version,
|
||||
Name: artist.Name,
|
||||
WebLink: artist.WebLink,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type CreateArtistDTO struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
WebLink string `json:"weblink" binding:"required"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package models
|
||||
import "time"
|
||||
|
||||
type Issue 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"`
|
||||
@@ -14,13 +14,45 @@ type Issue struct {
|
||||
Title string `gorm:"column:title" json:"title"`
|
||||
PublishedOn time.Time `gorm:"column:published_on" json:"published_on"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
StoryArcID *string `gorm:"column:story_arc_id" json:"story_arc_id"`
|
||||
StoryArc *StoryArc `gorm:"foreignKey:StoryArcID"`
|
||||
StoryArc *StoryArc `gorm:"foreignKey:StoryArcID" json:"story_arc"`
|
||||
VolumeID *string `gorm:"column:volume_id" json:"volume_id"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID" json:"volume"`
|
||||
}
|
||||
|
||||
func (issue *Issue) TableName() string {
|
||||
return "issue"
|
||||
}
|
||||
|
||||
type IssueDTO 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"`
|
||||
Title string `json:"title"`
|
||||
PublishedOn time.Time `json:"published_on"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
StoryArcID *string `json:"story_arc_id"`
|
||||
VolumeID *string `json:"volume_id"`
|
||||
}
|
||||
|
||||
func ConvertIssuesToDtos(issues []Issue) []IssueDTO {
|
||||
dtos := make([]IssueDTO, len(issues))
|
||||
for i, issue := range issues {
|
||||
dtos[i] = IssueDTO{
|
||||
ID: issue.ID,
|
||||
CreatedAt: issue.CreatedAt,
|
||||
UpdatedAt: issue.UpdatedAt,
|
||||
DeletedAt: issue.DeletedAt,
|
||||
Version: issue.Version,
|
||||
Title: issue.Title,
|
||||
PublishedOn: issue.PublishedOn,
|
||||
ComicID: issue.ComicID,
|
||||
StoryArcID: issue.StoryArcID,
|
||||
VolumeID: issue.VolumeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,19 +3,47 @@ package models
|
||||
import "time"
|
||||
|
||||
type IssueWork 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"`
|
||||
IssueID *string `gorm:"column:issue_id" json:"issue_id"`
|
||||
Issue *Issue `gorm:"foreignKey:IssueID"`
|
||||
Issue *Issue `gorm:"foreignKey:IssueID" json:"issue"`
|
||||
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 (issue_work *IssueWork) TableName() string {
|
||||
return "issue_work"
|
||||
}
|
||||
|
||||
type IssueworkDTO 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"`
|
||||
IssueID *string `json:"issue_id"`
|
||||
WorkTypeID *string `json:"work_type_id"`
|
||||
}
|
||||
|
||||
func ConvertIssueworksToDtos(issueworks []IssueWork) []IssueworkDTO {
|
||||
dtos := make([]IssueworkDTO, len(issueworks))
|
||||
for i, issuework := range issueworks {
|
||||
dtos[i] = IssueworkDTO{
|
||||
ID: issuework.ID,
|
||||
CreatedAt: issuework.CreatedAt,
|
||||
UpdatedAt: issuework.UpdatedAt,
|
||||
DeletedAt: issuework.DeletedAt,
|
||||
Version: issuework.Version,
|
||||
ArtistID: issuework.ArtistID,
|
||||
IssueID: issuework.IssueID,
|
||||
WorkTypeID: issuework.WorkTypeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ 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"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Name string `json:"name"`
|
||||
WebLink string `json:"weblink"`
|
||||
|
||||
@@ -3,18 +3,46 @@ package models
|
||||
import "time"
|
||||
|
||||
type StoryArc 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"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
VolumeID *string `gorm:"column:volume_id" json:"volume_id"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID"`
|
||||
Volume *Volume `gorm:"foreignKey:VolumeID" json:"volume"`
|
||||
}
|
||||
|
||||
func (story_arc *StoryArc) TableName() string {
|
||||
return "story_arc"
|
||||
}
|
||||
|
||||
type StoryArcDTO 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"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
VolumeID *string `json:"volume_id"`
|
||||
}
|
||||
|
||||
func ConvertStoryArcsToDtos(storyarcs []StoryArc) []StoryArcDTO {
|
||||
dtos := make([]StoryArcDTO, len(storyarcs))
|
||||
for i, storyarc := range storyarcs {
|
||||
dtos[i] = StoryArcDTO{
|
||||
ID: storyarc.ID,
|
||||
CreatedAt: storyarc.CreatedAt,
|
||||
UpdatedAt: storyarc.UpdatedAt,
|
||||
DeletedAt: storyarc.DeletedAt,
|
||||
Version: storyarc.Version,
|
||||
Name: storyarc.Name,
|
||||
ComicID: storyarc.ComicID,
|
||||
VolumeID: storyarc.VolumeID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,16 +3,42 @@ package models
|
||||
import "time"
|
||||
|
||||
type Volume 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"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
ComicID *string `gorm:"column:comic_id" json:"comic_id"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID"`
|
||||
Comic *Comic `gorm:"foreignKey:ComicID" json:"comic"`
|
||||
}
|
||||
|
||||
func (volume *Volume) TableName() string {
|
||||
return "volume"
|
||||
}
|
||||
|
||||
type VolumeDTO 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"`
|
||||
ComicID *string `json:"comic_id"`
|
||||
}
|
||||
|
||||
func ConvertVolumesToDtos(volumes []Volume) []VolumeDTO {
|
||||
dtos := make([]VolumeDTO, len(volumes))
|
||||
for i, volume := range volumes {
|
||||
dtos[i] = VolumeDTO{
|
||||
ID: volume.ID,
|
||||
CreatedAt: volume.CreatedAt,
|
||||
UpdatedAt: volume.UpdatedAt,
|
||||
DeletedAt: volume.DeletedAt,
|
||||
Version: volume.Version,
|
||||
Name: volume.Name,
|
||||
ComicID: volume.ComicID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
@@ -3,14 +3,38 @@ package models
|
||||
import "time"
|
||||
|
||||
type WorkType 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"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
Name string `gorm:"uniqueIndex" json:"name"`
|
||||
}
|
||||
|
||||
func (worktype *WorkType) TableName() string {
|
||||
return "worktype"
|
||||
}
|
||||
|
||||
type WorkTypeDTO struct {
|
||||
ID string `json:"id"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func ConvertWorkTypesToDtos(worktypes []WorkType) []WorkTypeDTO {
|
||||
dtos := make([]WorkTypeDTO, len(worktypes))
|
||||
for i, worktype := range worktypes {
|
||||
dtos[i] = WorkTypeDTO{
|
||||
ID: worktype.ID,
|
||||
CreatedAt: worktype.CreatedAt,
|
||||
UpdatedAt: worktype.UpdatedAt,
|
||||
DeletedAt: worktype.DeletedAt,
|
||||
Version: worktype.Version,
|
||||
Name: worktype.Name,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user