-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aggregate, edit anemic, add data
- Loading branch information
1 parent
51b9d98
commit e34ff50
Showing
9 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Domain } from '@toxictoast/azkaban-base-domain'; | ||
import { GroupAnemic } from '../anemics'; | ||
import { Nullable } from '@toxictoast/azkaban-base-types'; | ||
|
||
export class GroupAggregate implements Domain<GroupAnemic> { | ||
constructor( | ||
private readonly id: string, | ||
private title: string, | ||
private slug: string, | ||
private active: boolean, | ||
private readonly created_at: Date, | ||
private updated_at: Nullable<Date>, | ||
private deleted_at: Nullable<Date>, | ||
) {} | ||
|
||
isActive(): boolean { | ||
return this.active && !this.isDeleted(); | ||
} | ||
|
||
isUpdated(): boolean { | ||
return !!this.updated_at; | ||
} | ||
|
||
isDeleted(): boolean { | ||
return !!this.deleted_at; | ||
} | ||
|
||
delete(): void { | ||
this.deleted_at = new Date(); | ||
} | ||
|
||
restore(): void { | ||
this.deleted_at = null; | ||
} | ||
|
||
toAnemic(): GroupAnemic { | ||
return { | ||
id: this.id, | ||
title: this.title, | ||
slug: this.slug, | ||
active: this.active, | ||
created_at: this.created_at, | ||
updated_at: this.updated_at, | ||
deleted_at: this.deleted_at, | ||
isActive: this.isActive(), | ||
isUpdated: this.isUpdated(), | ||
isDeleted: this.isDeleted(), | ||
}; | ||
} | ||
|
||
updateTitle(title: string): void { | ||
if (this.title !== title) { | ||
this.updated_at = new Date(); | ||
this.title = title; | ||
} | ||
} | ||
|
||
updateSlug(slug: string): void { | ||
if (this.slug !== slug) { | ||
this.updated_at = new Date(); | ||
this.slug = slug; | ||
} | ||
} | ||
|
||
updateActive(active: boolean): void { | ||
if (this.active !== active) { | ||
this.updated_at = new Date(); | ||
this.active = active; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export {}; | ||
export * from './group.aggregate'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface GroupData { | ||
readonly title: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export {}; | ||
export * from './group.data'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export {}; | ||
export * from './aggregates'; | ||
export * from './anemics'; | ||
export * from './data'; | ||
export * from './factories'; | ||
export * from './repositories'; | ||
export * from './services'; | ||
export * from './validations'; | ||
export * from './valueObjects'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |