diff --git a/api/src/core/ports/reply.repository.ts b/api/src/core/ports/reply.repository.ts new file mode 100644 index 00000000..8425e4ff --- /dev/null +++ b/api/src/core/ports/reply.repository.ts @@ -0,0 +1,47 @@ +import { Reply } from '@src/core/entities/review.entity'; +import { TransactionClient } from '@src/core/ports/transaction.manager'; +import { Direction } from '@src/core/services/review/types'; + +export interface CreateReplyParams { + reviewId: number; + userId: string; + content: string; +} + +export interface FindManyAndCountResponse { + replies: Reply[]; + replyCount: number; +} + +export interface FindRepliesParams { + reviewId: number; + + // sort + direction: Direction; + + // pagination + pageOffset: number; + pageSize: number; +} + +export interface UpdateReplyParams { + id: number; + content: string; +} + +export interface ReplyRepository { + create( + params: CreateReplyParams, + txClient?: TransactionClient + ): Promise; + findById(id: number, txClient?: TransactionClient): Promise; + findManyAndCount( + params: FindRepliesParams, + txClient?: TransactionClient + ): Promise; + update( + params: UpdateReplyParams, + txClient?: TransactionClient + ): Promise; + deleteById(id: number, txClient?: TransactionClient): Promise; +} diff --git a/api/src/core/ports/review.repository.ts b/api/src/core/ports/review.repository.ts new file mode 100644 index 00000000..63988f71 --- /dev/null +++ b/api/src/core/ports/review.repository.ts @@ -0,0 +1,54 @@ +import { Review } from '@src/core/entities/review.entity'; +import { TransactionClient } from '@src/core/ports/transaction.manager'; +import { Direction, SortBy } from '@src/core/services/review/types'; + +export interface CreateReviewParams { + userId: string; + title: string; + movieName: string; + content: string; +} + +export interface FindManyAndCountResponse { + reviews: Review[]; + reviewCount: number; +} + +export interface FindReviewsParams { + // filter + nickname?: string; + title?: string; + movieName?: string; + + // sort + sortBy: SortBy; + direction: Direction; + + //pagination + pageOffset: number; + pageSize: number; +} + +export interface UpdateReviewParams { + id: number; + title: string; + movieName: string; + content: string; +} + +export interface ReviewRepository { + create( + params: CreateReviewParams, + txClient?: TransactionClient + ): Promise; + findById(id: number, txClient?: TransactionClient): Promise; + findManyAndCount( + params: FindReviewsParams, + txClient?: TransactionClient + ): Promise; + update( + params: UpdateReviewParams, + txClient?: TransactionClient + ): Promise; + deleteById(id: number, txClient?: TransactionClient): Promise; +} diff --git a/api/src/core/services/review/types.ts b/api/src/core/services/review/types.ts new file mode 100644 index 00000000..f73d7f41 --- /dev/null +++ b/api/src/core/services/review/types.ts @@ -0,0 +1,3 @@ +export type SortBy = 'createdAt' | 'movieName'; + +export type Direction = 'asc' | 'desc';