feat: Implement friendly match management features
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 44s

- Added backend support for managing friendly matches including listing, creating, updating, and deleting matches.
- Introduced a new database table `friendly_match` with relevant fields for match details.
- Created a service layer to handle business logic related to friendly matches.
- Developed API routes for friendly match operations with appropriate authentication and authorization.
- Added a Vue component for managing participants in friendly matches, allowing selection of members and manual entry of names.
- Updated existing tournament editor screens to integrate friendly match functionalities.
This commit is contained in:
Torsten Schulz (local)
2026-05-18 00:43:42 +02:00
parent 040e758044
commit 5dfdcb63bc
16 changed files with 1551 additions and 87 deletions

View File

@@ -0,0 +1,70 @@
import FriendlyMatchService from '../services/friendlyMatchService.js';
import { emitScheduleMatchUpdated } from '../services/socketService.js';
function userTokenFrom(req) {
return req.headers.authcode;
}
export const listFriendlyMatches = async (req, res) => {
try {
const matches = await FriendlyMatchService.list(userTokenFrom(req), req.params.clubId);
res.status(200).json(matches);
} catch (error) {
console.error('[listFriendlyMatches] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Freundschaftsspiele konnten nicht geladen werden' });
}
};
export const createFriendlyMatch = async (req, res) => {
try {
const match = await FriendlyMatchService.create(userTokenFrom(req), req.params.clubId, req.body);
emitScheduleMatchUpdated(req.params.clubId, match.id, match);
res.status(201).json(match);
} catch (error) {
console.error('[createFriendlyMatch] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Freundschaftsspiel konnte nicht erstellt werden' });
}
};
export const updateFriendlyMatch = async (req, res) => {
try {
const match = await FriendlyMatchService.update(userTokenFrom(req), req.params.clubId, req.params.matchId, req.body);
emitScheduleMatchUpdated(req.params.clubId, match.id, match);
res.status(200).json(match);
} catch (error) {
console.error('[updateFriendlyMatch] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Freundschaftsspiel konnte nicht gespeichert werden' });
}
};
export const deleteFriendlyMatch = async (req, res) => {
try {
const result = await FriendlyMatchService.remove(userTokenFrom(req), req.params.clubId, req.params.matchId);
emitScheduleMatchUpdated(req.params.clubId, Number(req.params.matchId), null);
res.status(200).json(result);
} catch (error) {
console.error('[deleteFriendlyMatch] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Freundschaftsspiel konnte nicht gelöscht werden' });
}
};
export const updateFriendlyMatchPlayers = async (req, res) => {
try {
const match = await FriendlyMatchService.updatePlayers(userTokenFrom(req), req.params.clubId, req.params.matchId, req.body);
emitScheduleMatchUpdated(req.params.clubId, match.id, match);
res.status(200).json({ message: 'Teilnehmer gespeichert', data: match });
} catch (error) {
console.error('[updateFriendlyMatchPlayers] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Teilnehmer konnten nicht gespeichert werden' });
}
};
export const getFriendlyMatchMembers = async (req, res) => {
try {
const members = await FriendlyMatchService.members(userTokenFrom(req), req.params.clubId);
res.status(200).json(members);
} catch (error) {
console.error('[getFriendlyMatchMembers] Error:', error);
res.status(error.statusCode || 500).json({ error: error.message || 'Mitglieder konnten nicht geladen werden' });
}
};