feat: add invoice-configs management functionality
This commit is contained in:
50
internal/mapper/invoice_config_mapper.go
Normal file
50
internal/mapper/invoice_config_mapper.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user