kontor-echo: setup project to show homepage
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user