add methods in Repository and Model for importing data
This commit is contained in:
@@ -30,6 +30,19 @@ type VolumeDTO struct {
|
||||
ComicID *string `json:"comic_id"`
|
||||
}
|
||||
|
||||
func (dto VolumeDTO) ConvertDTOToModel() Volume {
|
||||
model := Volume{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
Name: dto.Name,
|
||||
ComicID: dto.ComicID,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertVolumesToDtos(volumes []Volume) []VolumeDTO {
|
||||
dtos := make([]VolumeDTO, len(volumes))
|
||||
for i, volume := range volumes {
|
||||
@@ -45,3 +58,5 @@ func ConvertVolumesToDtos(volumes []Volume) []VolumeDTO {
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type VolumeDTOList []VolumeDTO
|
||||
|
||||
Reference in New Issue
Block a user