feat: add room management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-08 14:58:59 +07:00
parent 6a4a96e0ca
commit 459ff6b384
15 changed files with 1289 additions and 14 deletions

View 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,
}
}