Skip to content

Commit

Permalink
Merge pull request #227 from skgndi12/feature/issue-164/define-interf…
Browse files Browse the repository at this point in the history
…aces-and-types-for-review-and-reply-repositories

[#164] Define interfaces and types for Review and Reply repositories
  • Loading branch information
skgndi12 authored Mar 10, 2024
2 parents a9593d4 + 4c215da commit 48d4bd8
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
47 changes: 47 additions & 0 deletions api/src/core/ports/reply.repository.ts
Original file line number Diff line number Diff line change
@@ -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<Reply>;
findById(id: number, txClient?: TransactionClient): Promise<Reply>;
findManyAndCount(
params: FindRepliesParams,
txClient?: TransactionClient
): Promise<FindManyAndCountResponse>;
update(
params: UpdateReplyParams,
txClient?: TransactionClient
): Promise<Reply>;
deleteById(id: number, txClient?: TransactionClient): Promise<void>;
}
54 changes: 54 additions & 0 deletions api/src/core/ports/review.repository.ts
Original file line number Diff line number Diff line change
@@ -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<Review>;
findById(id: number, txClient?: TransactionClient): Promise<Review>;
findManyAndCount(
params: FindReviewsParams,
txClient?: TransactionClient
): Promise<FindManyAndCountResponse>;
update(
params: UpdateReviewParams,
txClient?: TransactionClient
): Promise<Review>;
deleteById(id: number, txClient?: TransactionClient): Promise<void>;
}
3 changes: 3 additions & 0 deletions api/src/core/services/review/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type SortBy = 'createdAt' | 'movieName';

export type Direction = 'asc' | 'desc';

0 comments on commit 48d4bd8

Please sign in to comment.