add methods in Repository and Model for importing data
This commit is contained in:
@@ -38,6 +38,22 @@ type CardDTO struct {
|
||||
VendorID string `json:"vendor_id" binding:"required"`
|
||||
}
|
||||
|
||||
func (dto CardDTO) ConvertDTOToModel() Card {
|
||||
model := Card{
|
||||
ID: dto.ID,
|
||||
CreatedAt: dto.CreatedAt.Time,
|
||||
UpdatedAt: dto.UpdatedAt.Time,
|
||||
DeletedAt: dto.DeletedAt,
|
||||
Version: dto.Version,
|
||||
CardNumber: dto.CardNumber,
|
||||
Year: dto.Year,
|
||||
CardSetID: dto.CardSetID,
|
||||
RoosterID: dto.RoosterID,
|
||||
VendorID: dto.VendorID,
|
||||
}
|
||||
return model
|
||||
}
|
||||
|
||||
func ConvertCardsToDtos(cards []Card) []CardDTO {
|
||||
dtos := make([]CardDTO, len(cards))
|
||||
for i, card := range cards {
|
||||
@@ -56,3 +72,5 @@ func ConvertCardsToDtos(cards []Card) []CardDTO {
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
|
||||
type CardDTOList []CardDTO
|
||||
|
||||
Reference in New Issue
Block a user