rename to core

This commit is contained in:
2025-12-15 13:46:07 +01:00
parent aedf58643d
commit 5c22f8820c
559 changed files with 415 additions and 767 deletions

View File

@@ -0,0 +1,34 @@
import type { ITeamRepository } from '../../domain/repositories/ITeamRepository';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import { Team } from '../../domain/entities/Team';
import type { UpdateTeamCommandDTO } from '../dto/TeamCommandAndQueryDTO';
export class UpdateTeamUseCase {
constructor(
private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
) {}
async execute(command: UpdateTeamCommandDTO): Promise<void> {
const { teamId, updates, updatedBy } = command;
const updaterMembership = await this.membershipRepository.getMembership(teamId, updatedBy);
if (!updaterMembership || (updaterMembership.role !== 'owner' && updaterMembership.role !== 'manager')) {
throw new Error('Only owners and managers can update team info');
}
const existing = await this.teamRepository.findById(teamId);
if (!existing) {
throw new Error('Team not found');
}
const updated = existing.update({
...(updates.name !== undefined && { name: updates.name }),
...(updates.tag !== undefined && { tag: updates.tag }),
...(updates.description !== undefined && { description: updates.description }),
...(updates.leagues !== undefined && { leagues: updates.leagues }),
});
await this.teamRepository.update(updated);
}
}