-
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.
- Loading branch information
1 parent
1b15ef1
commit 0649a28
Showing
32 changed files
with
589 additions
and
1 deletion.
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
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,9 @@ | ||
import { makeListActivityClassQuery } from "./queries/list-activity-class"; | ||
|
||
export function makeActivityClassUseCases(dependencies: Dependencies) { | ||
return { | ||
queries: { | ||
listActivityClasses: makeListActivityClassQuery(dependencies), | ||
}, | ||
}; | ||
} |
1 change: 1 addition & 0 deletions
1
src/application/activity-class/queries/list-activity-class/index.ts
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 * from './list-activity-class-query'; |
16 changes: 16 additions & 0 deletions
16
...pplication/activity-class/queries/list-activity-class/list-activity-class-query-mapper.ts
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,16 @@ | ||
import { ActivityClassDTO } from "@domain/dtos/activity-class"; | ||
import { ActivityClassEntity } from "@domain/entities"; | ||
|
||
export function map(activityClass: ActivityClassEntity): ActivityClassDTO { | ||
return { | ||
id: activityClass.id ?? null, | ||
name: activityClass.name ?? null, | ||
image_url: activityClass.image_url ?? null, | ||
status: activityClass.status, | ||
order: activityClass.order ?? null, | ||
created_at: activityClass.created_at?.toISOString() ?? null, | ||
updated_at: activityClass.updated_at?.toISOString() ?? null, | ||
created_by: activityClass.created_by ?? null, | ||
updated_by: activityClass.updated_by ?? null, | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/application/activity-class/queries/list-activity-class/list-activity-class-query.ts
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,10 @@ | ||
import { map } from "./list-activity-class-query-mapper"; | ||
|
||
export function makeListActivityClassQuery({ activityClassRepository }: Pick<Dependencies, 'activityClassRepository'>) { | ||
return async function listActivityClassQuery() { | ||
|
||
const activityClasses = await activityClassRepository.list(); | ||
|
||
return activityClasses.map((activityClass) => map(activityClass)); | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/application/common/interfaces/activity-class-repository.ts
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,5 @@ | ||
import { ActivityClassEntity } from "@domain/entities/activity-class"; | ||
|
||
export interface ActivityClassesRepository { | ||
list(): Promise<Array<ActivityClassEntity>>; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/application/common/interfaces/customer-review-repository.ts
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,5 @@ | ||
import { CustomerReviewEntity } from "@domain/entities/customer-review"; | ||
|
||
export interface CustomerReviewsRepository { | ||
list(): Promise<Array<CustomerReviewEntity>>; | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/application/common/interfaces/student-result-repository.ts
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,5 @@ | ||
import { StudentResultEntity } from "@domain/entities/student-result"; | ||
|
||
export interface StudentResultsRepository { | ||
list(): Promise<Array<StudentResultEntity>>; | ||
} |
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,9 @@ | ||
import { makeListCustomerReviewQuery } from "./queries/list-customer-review"; | ||
|
||
export function makeCustomerReviewUseCases(dependencies: Dependencies) { | ||
return { | ||
queries: { | ||
listCustomerReviews: makeListCustomerReviewQuery(dependencies), | ||
}, | ||
}; | ||
} |
1 change: 1 addition & 0 deletions
1
src/application/customer-review/queries/list-customer-review/index.ts
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 * from './list-customer-review-query'; |
17 changes: 17 additions & 0 deletions
17
...ication/customer-review/queries/list-customer-review/list-customer-review-query-mapper.ts
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,17 @@ | ||
import { CustomerReviewDTO } from "@domain/dtos/customer-review"; | ||
import { CustomerReviewEntity } from "@domain/entities"; | ||
|
||
export function map(customerReview: CustomerReviewEntity): CustomerReviewDTO { | ||
return { | ||
id: customerReview.id ?? null, | ||
review: customerReview.review ?? null, | ||
rating: customerReview.rating ?? null, | ||
media_url: customerReview.media_url, | ||
order: customerReview.order ?? null, | ||
status: customerReview.status, | ||
created_at: customerReview.created_at?.toISOString() ?? null, | ||
updated_at: customerReview.updated_at?.toISOString() ?? null, | ||
created_by: customerReview.created_by ?? null, | ||
updated_by: customerReview.updated_by ?? null, | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/application/customer-review/queries/list-customer-review/list-customer-review-query.ts
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,10 @@ | ||
import { map } from "./list-customer-review-query-mapper"; | ||
|
||
export function makeListCustomerReviewQuery({ customerReviewRepository }: Pick<Dependencies, 'customerReviewRepository'>) { | ||
return async function listCustomerReviewQuery() { | ||
|
||
const customerReviews = await customerReviewRepository.list(); | ||
|
||
return customerReviews.map((customerReview) => map(customerReview)); | ||
}; | ||
} |
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,9 @@ | ||
import { makeListStudentResultQuery } from "./queries/list-student-result"; | ||
|
||
export function makeStudentResultUseCases(dependencies: Dependencies) { | ||
return { | ||
queries: { | ||
listStudentResults: makeListStudentResultQuery(dependencies), | ||
}, | ||
}; | ||
} |
1 change: 1 addition & 0 deletions
1
src/application/student-result/queries/list-student-result/index.ts
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 * from './list-student-result-query'; |
18 changes: 18 additions & 0 deletions
18
...pplication/student-result/queries/list-student-result/list-student-result-query-mapper.ts
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,18 @@ | ||
import { StudentResultDTO } from "@domain/dtos/student-result"; | ||
import { StudentResultEntity } from "@domain/entities"; | ||
|
||
export function map(studentResult: StudentResultEntity): StudentResultDTO { | ||
return { | ||
id: studentResult.id ?? null, | ||
class_name: studentResult.class_name ?? null, | ||
name: studentResult.name ?? null, | ||
description: studentResult.description ?? null, | ||
result_image: studentResult.result_image, | ||
order: studentResult.order ?? null, | ||
status: studentResult.status, | ||
created_at: studentResult.created_at?.toISOString() ?? null, | ||
updated_at: studentResult.updated_at?.toISOString() ?? null, | ||
created_by: studentResult.created_by ?? null, | ||
updated_by: studentResult.updated_by ?? null, | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/application/student-result/queries/list-student-result/list-student-result-query.ts
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,10 @@ | ||
import { map } from "./list-student-result-query-mapper"; | ||
|
||
export function makeListStudentResultQuery({ studentResultRepository }: Pick<Dependencies, 'studentResultRepository'>) { | ||
return async function listStudentResultQuery() { | ||
|
||
const studentResults = await studentResultRepository.list(); | ||
|
||
return studentResults.map((studentResult) => map(studentResult)); | ||
}; | ||
} |
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,11 @@ | ||
export interface ActivityClassDTO { | ||
id: number | null; | ||
name: string | null; | ||
image_url: string | null; | ||
status: number; | ||
order: number | null; | ||
created_at: string | null; | ||
updated_at: string | null; | ||
created_by: string | null; | ||
updated_by: string | null; | ||
} |
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,12 @@ | ||
export interface CustomerReviewDTO { | ||
id: number | null; | ||
review: string | null; | ||
rating: number | null; | ||
media_url: string; | ||
order: number | null; | ||
status: number; | ||
created_at: string | null; | ||
updated_at: string | null; | ||
created_by: string | null; | ||
updated_by: string | null; | ||
} |
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,13 @@ | ||
export interface StudentResultDTO { | ||
id: number | null; | ||
class_name: string | null; | ||
name: string | null; | ||
description: string | null; | ||
result_image: string; | ||
order: number | null; | ||
status: number; | ||
created_at: string | null; | ||
updated_at: string | null; | ||
created_by: string | null; | ||
updated_by: string | null; | ||
} |
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,33 @@ | ||
export class ActivityClassEntity { | ||
public id?: number; | ||
public name?: string | null; | ||
public image_url?: string | null; | ||
public status: number; | ||
public order?: number | null; | ||
public created_at?: Date | null; | ||
public updated_at?: Date | null; | ||
public created_by?: string | null; | ||
public updated_by?: string | null; | ||
|
||
constructor(activityClassEntity: { | ||
id?: number; | ||
name?: string; | ||
image_url?: string; | ||
status: number; | ||
order?: number; | ||
created_at?: Date; | ||
updated_at?: Date; | ||
created_by?: string; | ||
updated_by?: string; | ||
}) { | ||
this.id = activityClassEntity.id; | ||
this.name = activityClassEntity.name; | ||
this.image_url = activityClassEntity.image_url; | ||
this.status = activityClassEntity.status; | ||
this.order = activityClassEntity.order; | ||
this.created_at = activityClassEntity.created_at; | ||
this.updated_at = activityClassEntity.updated_at; | ||
this.created_by = activityClassEntity.created_by; | ||
this.updated_by = activityClassEntity.updated_by; | ||
} | ||
} |
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,36 @@ | ||
export class CustomerReviewEntity { | ||
public id?: number; | ||
public review?: string | null; | ||
public rating?: number | null; | ||
public media_url: string; | ||
public order?: number | null; | ||
public status: number; | ||
public created_at?: Date | null; | ||
public updated_at?: Date | null; | ||
public created_by?: string | null; | ||
public updated_by?: string | null; | ||
|
||
constructor(customerReviewEntity: { | ||
id?: number; | ||
review?: string; | ||
rating?: number; | ||
media_url: string; | ||
order?: number; | ||
status: number; | ||
created_at?: Date; | ||
updated_at?: Date; | ||
created_by?: string; | ||
updated_by?: string; | ||
}) { | ||
this.id = customerReviewEntity.id; | ||
this.review = customerReviewEntity.review; | ||
this.rating = customerReviewEntity.rating; | ||
this.media_url = customerReviewEntity.media_url; | ||
this.order = customerReviewEntity.order; | ||
this.status = customerReviewEntity.status; | ||
this.created_at = customerReviewEntity.created_at; | ||
this.updated_at = customerReviewEntity.updated_at; | ||
this.created_by = customerReviewEntity.created_by; | ||
this.updated_by = customerReviewEntity.updated_by; | ||
} | ||
} |
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,39 @@ | ||
export class StudentResultEntity { | ||
public id?: number; | ||
public class_name?: string | null; | ||
public name?: string | null; | ||
public description?: string | null; | ||
public result_image: string; | ||
public order?: number | null; | ||
public status: number; | ||
public created_at?: Date | null; | ||
public updated_at?: Date | null; | ||
public created_by?: string | null; | ||
public updated_by?: string | null; | ||
|
||
constructor(studentResultEntity: { | ||
id?: number; | ||
class_name?: string; | ||
name?: string; | ||
description?: string; | ||
result_image: string; | ||
order?: number; | ||
status: number; | ||
created_at?: Date; | ||
updated_at?: Date; | ||
created_by?: string; | ||
updated_by?: string; | ||
}) { | ||
this.id = studentResultEntity.id; | ||
this.class_name = studentResultEntity.class_name; | ||
this.name = studentResultEntity.name; | ||
this.description = studentResultEntity.description; | ||
this.result_image = studentResultEntity.result_image; | ||
this.order = studentResultEntity.order; | ||
this.status = studentResultEntity.status; | ||
this.created_at = studentResultEntity.created_at; | ||
this.updated_at = studentResultEntity.updated_at; | ||
this.created_by = studentResultEntity.created_by; | ||
this.updated_by = studentResultEntity.updated_by; | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/infrastructure/repositories/activity-classes-repository.ts
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,18 @@ | ||
import { ActivityClassesRepository } from "@application/common/interfaces"; | ||
|
||
export function makeActivityClassesRepository({ db }: Dependencies): ActivityClassesRepository { | ||
return { | ||
async list() { | ||
const activityClasses = await db.activity_class.findMany({ | ||
where: { status: 1 }, | ||
orderBy: { | ||
order: 'asc', | ||
}, | ||
}); | ||
return activityClasses.map(activityClass => ({ | ||
...activityClass, | ||
id: Number(activityClass.id), | ||
})); | ||
} | ||
} | ||
} |
Oops, something went wrong.