2021-05-07 12:08:34 +02:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
2024-10-26 14:56:17 +02:00
|
|
|
"github.com/semaphoreui/semaphore/db"
|
2021-05-07 12:08:34 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (d *BoltDb) GetInventory(projectID int, inventoryID int) (inventory db.Inventory, err error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
err = d.getObject(projectID, db.InventoryProps, intObjectID(inventoryID), &inventory)
|
2021-05-07 12:08:34 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-09-01 21:17:28 +02:00
|
|
|
err = db.FillInventory(d, &inventory)
|
2021-05-07 12:08:34 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) GetInventories(projectID int, params db.RetrieveQueryParams) (inventories []db.Inventory, err error) {
|
2021-05-14 13:47:32 +02:00
|
|
|
err = d.getObjects(projectID, db.InventoryProps, params, nil, &inventories)
|
2021-05-08 22:25:31 +02:00
|
|
|
return
|
2021-05-07 12:08:34 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 08:05:13 +01:00
|
|
|
func (d *BoltDb) GetInventoryRefs(projectID int, inventoryID int) (db.ObjectReferrers, error) {
|
|
|
|
return d.getObjectRefs(projectID, db.InventoryProps, inventoryID)
|
2021-05-07 12:08:34 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 08:05:13 +01:00
|
|
|
func (d *BoltDb) DeleteInventory(projectID int, inventoryID int) error {
|
|
|
|
return d.deleteObject(projectID, db.InventoryProps, intObjectID(inventoryID), nil)
|
2021-05-07 12:08:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *BoltDb) UpdateInventory(inventory db.Inventory) error {
|
2021-05-13 21:45:54 +02:00
|
|
|
return d.updateObject(inventory.ProjectID, db.InventoryProps, inventory)
|
2021-05-07 12:08:34 +02:00
|
|
|
}
|
|
|
|
|
2021-05-08 22:25:31 +02:00
|
|
|
func (d *BoltDb) CreateInventory(inventory db.Inventory) (db.Inventory, error) {
|
2021-05-13 21:45:54 +02:00
|
|
|
newInventory, err := d.createObject(inventory.ProjectID, db.InventoryProps, inventory)
|
2021-05-08 22:25:31 +02:00
|
|
|
return newInventory.(db.Inventory), err
|
2021-05-07 12:08:34 +02:00
|
|
|
}
|