Files
kontor/kontor-gin/internal/models/issuework.go
T
Thomas Peetz 0750621b96
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / build-and-test (push) Failing after 19m24s
add methods in Repository and Model for importing data
2026-10-29 17:40:54 +01:00

55 lines
2.0 KiB
Go

package models
import (
"kontor-api-gin/internal/helpers"
"time"
)
type IssueWork 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"`
ArtistID *string `gorm:"column:artist_id" json:"artist_id"`
Artist *Artist `gorm:"foreignKey:ArtistID" json:"artist"`
IssueID *string `gorm:"column:issue_id" json:"issue_id"`
Issue *Issue `gorm:"foreignKey:IssueID" json:"issue"`
WorkTypeID *string `gorm:"column:work_type_id" json:"work_type_id"`
WorkType *WorkType `gorm:"foreignKey:WorkTypeID" json:"work_type"`
}
func (issue_work *IssueWork) TableName() string {
return "issue_work"
}
type IssueworkDTO 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"`
IssueID *string `json:"issue_id"`
ArtistID *string `json:"artist_id"`
WorkTypeID *string `json:"work_type_id"`
}
func ConvertIssueworksToDtos(issueworks []IssueWork) []IssueworkDTO {
dtos := make([]IssueworkDTO, len(issueworks))
for i, issuework := range issueworks {
dtos[i] = IssueworkDTO{
ID: issuework.ID,
CreatedAt: helpers.KontorTime{Time: issuework.CreatedAt},
UpdatedAt: helpers.KontorTime{Time: issuework.UpdatedAt},
DeletedAt: issuework.DeletedAt,
Version: issuework.Version,
ArtistID: issuework.ArtistID,
IssueID: issuework.IssueID,
WorkTypeID: issuework.WorkTypeID,
}
}
return dtos
}
type IssueworkDTOList []IssueworkDTO