bc88c694ee
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Co-authored-by: Thomas Peetz <thomas.peetz@cimt-ag.de> Reviewed-on: #97
68 lines
2.7 KiB
Go
68 lines
2.7 KiB
Go
package models
|
|
|
|
import (
|
|
"kontor-api-gin/internal/helpers"
|
|
"time"
|
|
)
|
|
|
|
type MediaFile 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"`
|
|
CloudLink string `gorm:"column:cloud_link" json:"cloud_link"`
|
|
FileName string `gorm:"column:file_name" json:"file_name"`
|
|
Path string `gorm:"column:path" json:"path"`
|
|
Review bool `gorm:"column:review" json:"review"`
|
|
Title string `gorm:"size:300, column:title" json:"title"`
|
|
WebLink string `gorm:"column:url" json:"url"`
|
|
ShouldDownload bool `gorm:"column:should_download" json:"should_download"`
|
|
|
|
MediaActorFiles []MediaActorFile `gorm:"foreignKey:MediaFileID" json:"media_actor_files"`
|
|
}
|
|
|
|
func (media_file *MediaFile) TableName() string {
|
|
return "media_file"
|
|
}
|
|
|
|
type MediaFileAdd struct {
|
|
Url string `json:"url"`
|
|
}
|
|
|
|
type MediaFileDTO 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"`
|
|
CloudLink string `json:"cloud_link"`
|
|
FileName string `json:"file_name"`
|
|
Path string `json:"path"`
|
|
Review bool `json:"review"`
|
|
Title string `json:"title"`
|
|
WebLink string `json:"url"`
|
|
ShouldDownload bool `json:"should_download"`
|
|
}
|
|
|
|
func ConvertMediaFilesToDtos(media_files []MediaFile) []MediaFileDTO {
|
|
dtos := make([]MediaFileDTO, len(media_files))
|
|
for i, media_file := range media_files {
|
|
dtos[i] = MediaFileDTO{
|
|
ID: media_file.ID,
|
|
CreatedAt: helpers.KontorTime{Time: media_file.CreatedAt},
|
|
UpdatedAt: helpers.KontorTime{Time: media_file.UpdatedAt},
|
|
DeletedAt: media_file.DeletedAt,
|
|
Version: media_file.Version,
|
|
CloudLink: media_file.CloudLink,
|
|
FileName: media_file.FileName,
|
|
Path: media_file.Path,
|
|
Review: media_file.Review,
|
|
Title: media_file.Title,
|
|
WebLink: media_file.WebLink,
|
|
ShouldDownload: media_file.ShouldDownload,
|
|
}
|
|
}
|
|
return dtos
|
|
}
|