60 lines
2.2 KiB
Go
60 lines
2.2 KiB
Go
package models
|
|
|
|
import (
|
|
"kontor-api-gin/internal/helpers"
|
|
"time"
|
|
)
|
|
|
|
type MediaLoFi struct {
|
|
ID string `gorm:"type:string;primary_key;" json:"id"`
|
|
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
|
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
|
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
|
Version int `gorm:"default:0" json:"version"`
|
|
WebLink string `gorm:"column:url" json:"url"`
|
|
Review bool `gorm:"column:review" json:"review"`
|
|
ShouldDownload bool `gorm:"column:should_download" json:"should_download"`
|
|
Title string `gorm:"size:300;column:title" json:"title"`
|
|
FileName string `gorm:"column:file_name" json:"file_name"`
|
|
}
|
|
|
|
func (media_lofi *MediaLoFi) TableName() string {
|
|
return "media_lofi"
|
|
}
|
|
|
|
type MediaLofiAdd struct {
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
type MediaLoFiDTO struct {
|
|
ID string `json:"id" binding:"required"`
|
|
CreatedAt helpers.KontorTime `json:"created_date"`
|
|
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
|
|
DeletedAt *time.Time `json:"deleted_date,omitempty"`
|
|
Version int `json:"version"`
|
|
FileName string `json:"file_name"`
|
|
Review bool `json:"review"`
|
|
ShouldDownload bool `json:"should_download"`
|
|
Title string `json:"title"`
|
|
WebLink string `json:"url"`
|
|
}
|
|
|
|
func ConvertMediaLoFisToDtos(media_lofis []MediaLoFi) []MediaLoFiDTO {
|
|
dtos := make([]MediaLoFiDTO, len(media_lofis))
|
|
for i, media_lofi := range media_lofis {
|
|
dtos[i] = MediaLoFiDTO{
|
|
ID: media_lofi.ID,
|
|
CreatedAt: helpers.KontorTime{Time: media_lofi.CreatedAt},
|
|
UpdatedAt: helpers.KontorTime{Time: media_lofi.UpdatedAt},
|
|
DeletedAt: media_lofi.DeletedAt,
|
|
Version: media_lofi.Version,
|
|
WebLink: media_lofi.WebLink,
|
|
Review: media_lofi.Review,
|
|
ShouldDownload: media_lofi.ShouldDownload,
|
|
Title: media_lofi.Title,
|
|
FileName: media_lofi.FileName,
|
|
}
|
|
}
|
|
return dtos
|
|
}
|