add methods in Repository and Model for importing data
This commit is contained in:
@@ -34,6 +34,20 @@ type PublisherDTO struct {
|
||||
ParentPublisherID *string `json:"parent_publisher_id"`
|
||||
}
|
||||
|
||||
func (dto PublisherDTO) ConvertDTOToModel() Publisher {
|
||||
model := Publisher{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
Name: dto.Name,
|
||||
WebLink: dto.WebLink,
|
||||
ParentPublisherID: dto.ParentPublisherID,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertPublishersToDtos(publishers []Publisher) []PublisherDTO {
|
||||
dtos := make([]PublisherDTO, len(publishers))
|
||||
for i, publisher := range publishers {
|
||||
@@ -55,3 +69,5 @@ type CreatePublisherDTO struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
WebLink string `json:"weblink" binding:"required"`
|
||||
}
|
||||
|
||||
type PublisherDTOList []PublisherDTO
|
||||
|
||||
Reference in New Issue
Block a user