Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#164] Define interfaces and types for Review and Reply repositories #227

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';