Files
kontor/kontor-gin/internal/models/mailaccount.go
T
tpeetz e1b5691fac
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s
add models for MailAccount and Mail
2026-10-04 20:43:08 +02:00

59 lines
2.2 KiB
Go

package models
import (
"kontor-api-gin/internal/helpers"
"time"
)
type MailAccount 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"`
Host string `gorm:"column:host" json:"host"`
Port int `gorm:"column:port" json:"port"`
Protocol string `gorm:"column:protocol" json:"protocol"`
UserName string `gorm:"column:user_name" json:"user_name"`
Password string `gorm:"column:password" json:"password"`
StartTLS bool `gorm:"column:start_tls" json:"start_tls"`
}
func (mail_account *MailAccount) TableName() string {
return "mail_account"
}
type MailAccountDTO 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"`
Host string `json:"host"`
Port int `json:"port"`
Protocol string `json:"protocol"`
UserName string `json:"user_name"`
Password string `json:"password"`
StartTLS bool `json:"start_tls"`
}
func ConvertMailAccountsToDtos(mailaccounts []MailAccount) []MailAccountDTO {
dtos := make([]MailAccountDTO, len(mailaccounts))
for i, mailaccount := range mailaccounts {
dtos[i] = MailAccountDTO{
ID: mailaccount.ID,
CreatedAt: helpers.KontorTime{Time: mailaccount.CreatedAt},
UpdatedAt: helpers.KontorTime{Time: mailaccount.UpdatedAt},
DeletedAt: mailaccount.DeletedAt,
Version: mailaccount.Version,
Host: mailaccount.Host,
Port: mailaccount.Port,
Protocol: mailaccount.Protocol,
UserName: mailaccount.UserName,
Password: mailaccount.Password,
StartTLS: mailaccount.StartTLS,
}
}
return dtos
}