51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package mapper
|
|
|
|
import (
|
|
"wm-backend/internal/models"
|
|
db "wm-backend/sqlc_gen"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
func ToDomainInvoiceConfig(r db.InvoiceConfig) *models.InvoiceConfig {
|
|
return &models.InvoiceConfig{
|
|
ID: r.ID,
|
|
Name: r.Name,
|
|
Type: string(r.Type),
|
|
Description: r.Description.String,
|
|
IsActive: r.IsActive,
|
|
Metadata: r.Metadata,
|
|
CreatedAt: r.CreatedAt,
|
|
UpdatedAt: r.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func ToModelInvoiceConfig(r *models.InvoiceConfig) *db.CreateInvoiceConfigParams {
|
|
return &db.CreateInvoiceConfigParams{
|
|
Name: r.Name,
|
|
Type: db.InvoiceTypeEnum(r.Type),
|
|
Description: pgtype.Text{
|
|
String: r.Description,
|
|
Valid: r.Description != "",
|
|
},
|
|
IsActive: r.IsActive,
|
|
Metadata: r.Metadata,
|
|
CreatedAt: r.CreatedAt,
|
|
}
|
|
}
|
|
|
|
func ToUpdateModelInvoiceConfig(r *models.InvoiceConfig) *db.UpdateInvoiceConfigParams {
|
|
return &db.UpdateInvoiceConfigParams{
|
|
Name: r.Name,
|
|
Type: db.InvoiceTypeEnum(r.Type),
|
|
Description: pgtype.Text{
|
|
String: r.Description,
|
|
Valid: r.Description != "",
|
|
},
|
|
IsActive: r.IsActive,
|
|
Metadata: r.Metadata,
|
|
UpdatedAt: r.UpdatedAt,
|
|
ID: r.ID,
|
|
}
|
|
}
|