feat: add cabinet management functionality
This commit is contained in:
43
internal/mapper/cabinet_mapper.go
Normal file
43
internal/mapper/cabinet_mapper.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package mapper
|
||||
|
||||
import (
|
||||
"wm-backend/internal/models"
|
||||
db "wm-backend/sqlc_gen"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
func ToDomainCabinet(r db.Cabinet) *models.Cabinet {
|
||||
return &models.Cabinet{
|
||||
ID: r.ID,
|
||||
RoomID: r.RoomID,
|
||||
Name: r.Name,
|
||||
Description: r.Description.String,
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ToModelCabinet(r *models.Cabinet) *db.CreateCabinetParams {
|
||||
return &db.CreateCabinetParams{
|
||||
RoomID: r.RoomID,
|
||||
Name: r.Name,
|
||||
Description: pgtype.Text{
|
||||
String: r.Description,
|
||||
Valid: r.Description != "",
|
||||
},
|
||||
CreatedAt: r.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ToUpdateModelCabinet(r *models.Cabinet) *db.UpdateCabinetParams {
|
||||
return &db.UpdateCabinetParams{
|
||||
Name: r.Name,
|
||||
Description: pgtype.Text{
|
||||
String: r.Description,
|
||||
Valid: r.Description != "",
|
||||
},
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
ID: r.ID,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user