first commit
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { Request, Response } from 'express';
|
||||
import * as platformService from '../services/platform.service.js';
|
||||
import { ApiResponse } from '../types/index.js';
|
||||
|
||||
export async function getPlatforms(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const includeInactive = req.query.includeInactive === 'true';
|
||||
const platforms = await platformService.getAllPlatforms(includeInactive);
|
||||
res.json({ success: true, data: platforms } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
error: 'Fehler beim Laden der Vertriebsplattformen',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPlatform(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const platform = await platformService.getPlatformById(parseInt(req.params.id));
|
||||
if (!platform) {
|
||||
res.status(404).json({
|
||||
success: false,
|
||||
error: 'Vertriebsplattform nicht gefunden',
|
||||
} as ApiResponse);
|
||||
return;
|
||||
}
|
||||
res.json({ success: true, data: platform } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
error: 'Fehler beim Laden der Vertriebsplattform',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
export async function createPlatform(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const platform = await platformService.createPlatform(req.body);
|
||||
res.status(201).json({ success: true, data: platform } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Fehler beim Erstellen der Vertriebsplattform',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
export async function updatePlatform(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const platform = await platformService.updatePlatform(parseInt(req.params.id), req.body);
|
||||
res.json({ success: true, data: platform } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Fehler beim Aktualisieren der Vertriebsplattform',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
|
||||
export async function deletePlatform(req: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
await platformService.deletePlatform(parseInt(req.params.id));
|
||||
res.json({ success: true, message: 'Vertriebsplattform gelöscht' } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Fehler beim Löschen der Vertriebsplattform',
|
||||
} as ApiResponse);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user