Files
kontor/kontor-gin/internal/models/artist.go
T
Thomas Peetz 4aaf580735
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
WIP: Export Kontor DB
2026-10-01 17:40:17 +02:00

52 lines
1.6 KiB
Go

package models
import (
"kontor-api-gin/internal/helpers"
"time"
)
type Artist 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"`
Name string `gorm:"uniqueIndex" json:"name"`
WebLink string `gorm:"column:weblink" json:"weblink"`
}
func (artist *Artist) TableName() string {
return "artist"
}
type ArtistDTO struct {
ID string `json:"id"`
CreatedAt helpers.KontorTime `json:"created_date"`
UpdatedAt helpers.KontorTime `json:"last_modified_date"`
DeletedAt *time.Time `json:"deleted_date,omitempty"`
Version int `json:"version"`
Name string `json:"name"`
WebLink string `json:"weblink"`
}
func ConvertArtistsToDtos(artists []Artist) []ArtistDTO {
dtos := make([]ArtistDTO, len(artists))
for i, artist := range artists {
dtos[i] = ArtistDTO{
ID: artist.ID,
CreatedAt: helpers.KontorTime{Time: artist.CreatedAt},
UpdatedAt: helpers.KontorTime{Time: artist.UpdatedAt},
DeletedAt: artist.DeletedAt,
Version: artist.Version,
Name: artist.Name,
WebLink: artist.WebLink,
}
}
return dtos
}
type CreateArtistDTO struct {
Name string `json:"name" binding:"required"`
WebLink string `json:"weblink" binding:"required"`
}