kontor-echo: setup project to show homepage
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / build-and-test (push) Failing after 11s

This commit is contained in:
Thomas Peetz
2026-11-09 17:02:59 +01:00
parent 074abd3c85
commit debdf3d0b0
63 changed files with 2411 additions and 485 deletions
+73
View File
@@ -0,0 +1,73 @@
package models
import (
"kontor-api-echo/internal/helpers"
"time"
"github.com/uptrace/bun"
)
type Mail struct {
bun.BaseModel `bun:"table:mail"`
ID string `bun:"id,pk"`
CreatedAt time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
UpdatedAt time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
DeletedAt *time.Time `bun:"deleted_date,nullzero"`
Version int `bun:"version,default:0"`
Folder string `bun:"folder"`
Subject string `bun:"subject"`
Body string `bun:"body"`
SendAt time.Time `bun:"sent_date"`
ReceivedAt time.Time `bun:"received_date"`
}
type MailDTO 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"`
Folder string `json:"folder"`
Subject string `json:"subject"`
Body string `json:"body"`
SendAt time.Time `json:"sent_date"`
ReceivedAt time.Time `json:"received_date"`
}
func (dto MailDTO) ConvertDTOToModel() Mail {
model := Mail{
ID: dto.ID,
CreatedAt: dto.CreatedAt.Time,
UpdatedAt: dto.UpdatedAt.Time,
DeletedAt: dto.DeletedAt,
Version: dto.Version,
Folder: dto.Folder,
Subject: dto.Subject,
Body: dto.Body,
SendAt: dto.SendAt,
ReceivedAt: dto.ReceivedAt,
}
return model
}
func ConvertMailsToDtos(mails []Mail) []MailDTO {
dtos := make([]MailDTO, len(mails))
for i, mail := range mails {
dtos[i] = MailDTO{
ID: mail.ID,
CreatedAt: helpers.KontorTime{Time: mail.CreatedAt},
UpdatedAt: helpers.KontorTime{Time: mail.UpdatedAt},
DeletedAt: mail.DeletedAt,
Version: mail.Version,
Folder: mail.Folder,
Subject: mail.Subject,
Body: mail.Body,
SendAt: mail.SendAt,
ReceivedAt: mail.ReceivedAt,
}
}
return dtos
}
type MailDTOList []MailDTO
@@ -0,0 +1,77 @@
package models
import (
"kontor-api-echo/internal/helpers"
"time"
"github.com/uptrace/bun"
)
type MailAccount struct {
bun.BaseModel `bun:"table:mail_account"`
ID string `bun:"id,pk"`
CreatedAt time.Time `bun:"created_date,nullzero,notnull,default:current_timestamp"`
UpdatedAt time.Time `bun:"last_modified_date,nullzero,notnull,default:current_timestamp"`
DeletedAt *time.Time `bun:"deleted_date,nullzero"`
Version int `bun:"version,default:0"`
Host string `bun:"host"`
Port int `bun:"port"`
Protocol string `bun:"protocol"`
UserName string `bun:"user_name"`
Password string `bun:"password"`
StartTLS bool `bun:"start_tls"`
}
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 (dto MailAccountDTO) ConvertDTOToModel() MailAccount {
model := MailAccount{
ID: dto.ID,
CreatedAt: dto.CreatedAt.Time,
UpdatedAt: dto.UpdatedAt.Time,
DeletedAt: dto.DeletedAt,
Version: dto.Version,
Host: dto.Host,
Port: dto.Port,
Protocol: dto.Protocol,
UserName: dto.UserName,
Password: dto.Password,
StartTLS: dto.StartTLS,
}
return model
}
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
}
type MailAccountDTOList []MailAccountDTO