add methods in Repository an dModel for importing data
This commit is contained in:
@@ -31,6 +31,19 @@ type AuthorDTO struct {
|
||||
LastName string `json:"last_name"`
|
||||
}
|
||||
|
||||
func (dto AuthorDTO) ConvertDTOToModel() Author {
|
||||
model := Author{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
FirstName: dto.FirstName,
|
||||
LastName: dto.LastName,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertAuthorsToDtos(authors []Author) []AuthorDTO {
|
||||
dtos := make([]AuthorDTO, len(authors))
|
||||
for i, author := range authors {
|
||||
|
||||
Reference in New Issue
Block a user