31 lines
773 B
Java
31 lines
773 B
Java
package org.hso.ecommerce.components;
|
|
|
|
import org.hso.ecommerce.entities.warehouse.Slot;
|
|
import org.hso.ecommerce.repos.warehouse.SlotRepository;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
@Component
|
|
public class SlotInitializer {
|
|
|
|
@Autowired
|
|
private final SlotRepository slotRepository = null;
|
|
|
|
// TODO: use values form cfg.
|
|
private final int NUM_SLOTS = 50;
|
|
|
|
@PostConstruct
|
|
public void init() {
|
|
for (int i = 1; i <= NUM_SLOTS; i++) {
|
|
if (!slotRepository.findBySlotNum(i).isPresent()) {
|
|
Slot slotAdded = new Slot();
|
|
slotAdded.slotNum = i;
|
|
slotRepository.save(slotAdded);
|
|
System.out.println("Added Slot " + i + " to DB");
|
|
}
|
|
}
|
|
}
|
|
}
|