package mapper import ( "wm-backend/internal/models" db "wm-backend/sqlc_gen" "github.com/jackc/pgx/v5/pgtype" ) func ToDomainContainer(r db.Container) *models.Container { return &models.Container{ ID: r.ID, ShelfID: r.ShelfID, Name: r.Name, ContainerType: string(r.ContainerType), Description: r.Description.String, MaxCapacity: r.MaxCapacity.Int32, Metadata: r.Metadata, CreatedAt: r.CreatedAt, UpdatedAt: r.UpdatedAt, } } func ToModelContainer(r *models.Container) *db.CreateContainerParams { return &db.CreateContainerParams{ ShelfID: r.ShelfID, Name: r.Name, ContainerType: db.ContainerTypeEnum(r.ContainerType), Description: pgtype.Text{ String: r.Description, Valid: r.Description != "", }, MaxCapacity: pgtype.Int4{ Int32: r.MaxCapacity, Valid: r.MaxCapacity != 0, }, Metadata: r.Metadata, CreatedAt: r.CreatedAt, } } func ToUpdateModelContainer(r *models.Container) *db.UpdateContainerParams { return &db.UpdateContainerParams{ Name: r.Name, ContainerType: db.NullContainerTypeEnum{ ContainerTypeEnum: db.ContainerTypeEnum(r.ContainerType), Valid: r.ContainerType != "", }, Description: pgtype.Text{ String: r.Description, Valid: r.Description != "", }, MaxCapacity: pgtype.Int4{ Int32: r.MaxCapacity, Valid: r.MaxCapacity != 0, }, Metadata: r.Metadata, UpdatedAt: r.UpdatedAt, ID: r.ID, } }