generated from nhcarrigan/template
feat: add manga and shows collections
This commit is contained in:
@@ -64,6 +64,8 @@ export class CommentService {
|
||||
bookId: comment.bookId || undefined,
|
||||
musicId: comment.musicId || undefined,
|
||||
artId: comment.artId || undefined,
|
||||
showId: comment.showId || undefined,
|
||||
mangaId: comment.mangaId || undefined,
|
||||
createdAt: comment.createdAt,
|
||||
updatedAt: comment.updatedAt,
|
||||
};
|
||||
@@ -173,6 +175,58 @@ export class CommentService {
|
||||
return this.mapComment(comment);
|
||||
}
|
||||
|
||||
async getCommentsForShow(showId: string): Promise<Comment[]> {
|
||||
const comments = await this.prisma.comment.findMany({
|
||||
where: { showId },
|
||||
include: { user: true },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
return comments.map((c) => this.mapComment(c));
|
||||
}
|
||||
|
||||
async createCommentForShow(
|
||||
showId: string,
|
||||
userId: string,
|
||||
data: CreateCommentDto
|
||||
): Promise<Comment> {
|
||||
const sanitizedContent = this.sanitizeMarkdown(data.content);
|
||||
const comment = await this.prisma.comment.create({
|
||||
data: {
|
||||
content: sanitizedContent,
|
||||
userId,
|
||||
showId,
|
||||
},
|
||||
include: { user: true },
|
||||
});
|
||||
return this.mapComment(comment);
|
||||
}
|
||||
|
||||
async getCommentsForManga(mangaId: string): Promise<Comment[]> {
|
||||
const comments = await this.prisma.comment.findMany({
|
||||
where: { mangaId },
|
||||
include: { user: true },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
return comments.map((c) => this.mapComment(c));
|
||||
}
|
||||
|
||||
async createCommentForManga(
|
||||
mangaId: string,
|
||||
userId: string,
|
||||
data: CreateCommentDto
|
||||
): Promise<Comment> {
|
||||
const sanitizedContent = this.sanitizeMarkdown(data.content);
|
||||
const comment = await this.prisma.comment.create({
|
||||
data: {
|
||||
content: sanitizedContent,
|
||||
userId,
|
||||
mangaId,
|
||||
},
|
||||
include: { user: true },
|
||||
});
|
||||
return this.mapComment(comment);
|
||||
}
|
||||
|
||||
async deleteComment(commentId: string): Promise<void> {
|
||||
await this.prisma.comment.delete({
|
||||
where: { id: commentId },
|
||||
|
||||
Reference in New Issue
Block a user