add methods in Repository an dModel for importing data
This commit is contained in:
@@ -32,6 +32,18 @@ type BookDTO struct {
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
func (dto BookDTO) ConvertDTOToModel() Book {
|
||||
model := Book{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
Title: dto.Title,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertBooksToDtos(books []Book) []BookDTO {
|
||||
dtos := make([]BookDTO, len(books))
|
||||
for i, book := range books {
|
||||
|
||||
Reference in New Issue
Block a user