mirror of
https://gitlab.com/mobicoop/v3/service/auth.git
synced 2026-03-29 15:15:49 +00:00
update username
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { DomainEvent, DomainEventProps } from '@mobicoop/ddd-library';
|
||||
|
||||
export class UsernameUpdatedDomainEvent extends DomainEvent {
|
||||
constructor(props: DomainEventProps<UsernameUpdatedDomainEvent>) {
|
||||
super(props);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
import { AggregateID, AggregateRoot } from '@mobicoop/ddd-library';
|
||||
import { CreateUsernameProps, UsernameProps } from './username.types';
|
||||
import {
|
||||
CreateUsernameProps,
|
||||
UpdateUsernameProps,
|
||||
UsernameProps,
|
||||
} from './username.types';
|
||||
import { UsernameAddedDomainEvent } from './events/username-added.domain-event';
|
||||
import { UsernameDeletedDomainEvent } from './events/username-deleted.domain-event';
|
||||
import { UsernameUpdatedDomainEvent } from './events/username-updated.domain-event';
|
||||
|
||||
export class UsernameEntity extends AggregateRoot<UsernameProps> {
|
||||
protected readonly _id: AggregateID;
|
||||
@@ -24,6 +29,15 @@ export class UsernameEntity extends AggregateRoot<UsernameProps> {
|
||||
return username;
|
||||
};
|
||||
|
||||
update(props: UpdateUsernameProps): void {
|
||||
this.props.name = props.name;
|
||||
this.addEvent(
|
||||
new UsernameUpdatedDomainEvent({
|
||||
aggregateId: props.name,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
delete(): void {
|
||||
this.addEvent(
|
||||
new UsernameDeletedDomainEvent({
|
||||
|
||||
@@ -10,6 +10,10 @@ export interface CreateUsernameProps {
|
||||
type: Type;
|
||||
}
|
||||
|
||||
export interface UpdateUsernameProps {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export enum Type {
|
||||
EMAIL = 'EMAIL',
|
||||
PHONE = 'PHONE',
|
||||
|
||||
Reference in New Issue
Block a user