feat: add room management functionality
This commit is contained in:
43
internal/mapper/room_mapper.go
Normal file
43
internal/mapper/room_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 ToDomainRoom(r db.Room) *models.Room {
|
||||
return &models.Room{
|
||||
ID: r.ID,
|
||||
WarehouseID: r.WarehouseID,
|
||||
Name: r.Name,
|
||||
Description: r.Description.String,
|
||||
CreatedAt: r.CreatedAt,
|
||||
UpdatedAt: r.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ToModelRoom(r *models.Room) *db.CreateRoomParams {
|
||||
return &db.CreateRoomParams{
|
||||
WarehouseID: r.WarehouseID,
|
||||
Name: r.Name,
|
||||
Description: pgtype.Text{
|
||||
String: r.Description,
|
||||
Valid: r.Description != "",
|
||||
},
|
||||
CreatedAt: r.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func ToUpdateModelRoom(r *models.Room) *db.UpdateRoomParams {
|
||||
return &db.UpdateRoomParams{
|
||||
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