harden media
This commit is contained in:
@@ -14,6 +14,7 @@ import { TeamDescription } from '../value-objects/TeamDescription';
|
||||
import { DriverId } from './DriverId';
|
||||
import { LeagueId } from './LeagueId';
|
||||
import { TeamCreatedAt } from '../value-objects/TeamCreatedAt';
|
||||
import { MediaReference } from '@core/domain/media/MediaReference';
|
||||
|
||||
export class Team implements IEntity<string> {
|
||||
readonly id: string;
|
||||
@@ -25,6 +26,7 @@ export class Team implements IEntity<string> {
|
||||
readonly category: string | undefined;
|
||||
readonly isRecruiting: boolean;
|
||||
readonly createdAt: TeamCreatedAt;
|
||||
readonly logoRef: MediaReference;
|
||||
|
||||
private constructor(props: {
|
||||
id: string;
|
||||
@@ -36,6 +38,7 @@ export class Team implements IEntity<string> {
|
||||
category: string | undefined;
|
||||
isRecruiting: boolean;
|
||||
createdAt: TeamCreatedAt;
|
||||
logoRef: MediaReference;
|
||||
}) {
|
||||
this.id = props.id;
|
||||
this.name = props.name;
|
||||
@@ -46,6 +49,7 @@ export class Team implements IEntity<string> {
|
||||
this.category = props.category;
|
||||
this.isRecruiting = props.isRecruiting;
|
||||
this.createdAt = props.createdAt;
|
||||
this.logoRef = props.logoRef;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +65,7 @@ export class Team implements IEntity<string> {
|
||||
category?: string;
|
||||
isRecruiting?: boolean;
|
||||
createdAt?: Date;
|
||||
logoRef?: MediaReference;
|
||||
}): Team {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
throw new RacingDomainValidationError('Team ID is required');
|
||||
@@ -80,6 +85,7 @@ export class Team implements IEntity<string> {
|
||||
category: props.category,
|
||||
isRecruiting: props.isRecruiting ?? false,
|
||||
createdAt: TeamCreatedAt.create(props.createdAt ?? new Date()),
|
||||
logoRef: props.logoRef ?? MediaReference.createSystemDefault('logo'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,6 +99,7 @@ export class Team implements IEntity<string> {
|
||||
category?: string;
|
||||
isRecruiting: boolean;
|
||||
createdAt: Date;
|
||||
logoRef?: MediaReference;
|
||||
}): Team {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
throw new RacingDomainValidationError('Team ID is required');
|
||||
@@ -112,6 +119,7 @@ export class Team implements IEntity<string> {
|
||||
category: props.category,
|
||||
isRecruiting: props.isRecruiting,
|
||||
createdAt: TeamCreatedAt.create(props.createdAt),
|
||||
logoRef: props.logoRef ?? MediaReference.createSystemDefault('logo'),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,6 +134,7 @@ export class Team implements IEntity<string> {
|
||||
leagues: string[];
|
||||
category: string | undefined;
|
||||
isRecruiting: boolean;
|
||||
logoRef: MediaReference;
|
||||
}>): Team {
|
||||
const nextName = 'name' in props ? TeamName.create(props.name!) : this.name;
|
||||
const nextTag = 'tag' in props ? TeamTag.create(props.tag!) : this.tag;
|
||||
@@ -134,6 +143,7 @@ export class Team implements IEntity<string> {
|
||||
const nextLeagues = 'leagues' in props ? props.leagues!.map(leagueId => LeagueId.create(leagueId)) : this.leagues;
|
||||
const nextCategory = 'category' in props ? props.category : this.category;
|
||||
const nextIsRecruiting = 'isRecruiting' in props ? props.isRecruiting! : this.isRecruiting;
|
||||
const nextLogoRef = 'logoRef' in props ? props.logoRef! : this.logoRef;
|
||||
|
||||
return new Team({
|
||||
id: this.id,
|
||||
@@ -145,6 +155,7 @@ export class Team implements IEntity<string> {
|
||||
category: nextCategory,
|
||||
isRecruiting: nextIsRecruiting,
|
||||
createdAt: this.createdAt,
|
||||
logoRef: nextLogoRef,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user