Füge neue Modelle für Produktion, Inventar und kaufbare Bestände hinzu; aktualisiere bestehende Modelle und Routen

This commit is contained in:
Torsten Schulz
2024-12-23 10:37:43 +01:00
parent 1bb2bd49d5
commit 6f7d97672e
15 changed files with 1143 additions and 44 deletions

View File

@@ -7,11 +7,13 @@ class FalukantController {
this.randomFirstName = this.randomFirstName.bind(this);
this.randomLastName = this.randomLastName.bind(this);
this.getInfo = this.getInfo.bind(this);
this.getInventory = this.getInventory.bind(this);
this.sellProduct = this.sellProduct.bind(this);
}
async getUser(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getUser(hashedUserId);
res.status(200).json(result);
} catch (error) {
@@ -69,6 +71,94 @@ class FalukantController {
res.status(500).json({ error: error.message });
}
}
async getBranch(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branch: branchId } = req.params;
console.log(branchId, req.params);
const result = await FalukantService.getBranch(hashedUserId, branchId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async createProduction(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId, productId, quantity } = req.body;
const result = await FalukantService.createProduction(hashedUserId, branchId, productId, quantity);
res.status(201).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getProduction(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId } = req.params;
const result = await FalukantService.getProduction(hashedUserId, branchId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getStock(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId } = req.params || null;
const result = await FalukantService.getStock(hashedUserId, branchId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async createStock(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId, stockTypeId, stockSize } = req.body;
const result = await FalukantService.createStock(hashedUserId, branchId, stockTypeId, stockSize);
res.status(201).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getProducts(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getProducts(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async getInventory(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId } = req.params;
const result = await FalukantService.getInventory(hashedUserId, branchId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
async sellProduct(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { branchId, productId, quality, quantity } = req.body;
const result = await FalukantService.sellProduct(hashedUserId, branchId, productId, quality, quantity);
res.status(201).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
}
}
export default FalukantController;