add methods in Repository and Model for importing data
This commit is contained in:
@@ -41,6 +41,22 @@ type ComicDTO struct {
|
||||
WebLink string `json:"weblink"`
|
||||
}
|
||||
|
||||
func (dto ComicDTO) ConvertDTOToModel() Comic {
|
||||
model := Comic{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
Title: dto.Title,
|
||||
PublisherID: dto.PublisherID,
|
||||
CurrentOrder: dto.CurrentOrder,
|
||||
Completed: dto.Completed,
|
||||
WebLink: dto.WebLink,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertComicsToDtos(comics []Comic) []ComicDTO {
|
||||
dtos := make([]ComicDTO, len(comics))
|
||||
for i, comic := range comics {
|
||||
@@ -60,6 +76,8 @@ func ConvertComicsToDtos(comics []Comic) []ComicDTO {
|
||||
return dtos
|
||||
}
|
||||
|
||||
type ComicDTOList []ComicDTO
|
||||
|
||||
type CreateComicDTO struct {
|
||||
Title string `json:"title" binding:"required"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user