mirror of
https://gitlab.com/mobicoop/v3/service/auth.git
synced 2026-03-29 15:15:49 +00:00
delete username usecase
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { DomainEvent, DomainEventProps } from '@mobicoop/ddd-library';
|
||||
|
||||
export class UsernameDeletedDomainEvent extends DomainEvent {
|
||||
constructor(props: DomainEventProps<UsernameDeletedDomainEvent>) {
|
||||
super(props);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AggregateID, AggregateRoot } from '@mobicoop/ddd-library';
|
||||
import { CreateUsernameProps, UsernameProps } from './username.types';
|
||||
import { UsernameAddedDomainEvent } from './events/username-added.domain-event';
|
||||
import { UsernameDeletedDomainEvent } from './events/username-deleted.domain-event';
|
||||
|
||||
export class UsernameEntity extends AggregateRoot<UsernameProps> {
|
||||
protected readonly _id: AggregateID;
|
||||
@@ -23,6 +24,14 @@ export class UsernameEntity extends AggregateRoot<UsernameProps> {
|
||||
return username;
|
||||
};
|
||||
|
||||
delete(): void {
|
||||
this.addEvent(
|
||||
new UsernameDeletedDomainEvent({
|
||||
aggregateId: this.id,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
validate(): void {
|
||||
// entity business rules validation to protect it's invariant before saving entity to a database
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user