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